Browse Source

Moved read thread initialization to support reopening closed devices.

pyserial_fix
Scott Petersen 10 years ago
parent
commit
fba1baa521
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      alarmdecoder/devices.py

+ 7
- 1
alarmdecoder/devices.py View File

@@ -48,7 +48,7 @@ class Device(object):
self._buffer = ''
self._device = None
self._running = False
self._read_thread = Device.ReadThread(self)
self._read_thread = None

def __enter__(self):
"""
@@ -363,6 +363,8 @@ class USBDevice(Device):
if baudrate is None:
baudrate = USBDevice.BAUDRATE

self._read_thread = Device.ReadThread(self)

# Open the device and start up the thread.
try:
self._device.open(self._vendor_id,
@@ -653,6 +655,8 @@ class SerialDevice(Device):
if self._port is None:
raise NoDeviceError('No device interface specified.')

self._read_thread = Device.ReadThread(self)

# Open the device and start up the reader thread.
try:
self._device.port = self._port
@@ -922,6 +926,8 @@ class SocketDevice(Device):
"""

try:
self._read_thread = Device.ReadThread(self)

self._device = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

if self._use_ssl:


Loading…
Cancel
Save