Browse Source

Updated default address mask, proper handling of invalid messages, added fileno() to support use with select().

pyserial_fix
Scott Petersen 11 years ago
parent
commit
0a6d493d11
2 changed files with 19 additions and 4 deletions
  1. +1
    -1
      alarmdecoder/decoder.py
  2. +18
    -3
      alarmdecoder/devices.py

+ 1
- 1
alarmdecoder/decoder.py View File

@@ -66,7 +66,7 @@ class AlarmDecoder(object):
"""The keypad address in use by the device."""
configbits = 0xFF00
"""The configuration bits set on the device."""
address_mask = 0x00000000
address_mask = 0xFFFFFFFF
"""The address mask configured on the device."""
emulate_zone = [False for _ in range(5)]
"""List containing the devices zone emulation status."""


+ 18
- 3
alarmdecoder/devices.py View File

@@ -25,7 +25,7 @@ import socket

from OpenSSL import SSL, crypto
from pyftdi.pyftdi.ftdi import Ftdi, FtdiError
from .util import CommError, TimeoutError, NoDeviceError
from .util import CommError, TimeoutError, NoDeviceError, InvalidMessageError
from .event import event


@@ -149,7 +149,10 @@ class Device(object):
except TimeoutError:
pass

except Exception:
except InvalidMessageError:
pass

except Exception, err:
self._running = False


@@ -234,7 +237,10 @@ class USBDevice(Device):
"""
cls.__detect_thread = USBDevice.DetectThread(on_attached, on_detached)

cls.find_all()
try:
cls.find_all()
except CommError:
pass

cls.__detect_thread.start()

@@ -390,6 +396,9 @@ class USBDevice(Device):
except Exception:
pass

def fileno(self):
raise NotImplementedError('USB devices do not support fileno()')

def write(self, data):
"""
Writes data to the device.
@@ -670,6 +679,9 @@ class SerialDevice(Device):
except Exception:
pass

def fileno(self):
return self._device.fileno()

def write(self, data):
"""
Writes data to the device.
@@ -944,6 +956,9 @@ class SocketDevice(Device):
except Exception:
pass

def fileno(self):
return self._device.fileno()

def write(self, data):
"""
Writes data to the device.


Loading…
Cancel
Save