Skip to content

RS-232 Tools

RS-232 is the default mode for all newly opened ports. These five tools provide control over modem signal lines and break conditions — the hardware handshaking and signaling layer of point-to-point serial communication.


Read all RS-232 modem control and status line states, including the current break condition.

ParameterTypeDefaultDescription
portstrrequiredDevice path of the port to query.

Returns: Dict with success, port, input_lines (object with cts, dsr, ri, cd), output_lines (object with rts, dtr), and break_condition (bool).

get_modem_lines(port="/dev/ttyUSB0")
# Example response:
# {
# "success": true,
# "port": "/dev/ttyUSB0",
# "input_lines": {"cts": true, "dsr": true, "ri": false, "cd": false},
# "output_lines": {"rts": true, "dtr": true},
# "break_condition": false
# }

Set the RS-232 output control lines (RTS and DTR). Only the lines you specify are changed; pass None (or omit the parameter) to leave a line unchanged.

ParameterTypeDefaultDescription
portstrrequiredDevice path of the port.
rtsbool | NoneNoneSet RTS (Request To Send) state. None = no change.
dtrbool | NoneNoneSet DTR (Data Terminal Ready) state. None = no change.

Returns: Dict with success, port, rts, and dtr (current states after change).

These lines are commonly used for:

  • Hardware flow control
  • Device reset sequences (many boards use DTR for reset)
  • Power control on some devices
  • Custom signaling protocols
# Assert DTR to signal "terminal ready"
set_modem_lines(port="/dev/ttyUSB0", dtr=true)
# Drop RTS to signal "stop sending"
set_modem_lines(port="/dev/ttyUSB0", rts=false)
# Set both lines at once
set_modem_lines(port="/dev/ttyUSB0", rts=true, dtr=true)

Pulse an RS-232 control line high-then-low or low-then-high. Commonly used for device reset sequences.

ParameterTypeDefaultDescription
portstrrequiredDevice path of the port.
lineLiteral["rts", "dtr"]requiredWhich line to pulse.
duration_msint100Pulse duration in milliseconds. Must be 1-5000.
active_lowboolTrueIf True, pulse LOW then HIGH. If False, pulse HIGH then LOW.

Returns: Dict with success, port, line, duration_ms, and active_low.

The line is set to its initial state, held for duration_ms, pulsed to the active state for duration_ms, then restored to its original value.

Typical reset sequences:

  • Arduino: DTR pulse triggers auto-reset
  • ESP32/ESP8266: DTR + RTS sequence enters bootloader
  • Custom hardware: Various reset/trigger signals
# Arduino-style reset (DTR pulse, active low)
pulse_line(port="/dev/ttyUSB0", line="dtr", duration_ms=100)
# Active-high pulse on RTS
pulse_line(port="/dev/ttyUSB0", line="rts", duration_ms=200, active_low=false)
# Short trigger pulse
pulse_line(port="/dev/ttyUSB0", line="dtr", duration_ms=10)

Send a timed serial break signal — a sustained low state on the TX line longer than a character frame. Used to get the attention of a remote device or trigger special modes.

ParameterTypeDefaultDescription
portstrrequiredDevice path of the port.
duration_msint250Break duration in milliseconds. Must be 1-5000.

Returns: Dict with success, port, and duration_ms.

# Standard break signal
send_break(port="/dev/ttyUSB0")
# Short break (100ms)
send_break(port="/dev/ttyUSB0", duration_ms=100)
# Long break to force attention
send_break(port="/dev/ttyUSB0", duration_ms=1000)

Set or clear the break condition on a serial port. Unlike send_break() which sends a timed pulse, this holds the break condition indefinitely until explicitly cleared. Useful for protocols that require sustained break states.

ParameterTypeDefaultDescription
portstrrequiredDevice path of the port.
enabledboolrequiredTrue to assert break (hold TX low), False to release.

Returns: Dict with success, port, and break_condition.

# Assert break condition
set_break_condition(port="/dev/ttyUSB0", enabled=true)
# ... wait for device to respond ...
# Release break
set_break_condition(port="/dev/ttyUSB0", enabled=false)