cuewire
0.1.1.dev19+g401898733

Contents

  • Quickstart
  • Worked example: two_led_thermo
  • Wire protocol
  • API reference
    • cuewire.constants
    • cuewire.serial_link
      • ArduinoSerial
        • ArduinoSerial.close()
        • ArduinoSerial.comm_test()
        • ArduinoSerial.flush_all()
        • ArduinoSerial.read_buffer()
        • ArduinoSerial.read_line()
        • ArduinoSerial.reset_clock()
        • ArduinoSerial.send_command()
        • ArduinoSerial.send_command_verbose()
        • ArduinoSerial.send_command_with_follow_float()
        • ArduinoSerial.send_command_with_follow_int()
        • ArduinoSerial.set_write_out()
        • ArduinoSerial.write_float()
        • ArduinoSerial.write_int()
      • CommTestError
    • cuewire.port_select
    • cuewire.huepfburg
    • cuewire.cli
    • cuewire.experiments.sample_experiment
    • cuewire.experiments.rocking_trigger_experiment
cuewire
  • API reference
  • cuewire.serial_link
  • View page source

cuewire.serial_link

Generic Python ↔ Arduino serial link.

Classes

ArduinoSerial(port[, baud, timeout, ...])

Generic integer-command bridge to a PARROTard Arduino.

Exceptions

CommTestError

Raised when the Arduino fails to reply with 50 1337.

class cuewire.serial_link.ArduinoSerial(port: str | _SerialLike, baud: int = 9600, timeout: float = 0.1, comm_test_on_open: bool = True)[source]

Bases: object

Generic integer-command bridge to a PARROTard Arduino.

Use as a context manager:

with ArduinoSerial(“/dev/ttyUSB0”) as ard:

ard.set_write_out(True) ard.reset_clock()

Parameters:
  • port – Device path or pyserial-compatible object.

  • baud – Serial baud rate.

  • timeout – Read timeout in seconds.

  • comm_test_on_open – Run the 50 1337 handshake on enter.

close() → None[source]
comm_test() → bool[source]

Run the 50 1337 handshake; raise CommTestError on failure.

flush_all() → None[source]

Flush output and reset both buffers.

read_buffer() → str[source]

Drain the input buffer; useful for diagnostics.

read_line() → str[source]

Read one newline-terminated line, stripped of CR/LF.

reset_clock(settle_s: float = 0.0) → None[source]

Reset the firmware’s clockVar to zero.

send_command(name: str, settle_s: float = 0.0) → None[source]

Send a named command (looked up in COMMAND_IDS).

send_command_verbose(name: str, settle_s: float = 1.0) → str[source]

Send a named command and read the next single-line response.

send_command_with_follow_float(name: str, follow: float, settle_s: float = 0.0) → None[source]

Send a command followed by a float parameter.

send_command_with_follow_int(name: str, follow: int, settle_s: float = 0.0) → None[source]

Send a command followed by an integer parameter.

set_write_out(enabled: bool, settle_s: float = 0.0) → None[source]

Toggle the Arduino’s continuous serial write-out.

write_float(value: float, settle_s: float = 0.0) → None[source]

Send a float (encoded as ASCII).

write_int(value: int, settle_s: float = 0.0) → None[source]

Send an integer (encoded as ASCII).

exception cuewire.serial_link.CommTestError[source]

Bases: RuntimeError

Raised when the Arduino fails to reply with 50 1337.

Previous Next

© Copyright 2026, Bart R. H. Geurten.

Built with Sphinx using a theme provided by Read the Docs.