Fixed Python2 remnant in interfaces

This commit is contained in:
Mark Qvist 2020-05-03 23:06:53 +02:00
parent a948d153e6
commit 4c3a874b21
3 changed files with 16 additions and 4 deletions

View File

@ -23,6 +23,12 @@ class KISS():
CMD_READY = 0x0F CMD_READY = 0x0F
CMD_RETURN = 0xFF CMD_RETURN = 0xFF
@staticmethod
def escape(data):
data = data.replace(bytes([0xdb]), bytes([0xdb])+bytes([0xdd]))
data = data.replace(bytes([0xc0]), bytes([0xdb])+bytes([0xdc]))
return data
class AX25(): class AX25():
PID_NOLAYER3 = 0xF0 PID_NOLAYER3 = 0xF0
CTRL_UI = 0x03 CTRL_UI = 0x03
@ -245,7 +251,7 @@ class AX25KISSInterface(Interface):
in_frame = False in_frame = False
escape = False escape = False
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
data_buffer = "" data_buffer = b""
last_read_ms = int(time.time()*1000) last_read_ms = int(time.time()*1000)
while self.serial.is_open: while self.serial.is_open:
@ -284,7 +290,7 @@ class AX25KISSInterface(Interface):
else: else:
time_since_last = int(time.time()*1000) - last_read_ms time_since_last = int(time.time()*1000) - last_read_ms
if len(data_buffer) > 0 and time_since_last > self.timeout: if len(data_buffer) > 0 and time_since_last > self.timeout:
data_buffer = "" data_buffer = b""
in_frame = False in_frame = False
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
escape = False escape = False

View File

@ -23,6 +23,12 @@ class KISS():
CMD_READY = 0x0F CMD_READY = 0x0F
CMD_RETURN = 0xFF CMD_RETURN = 0xFF
@staticmethod
def escape(data):
data = data.replace(bytes([0xdb]), bytes([0xdb])+bytes([0xdd]))
data = data.replace(bytes([0xc0]), bytes([0xdb])+bytes([0xdc]))
return data
class KISSInterface(Interface): class KISSInterface(Interface):
MAX_CHUNK = 32768 MAX_CHUNK = 32768
@ -236,7 +242,7 @@ class KISSInterface(Interface):
else: else:
time_since_last = int(time.time()*1000) - last_read_ms time_since_last = int(time.time()*1000) - last_read_ms
if len(data_buffer) > 0 and time_since_last > self.timeout: if len(data_buffer) > 0 and time_since_last > self.timeout:
data_buffer = "" data_buffer = b""
in_frame = False in_frame = False
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
escape = False escape = False

View File

@ -429,7 +429,7 @@ class RNodeInterface(Interface):
time_since_last = int(time.time()*1000) - last_read_ms time_since_last = int(time.time()*1000) - last_read_ms
if len(data_buffer) > 0 and time_since_last > self.timeout: if len(data_buffer) > 0 and time_since_last > self.timeout:
RNS.log(str(self)+" serial read timeout", RNS.LOG_DEBUG) RNS.log(str(self)+" serial read timeout", RNS.LOG_DEBUG)
data_buffer = "" data_buffer = b""
in_frame = False in_frame = False
command = KISS.CMD_UNKNOWN command = KISS.CMD_UNKNOWN
escape = False escape = False