Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ enumeration order.
RawSerialPort:
port: '/dev/ttyUSB0'
speed: 115200
xonxoff: False

The example would access the serial port ``/dev/ttyUSB0`` on the local computer
with a baud rate of ``115200``.

Arguments:
- port (str): path to the serial device
- speed (int, default=115200): desired baud rate
- xonxoff (bool, default=False): software flow control

Used by:
- `SerialDriver`_
Expand Down
6 changes: 3 additions & 3 deletions doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ specific driver set a binding mapping before creating the driver:
>>>
>>> t = Target("Test")
>>> SerialPort(t, "First")
SerialPort(target=Target(name='Test', env=None), name='First', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200)
SerialPort(target=Target(name='Test', env=None), name='First', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200, xonxoff=False)
>>> SerialPort(t, "Second")
SerialPort(target=Target(name='Test', env=None), name='Second', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200)
SerialPort(target=Target(name='Test', env=None), name='Second', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200, xonxoff=False)
>>> t.set_binding_map({"port": "Second"})
>>> sd = SerialDriver(t, "Driver")
>>> sd
SerialDriver(target=Target(name='Test', env=None), name='Driver', state=<BindingState.bound: 1>, txdelay=0.0, timeout=3.0)
>>> sd.port
SerialPort(target=Target(name='Test', env=None), name='Second', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200)
SerialPort(target=Target(name='Test', env=None), name='Second', state=<BindingState.bound: 1>, avail=True, port=None, speed=115200, xonxoff=False)

Priorities
~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ to the resource object created above:
.. doctest::

>>> sd.port
RawSerialPort(target=Target(name='example', env=None), name=None, state=<BindingState.bound: 1>, avail=True, port='/dev/ttyUSB0', speed=115200)
RawSerialPort(target=Target(name='example', env=None), name=None, state=<BindingState.bound: 1>, avail=True, port='/dev/ttyUSB0', speed=115200, xonxoff=False)
>>> sd.port is rsp
True

Expand Down
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