mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 05:30:17 +00:00
Internal interface config handling for SerialInterface
This commit is contained in:
parent
cd8fe95d91
commit
ebf084cff0
@ -829,6 +829,7 @@ class I2PInterfacePeer(Interface):
|
|||||||
|
|
||||||
class I2PInterface(Interface):
|
class I2PInterface(Interface):
|
||||||
BITRATE_GUESS = 256*1000
|
BITRATE_GUESS = 256*1000
|
||||||
|
DEFAULT_IFAC_SIZE = 16
|
||||||
|
|
||||||
def __init__(self, owner, configuration):
|
def __init__(self, owner, configuration):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -42,6 +42,7 @@ class HDLC():
|
|||||||
|
|
||||||
class SerialInterface(Interface):
|
class SerialInterface(Interface):
|
||||||
MAX_CHUNK = 32768
|
MAX_CHUNK = 32768
|
||||||
|
DEFAULT_IFAC_SIZE = 8
|
||||||
|
|
||||||
owner = None
|
owner = None
|
||||||
port = None
|
port = None
|
||||||
@ -51,7 +52,7 @@ class SerialInterface(Interface):
|
|||||||
stopbits = None
|
stopbits = None
|
||||||
serial = None
|
serial = None
|
||||||
|
|
||||||
def __init__(self, owner, name, port, speed, databits, parity, stopbits):
|
def __init__(self, owner, configuration):
|
||||||
import importlib
|
import importlib
|
||||||
if importlib.util.find_spec('serial') != None:
|
if importlib.util.find_spec('serial') != None:
|
||||||
import serial
|
import serial
|
||||||
@ -62,6 +63,17 @@ class SerialInterface(Interface):
|
|||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
c = configuration
|
||||||
|
name = c["name"]
|
||||||
|
port = c["port"] if "port" in c else None
|
||||||
|
speed = int(c["speed"]) if "speed" in c else 9600
|
||||||
|
databits = int(c["databits"]) if "databits" in c else 8
|
||||||
|
parity = c["parity"] if "parity" in c else "N"
|
||||||
|
stopbits = int(c["stopbits"]) if "stopbits" in c else 1
|
||||||
|
|
||||||
|
if port == None:
|
||||||
|
raise ValueError("No port specified for serial interface")
|
||||||
|
|
||||||
self.HW_MTU = 564
|
self.HW_MTU = 564
|
||||||
|
|
||||||
self.pyserial = serial
|
self.pyserial = serial
|
||||||
|
@ -615,39 +615,8 @@ class Reticulum:
|
|||||||
interface_post_init(interface)
|
interface_post_init(interface)
|
||||||
|
|
||||||
if c["type"] == "SerialInterface":
|
if c["type"] == "SerialInterface":
|
||||||
port = c["port"] if "port" in c else None
|
interface = SerialInterface.SerialInterface(RNS.Transport, interface_config)
|
||||||
speed = int(c["speed"]) if "speed" in c else 9600
|
interface_post_init(interface)
|
||||||
databits = int(c["databits"]) if "databits" in c else 8
|
|
||||||
parity = c["parity"] if "parity" in c else "N"
|
|
||||||
stopbits = int(c["stopbits"]) if "stopbits" in c else 1
|
|
||||||
|
|
||||||
if port == None:
|
|
||||||
raise ValueError("No port specified for serial interface")
|
|
||||||
|
|
||||||
interface = SerialInterface.SerialInterface(
|
|
||||||
RNS.Transport,
|
|
||||||
name,
|
|
||||||
port,
|
|
||||||
speed,
|
|
||||||
databits,
|
|
||||||
parity,
|
|
||||||
stopbits
|
|
||||||
)
|
|
||||||
|
|
||||||
if "outgoing" in c and c.as_bool("outgoing") == False:
|
|
||||||
interface.OUT = False
|
|
||||||
else:
|
|
||||||
interface.OUT = True
|
|
||||||
|
|
||||||
interface.mode = interface_mode
|
|
||||||
|
|
||||||
interface.announce_cap = announce_cap
|
|
||||||
if configured_bitrate:
|
|
||||||
interface.bitrate = configured_bitrate
|
|
||||||
if ifac_size != None:
|
|
||||||
interface.ifac_size = ifac_size
|
|
||||||
else:
|
|
||||||
interface.ifac_size = 8
|
|
||||||
|
|
||||||
if c["type"] == "PipeInterface":
|
if c["type"] == "PipeInterface":
|
||||||
command = c["command"] if "command" in c else None
|
command = c["command"] if "command" in c else None
|
||||||
|
Loading…
Reference in New Issue
Block a user