Skip to content

open_serialOpenSerialOpenSerialopen_serialT_open_serial🔗

Short description🔗

open_serialOpenSerialOpenSerialopen_serialT_open_serial — Open a serial device.

Signature🔗

open_serial( filename PortName, out serial SerialHandle )void OpenSerial( const HTuple& PortName, HTuple* SerialHandle )static void HOperatorSet.OpenSerial( HTuple portName, out HTuple serialHandle )def open_serial( port_name: str ) -> HHandle

Herror T_open_serial( const Htuple PortName, Htuple* SerialHandle )

void HSerial::HSerial( const HString& PortName )

void HSerial::HSerial( const char* PortName )

void HSerial::HSerial( const wchar_t* PortName ) (Windows only)

public HSerial( string portName )

void HSerial::OpenSerial( const HString& PortName )

void HSerial::OpenSerial( const char* PortName )

void HSerial::OpenSerial( const wchar_t* PortName ) (Windows only)

void HSerial.OpenSerial( string portName )

Description🔗

open_serialOpenSerial opens a serial device. The name of the device is determined by the parameter PortNameportNameport_name and is operating system specific. On Windows machines, 'COM1'"COM1"-'COM4'"COM4" is typically used, while on Unix-like systems the serial devices usually are named '/dev/tty*'"/dev/tty*". The parameters of the serial device, e.g., its speed or number of data bits, are set to the system default values for the respective device after the device has been opened. They can be set or changed by calling set_serial_paramSetSerialParam.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters🔗

PortNameportNameport_name (input_control) filename → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of the serial port.

Default: 'COM1'"COM1"
Suggested values: 'COM1', 'COM2', 'COM3', 'COM4', '/dev/ttya', '/dev/ttyb', '/dev/tty00', '/dev/tty01', '/dev/ttyd1', '/dev/ttyd2', '/dev/cua0', '/dev/cua1'"COM1", "COM2", "COM3", "COM4", "/dev/ttya", "/dev/ttyb", "/dev/tty00", "/dev/tty01", "/dev/ttyd1", "/dev/ttyd2", "/dev/cua0", "/dev/cua1"

SerialHandleserialHandleserial_handle (output_control) serial → (handle)HTuple (HHandle)HSerial, HTuple (IntPtr)HHandleHtuple (handle)

Serial interface handle.

Result🔗

If the parameters are correct and the device could be opened, the operator open_serialOpenSerial returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible successors

set_serial_paramSetSerialParam, read_serialReadSerial, write_serialWriteSerial, close_serialCloseSerial

See also

set_serial_paramSetSerialParam, get_serial_paramGetSerialParam, open_fileOpenFile

Module🔗

Foundation