Conditional imports for serial-based interfaces

This commit is contained in:
Mark Qvist 2021-12-01 13:57:40 +01:00
parent 259c2aa397
commit c44c6f9086
4 changed files with 4 additions and 0 deletions

View File

@ -47,6 +47,7 @@ class AX25KISSInterface(Interface):
serial = None serial = None
def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control): def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control):
import importlib
if importlib.util.find_spec('serial') != None: if importlib.util.find_spec('serial') != None:
import serial import serial
else: else:

View File

@ -39,6 +39,7 @@ class KISSInterface(Interface):
serial = None serial = None
def __init__(self, owner, name, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control, beacon_interval, beacon_data): def __init__(self, owner, name, port, speed, databits, parity, stopbits, preamble, txtail, persistence, slottime, flow_control, beacon_interval, beacon_data):
import importlib
if importlib.util.find_spec('serial') != None: if importlib.util.find_spec('serial') != None:
import serial import serial
else: else:

View File

@ -71,6 +71,7 @@ class RNodeInterface(Interface):
CALLSIGN_MAX_LEN = 32 CALLSIGN_MAX_LEN = 32
def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, flow_control = False, id_interval = None, id_callsign = None): def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, flow_control = False, id_interval = None, id_callsign = None):
import importlib
if importlib.util.find_spec('serial') != None: if importlib.util.find_spec('serial') != None:
import serial import serial
else: else:

View File

@ -30,6 +30,7 @@ class SerialInterface(Interface):
serial = None serial = None
def __init__(self, owner, name, port, speed, databits, parity, stopbits): def __init__(self, owner, name, port, speed, databits, parity, stopbits):
import importlib
if importlib.util.find_spec('serial') != None: if importlib.util.find_spec('serial') != None:
import serial import serial
else: else: