Native Serial/UART communication. Provides high-performance, zero-dependency access to hardware serial ports.

Static methods

@:value({ stopBits : 1, parity : NONE, dataBits : 8, baudRate : 9600 })staticopen(portName:String, baudRate:Int = 9600, dataBits:Int = 8, parity:SerialParity = NONE, stopBits:Int = 1):SerialPort

Opens a serial port.

Parameters:

portName

Device path (e.g. "/dev/ttyUSB0", "COM3").

baudRate

Baud rate (standard values: 9600, 115200, etc.).

dataBits

Number of data bits (usually 8).

parity

Parity mode.

stopBits

Number of stop bits (1 or 2).

Returns:

SerialPort instance or null if opening failed.

Variables

Methods

close():Void

Closes the serial port.

read(buffer:NativeBuffer):Int

Reads bytes from the serial port into a native buffer.

Returns:

Number of bytes read, or -1 on error.

@:value({ length : -1 })write(buffer:NativeBuffer, length:Int = -1):Int

Writes bytes to the serial port from a native buffer.

Parameters:

buffer

The source buffer.

length

Number of bytes to write (defaults to buffer size).

Returns:

Number of bytes written, or -1 on error.