@@ -155,19 +155,9 @@ class AlarmDecoder(object): | |||||
Sets configuration entries on the device. | Sets configuration entries on the device. | ||||
""" | """ | ||||
config_string = '' | config_string = '' | ||||
# HACK: Both of these methods are ugly.. but I can't think of an | |||||
# elegant way of doing it. | |||||
#config_string += 'ADDRESS={0}&'.format(self.address) | |||||
#config_string += 'CONFIGBITS={0:x}&'.format(self.configbits) | |||||
#config_string += 'MASK={0:x}&'.format(self.address_mask) | |||||
#config_string += 'EXP={0}&'.format(''.join(['Y' if z else 'N' for z in self.emulate_zone])) | |||||
#config_string += 'REL={0}&'.format(''.join(['Y' if r else 'N' for r in self.emulate_relay])) | |||||
#config_string += 'LRR={0}&'.format('Y' if self.emulate_lrr else 'N') | |||||
#config_string += 'DEDUPLICATE={0}'.format('Y' if self.deduplicate else 'N') | |||||
config_entries = [] | config_entries = [] | ||||
# HACK: This is ugly.. but I can't think of an elegant way of doing it. | |||||
config_entries.append(('ADDRESS', | config_entries.append(('ADDRESS', | ||||
'{0}'.format(self.address))) | '{0}'.format(self.address))) | ||||
config_entries.append(('CONFIGBITS', | config_entries.append(('CONFIGBITS', | ||||
@@ -437,7 +427,7 @@ class AlarmDecoder(object): | |||||
""" | """ | ||||
self.on_read(args, kwargs) | self.on_read(args, kwargs) | ||||
msg = self._handle_message(kwargs['data']) | |||||
msg = self._handle_message(kwargs.get('data', None)) | |||||
if msg: | if msg: | ||||
self.on_message(message=msg) | self.on_message(message=msg) | ||||
@@ -158,6 +158,7 @@ class USBDevice(Device): | |||||
"""Default baudrate for AD2USB devices.""" | """Default baudrate for AD2USB devices.""" | ||||
__devices = [] | __devices = [] | ||||
__detect_thread = None | |||||
@classmethod | @classmethod | ||||
def find_all(cls, vid=FTDI_VENDOR_ID, pid=FTDI_PRODUCT_ID): | def find_all(cls, vid=FTDI_VENDOR_ID, pid=FTDI_PRODUCT_ID): | ||||
@@ -638,10 +639,9 @@ class SerialDevice(Device): | |||||
if self._port is None: | if self._port is None: | ||||
raise NoDeviceError('No device interface specified.') | raise NoDeviceError('No device interface specified.') | ||||
self._device.port = self._port | |||||
# Open the device and start up the reader thread. | # Open the device and start up the reader thread. | ||||
try: | try: | ||||
self._device.port = self._port | |||||
self._device.open() | self._device.open() | ||||
# NOTE: Setting the baudrate before opening the | # NOTE: Setting the baudrate before opening the | ||||
# port caused issues with Moschip 7840/7820 | # port caused issues with Moschip 7840/7820 | ||||
@@ -685,7 +685,7 @@ class SerialDevice(Device): | |||||
try: | try: | ||||
self._device.write(data) | self._device.write(data) | ||||
except serial.SerialTimeoutException, err: | |||||
except serial.SerialTimeoutException: | |||||
pass | pass | ||||
except serial.SerialException, err: | except serial.SerialException, err: | ||||
@@ -808,8 +808,7 @@ class SocketDevice(Device): | |||||
:param value: Tuple containing the host and port to use. | :param value: Tuple containing the host and port to use. | ||||
:type value: tuple | :type value: tuple | ||||
""" | """ | ||||
self._host = value[0] | |||||
self._port = value[1] | |||||
self._host, self._port = value | |||||
@property | @property | ||||
def ssl(self): | def ssl(self): | ||||
@@ -49,6 +49,7 @@ class Firmware(object): | |||||
STAGE_UPLOADING = 4 | STAGE_UPLOADING = 4 | ||||
STAGE_DONE = 5 | STAGE_DONE = 5 | ||||
# FIXME: Rewrite this monstrosity. | |||||
@staticmethod | @staticmethod | ||||
def upload(dev, filename, progress_callback=None): | def upload(dev, filename, progress_callback=None): | ||||
""" | """ | ||||