mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 23:40:18 +00:00
Added flow control timeouts to AX.25 interface and optimised timeouts.
This commit is contained in:
parent
cd9daaefee
commit
425f0153d0
@ -62,13 +62,12 @@ class AX25KISSInterface(Interface):
|
|||||||
self.stopbits = stopbits
|
self.stopbits = stopbits
|
||||||
self.timeout = 100
|
self.timeout = 100
|
||||||
self.online = False
|
self.online = False
|
||||||
# TODO: Sane default and make this configurable
|
|
||||||
# TODO: Changed to 25ms instead of 100ms, check it
|
|
||||||
self.txdelay = 0.025
|
|
||||||
|
|
||||||
self.packet_queue = []
|
self.packet_queue = []
|
||||||
self.flow_control = flow_control
|
self.flow_control = flow_control
|
||||||
self.interface_ready = False
|
self.interface_ready = False
|
||||||
|
self.flow_control_timeout = 5
|
||||||
|
self.flow_control_locked = time.time()
|
||||||
|
|
||||||
if (len(self.src_call) < 3 or len(self.src_call) > 6):
|
if (len(self.src_call) < 3 or len(self.src_call) > 6):
|
||||||
raise ValueError("Invalid callsign for "+str(self))
|
raise ValueError("Invalid callsign for "+str(self))
|
||||||
@ -197,6 +196,7 @@ class AX25KISSInterface(Interface):
|
|||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
if self.flow_control:
|
if self.flow_control:
|
||||||
self.interface_ready = False
|
self.interface_ready = False
|
||||||
|
self.flow_control_locked = time.time()
|
||||||
|
|
||||||
encoded_dst_ssid = bytes([0x60 | (self.dst_ssid << 1)])
|
encoded_dst_ssid = bytes([0x60 | (self.dst_ssid << 1)])
|
||||||
encoded_src_ssid = bytes([0x60 | (self.src_ssid << 1) | 0x01])
|
encoded_src_ssid = bytes([0x60 | (self.src_ssid << 1) | 0x01])
|
||||||
@ -223,9 +223,6 @@ class AX25KISSInterface(Interface):
|
|||||||
data = data.replace(bytes([0xc0]), bytes([0xdb])+bytes([0xdc]))
|
data = data.replace(bytes([0xc0]), bytes([0xdb])+bytes([0xdc]))
|
||||||
kiss_frame = bytes([KISS.FEND])+bytes([0x00])+data+bytes([KISS.FEND])
|
kiss_frame = bytes([KISS.FEND])+bytes([0x00])+data+bytes([KISS.FEND])
|
||||||
|
|
||||||
if (self.txdelay > 0):
|
|
||||||
sleep(self.txdelay)
|
|
||||||
|
|
||||||
written = self.serial.write(kiss_frame)
|
written = self.serial.write(kiss_frame)
|
||||||
if written != len(kiss_frame):
|
if written != len(kiss_frame):
|
||||||
if self.flow_control:
|
if self.flow_control:
|
||||||
@ -293,7 +290,13 @@ class AX25KISSInterface(Interface):
|
|||||||
in_frame = False
|
in_frame = False
|
||||||
command = KISS.CMD_UNKNOWN
|
command = KISS.CMD_UNKNOWN
|
||||||
escape = False
|
escape = False
|
||||||
sleep(0.08)
|
sleep(0.05)
|
||||||
|
|
||||||
|
if self.flow_control:
|
||||||
|
if not self.interface_ready:
|
||||||
|
if time.time() > self.flow_control_locked + self.flow_control_timeout:
|
||||||
|
RNS.log("Interface "+str(self)+" is unlocking flow control due to time-out. This should not happen. Your hardware might have missed a flow-control READY command, or maybe it does not support flow-control.", RNS.LOG_WARNING)
|
||||||
|
self.process_queue()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.online = False
|
self.online = False
|
||||||
|
@ -60,7 +60,7 @@ class KISSInterface(Interface):
|
|||||||
self.packet_queue = []
|
self.packet_queue = []
|
||||||
self.flow_control = flow_control
|
self.flow_control = flow_control
|
||||||
self.interface_ready = False
|
self.interface_ready = False
|
||||||
self.flow_control_timeout = 10
|
self.flow_control_timeout = 5
|
||||||
self.flow_control_locked = time.time()
|
self.flow_control_locked = time.time()
|
||||||
|
|
||||||
self.preamble = preamble if preamble != None else 350;
|
self.preamble = preamble if preamble != None else 350;
|
||||||
@ -259,12 +259,12 @@ class KISSInterface(Interface):
|
|||||||
in_frame = False
|
in_frame = False
|
||||||
command = KISS.CMD_UNKNOWN
|
command = KISS.CMD_UNKNOWN
|
||||||
escape = False
|
escape = False
|
||||||
sleep(0.08)
|
sleep(0.05)
|
||||||
|
|
||||||
if self.flow_control:
|
if self.flow_control:
|
||||||
if not self.interface_ready:
|
if not self.interface_ready:
|
||||||
if time.time() > self.flow_control_locked + self.flow_control_timeout:
|
if time.time() > self.flow_control_locked + self.flow_control_timeout:
|
||||||
RNS.log("Interface "+str(self)+" is unlocking flow control due to time-out. This should not happen. Your hardware might have missed a flow-control READY command.", RNS.LOG_WARNING)
|
RNS.log("Interface "+str(self)+" is unlocking flow control due to time-out. This should not happen. Your hardware might have missed a flow-control READY command, or maybe it does not support flow-control.", RNS.LOG_WARNING)
|
||||||
self.process_queue()
|
self.process_queue()
|
||||||
|
|
||||||
if self.beacon_i != None and self.beacon_d != None:
|
if self.beacon_i != None and self.beacon_d != None:
|
||||||
|
Loading…
Reference in New Issue
Block a user