Skip to main content

pamoja_serial_port_open

Function pamoja_serial_port_open 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_serial_port_open( path: *const c_char, settings: PamojaSerialSettings, out_port: *mut *mut PamojaSerialPort, ) -> PamojaStatus
Expand description

Opens the kernel’s serial device raw, at a speed and a character format. Whatever the device received before it was opened is dropped.

§Arguments

  • path - the device file: /dev/serial0 for a Raspberry Pi’s own UART, /dev/ttyUSB0 or /dev/ttyACM0 for a USB adapter.
  • settings - the speed, one of the standard rates from 1200 to 921600, and the format.
  • out_port - receives the port, or null when opening fails.

§Returns

PamojaStatus::Ok with the port in out_port; PamojaStatus::Unsupported on any platform but Linux; PamojaStatus::InvalidArgument for a null or non-UTF-8 argument or settings the port does not have; or PamojaStatus::Io when the device cannot be opened or set up, with a last error message that names it.

§Safety

path must be a null-terminated string or null, and out_port a writable pointer or null.