fn controllino_open_serial_port(
port_name: String,
baud_rate: u32,
timeout_millis: u64,
) -> Result<Box<dyn SerialPort>, ActuateControllinoError>Expand description
Opens and initializes a serial port connection to the Controllino device.
This function attempts to establish a serial communication link using the provided port name and baud rate. It also configures the port timeout, performs a DTR reset, and clears input/output buffers to ensure a clean communication state before returning the opened port.
§Arguments
port_name- The name of the serial port (e.g., “/dev/ttyUSB0” on Linux).baud_rate- The baud rate for serial communication (e.g., 9600).timeout_millis- The read/write timeout for serial port operations in milliseconds.
§Returns
A Result containing a Box<dyn SerialPort> representing the opened and configured serial port on success.
§Errors
Returns an ActuateControllinoError if any step of the initialization fails:
SerialPortOpenFailed: If the port cannot be opened.SetTimeoutFailed: If the timeout cannot be set on the port.ClearDTRFailed: If the Data Terminal Ready signal cannot be cleared.ClearBufferFailed: If the serial port’s internal buffers cannot be cleared.