Conditional imports for serial-based interfaces
This commit is contained in:
parent
10854bfdbc
commit
259c2aa397
@ -2,7 +2,6 @@
|
|||||||
from .Interface import Interface
|
from .Interface import Interface
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import sys
|
import sys
|
||||||
import serial
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import RNS
|
import RNS
|
||||||
@ -48,6 +47,13 @@ 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):
|
||||||
|
if importlib.util.find_spec('serial') != None:
|
||||||
|
import serial
|
||||||
|
else:
|
||||||
|
RNS.log("Using the AX.25 KISS interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
||||||
|
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
||||||
|
RNS.panic()
|
||||||
|
|
||||||
self.rxb = 0
|
self.rxb = 0
|
||||||
self.txb = 0
|
self.txb = 0
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from .Interface import Interface
|
from .Interface import Interface
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import sys
|
import sys
|
||||||
import serial
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import RNS
|
import RNS
|
||||||
@ -40,6 +39,13 @@ 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):
|
||||||
|
if importlib.util.find_spec('serial') != None:
|
||||||
|
import serial
|
||||||
|
else:
|
||||||
|
RNS.log("Using the KISS interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
||||||
|
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
||||||
|
RNS.panic()
|
||||||
|
|
||||||
self.rxb = 0
|
self.rxb = 0
|
||||||
self.txb = 0
|
self.txb = 0
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from .Interface import Interface
|
from .Interface import Interface
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import sys
|
import sys
|
||||||
import serial
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
@ -72,6 +71,13 @@ 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):
|
||||||
|
if importlib.util.find_spec('serial') != None:
|
||||||
|
import serial
|
||||||
|
else:
|
||||||
|
RNS.log("Using the RNode interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
||||||
|
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
||||||
|
RNS.panic()
|
||||||
|
|
||||||
self.rxb = 0
|
self.rxb = 0
|
||||||
self.txb = 0
|
self.txb = 0
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from .Interface import Interface
|
from .Interface import Interface
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import sys
|
import sys
|
||||||
import serial
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import RNS
|
import RNS
|
||||||
@ -31,6 +30,13 @@ 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):
|
||||||
|
if importlib.util.find_spec('serial') != None:
|
||||||
|
import serial
|
||||||
|
else:
|
||||||
|
RNS.log("Using the Serial interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
||||||
|
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
||||||
|
RNS.panic()
|
||||||
|
|
||||||
self.rxb = 0
|
self.rxb = 0
|
||||||
self.txb = 0
|
self.txb = 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user