"""
@copyright: 2013 Single D Software - All Rights Reserved
@summary: DMX USB Pro interface for Light Maestro.
"""

# Standard library imports
import logging

# Additional library imports
import serial

# Application imports
import console


# Named logger for this module
_logger = logging.getLogger(__name__)


_dmxheader = bytes([0x7e, 0x06, 0x01, 0x02])
_dmxfooter = bytes([0xe7])


class DmxUsbPro(console.Console):
    """Interface to ENTTEC DMX USB Pro compatible devices."""

    def getstatus(self):
        status = super().getstatus()
        status['condition'] = 'operational' if self._portavailable else 'nonoperational'
        return status

    def _setchannels(self, channels):
        super()._setchannels(channels)
        for c, v in self._channels.items():
            self._universe[int(c)] = max(0, min(int(v * 255.0 / 100.0), 255))
        if not self._port.isOpen():
            try:
                self._port.open()
            except IOError:
                if self._portavailable:
                    _logger.error('Unable to open port {0}'.format(self._port.name))
                    self._portavailable = False
                return
            if not self._portavailable:
                self._portavailable = True
                _logger.info('Opened port {0}'.format(self._port.name))
        try:
            self._port.write(_dmxheader + self._universe + _dmxfooter)
        except IOError:
            _logger.warning('Could not write to port {0}'.format(self._port.name))
            self._port.close()
            return

    def __init__(self, parameter):
        self._universe = bytearray(513)
        self._port = serial.Serial()
        self._baudrate = 115200
        self._port.port = parameter
        self._portavailable = False
        super().__init__()

@@ -789,30 +789,13 @@
     
-self._universe%5Bint(c)%5D
+value
  = m
@@ -834,16 +834,222 @@
 , 255))%0A
+            try:%0A                self._universe%5Bint(c)%5D = value%0A            except IndexError:%0A                _logger.warning('Ignoring channel %7B0%7D, which is outside of DMX universe max of 512'.format(c))%0A
         
@@ -1147,32 +1147,32 @@
 except IOError:%0A
-
                 
@@ -1185,32 +1185,63 @@
 f._portavailable
+ or self._portavailable is None
 :%0A              
@@ -1981,36 +1981,35 @@
 portavailable = 
-Fals
+Non
 e%0A        super(

Improve error reporting in DmxUsbPro module.