Browse Source

update serial read_line

main
AJ Schmidt 4 years ago
parent
commit
a48cecee59
2 changed files with 6 additions and 6 deletions
  1. +1
    -1
      alarmdecoder/devices/serial_device.py
  2. +5
    -5
      alarmdecoder/util.py

+ 1
- 1
alarmdecoder/devices/serial_device.py View File

@@ -229,7 +229,7 @@ class SerialDevice(Device):
buf = filter_ad2prot_byte(self._device.read(1))

if buf != b'':
self._buffer += buf[0]
self._buffer += buf

if buf == b"\n":
self._buffer = self._buffer.rstrip(b"\r\n")


+ 5
- 5
alarmdecoder/util.py View File

@@ -97,14 +97,14 @@ def filter_ad2prot_byte(buf):
"""
Return the byte sent in back if valid visible terminal characters or line terminators.
"""
c = buf[0];
c = buf[0]

if (c == '\n' or c == '\r'):
return c
if (c == 10 or c == 13):
return buf
if (c > 31 and c < 127):
return c
return buf
else:
return ''
return b''

def read_firmware_file(file_path):
"""


Loading…
Cancel
Save