From efb02649b4c1b6af2ab2431570becf33c231d742 Mon Sep 17 00:00:00 2001 From: Jakob Arndt Date: Mon, 3 Oct 2022 22:30:16 +0200 Subject: [PATCH] Changes to use Labgrid with XFCP This commit modifies the interface class, in a way that it is possible to utilize the serial instance created by labgrid. To use it a SerialDriver class has to passed to the __init__ function as a forth parameter. Signed-off-by: Jakob Arndt --- python/xfcp/interface.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/xfcp/interface.py b/python/xfcp/interface.py index 3db1ebb3..d590ef85 100644 --- a/python/xfcp/interface.py +++ b/python/xfcp/interface.py @@ -108,12 +108,20 @@ def get_root(self): class SerialInterface(Interface): - def __init__(self, port='/dev/ttyUSB0', baud=115200, timeout=10): + def __init__(self, port='/dev/ttyUSB0', baud=115200, timeout=10, driver=None): + """ + driver is expected to be a SerialDriver class from the labgrid module + """ super().__init__() self.port = port self.baud = baud - self.serial_port = serial.Serial(port, baud, timeout=timeout) + + # if labgrid driver is given, use labgrid driver + if driver is None: + self.serial_port = serial.Serial(port, baud, timeout=timeout) + else: + self.serial_port = driver.serial @property def timeout(self):