Skip to content

Commit

Permalink
Extend SerialPort
Browse files Browse the repository at this point in the history
Adding software flow control parameter xonoff to SerialPort.

Signed-off-by: Sebastian Bergt <[email protected]>
  • Loading branch information
sebastianbergt committed Feb 10, 2025
1 parent de5257d commit 1158cab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions labgrid/driver/serialdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def on_activate(self):
if isinstance(self.port, SerialPort):
self.serial.port = self.port.port
self.serial.baudrate = self.port.speed
self.serial.xonxoff = self.port.xonxoff
else:
host, port = proxymanager.get_host_and_port(self.port)
if self.port.protocol == "rfc2217":
Expand Down
4 changes: 3 additions & 1 deletion labgrid/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class SerialPort(Resource):
Args:
port (str): port to connect to
speed (int): speed of the port, defaults to 115200"""
speed (int): speed of the port, defaults to 115200
xonxoff (bool): software flow control, defaults to False (=off)"""
port = attr.ib(default=None)
speed = attr.ib(default=115200, validator=attr.validators.instance_of(int))
xonxoff = attr.ib(default=False, validator=attr.validators.instance_of(bool))


@target_factory.reg_resource
Expand Down
1 change: 1 addition & 0 deletions tests/test_serialport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ def test_instanziation_with(self, target):
s = RawSerialPort(target, 'serial', 'port', 115200)
assert (s.port == 'port')
assert (s.speed == 115200)
assert (s.xonxoff == False)
assert s in target.resources

0 comments on commit 1158cab

Please sign in to comment.