Browse Source

More cleanup.

pyserial_fix
Scott 11 years ago
parent
commit
75e39f04fd
3 changed files with 8 additions and 18 deletions
  1. +3
    -13
      alarmdecoder/decoder.py
  2. +4
    -5
      alarmdecoder/devices.py
  3. +1
    -0
      alarmdecoder/util.py

+ 3
- 13
alarmdecoder/decoder.py View File

@@ -155,19 +155,9 @@ class AlarmDecoder(object):
Sets configuration entries on the device.
"""
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 = []

# HACK: This is ugly.. but I can't think of an elegant way of doing it.
config_entries.append(('ADDRESS',
'{0}'.format(self.address)))
config_entries.append(('CONFIGBITS',
@@ -437,7 +427,7 @@ class AlarmDecoder(object):
"""
self.on_read(args, kwargs)

msg = self._handle_message(kwargs['data'])
msg = self._handle_message(kwargs.get('data', None))
if msg:
self.on_message(message=msg)



+ 4
- 5
alarmdecoder/devices.py View File

@@ -158,6 +158,7 @@ class USBDevice(Device):
"""Default baudrate for AD2USB devices."""

__devices = []
__detect_thread = None

@classmethod
def find_all(cls, vid=FTDI_VENDOR_ID, pid=FTDI_PRODUCT_ID):
@@ -638,10 +639,9 @@ class SerialDevice(Device):
if self._port is None:
raise NoDeviceError('No device interface specified.')

self._device.port = self._port

# Open the device and start up the reader thread.
try:
self._device.port = self._port
self._device.open()
# NOTE: Setting the baudrate before opening the
# port caused issues with Moschip 7840/7820
@@ -685,7 +685,7 @@ class SerialDevice(Device):
try:
self._device.write(data)

except serial.SerialTimeoutException, err:
except serial.SerialTimeoutException:
pass

except serial.SerialException, err:
@@ -808,8 +808,7 @@ class SocketDevice(Device):
:param value: Tuple containing the host and port to use.
:type value: tuple
"""
self._host = value[0]
self._port = value[1]
self._host, self._port = value

@property
def ssl(self):


+ 1
- 0
alarmdecoder/util.py View File

@@ -49,6 +49,7 @@ class Firmware(object):
STAGE_UPLOADING = 4
STAGE_DONE = 5

# FIXME: Rewrite this monstrosity.
@staticmethod
def upload(dev, filename, progress_callback=None):
"""


Loading…
Cancel
Save