serial_port
local port = serial_port.new()
port:open(name)
Functions
new() → serial_port
new() (1)
new(fd: file_descriptor) (2)
1 | Default constructor. |
2 | Converts a file descriptor into a serial_port object. |
ptypair() → serial_port, file_descriptor
Open a pair of connected pseudoterminal devices. Returns the master and the slave ends, respectively.
The flag O_NOCTTY will be used to open the slave end so it doesn’t
accidentally become the controlling terminal for the session of the calling
process.
|
Use the returned file_descriptor object in system.spawn() 's
set_ctty .
|
open(self, device: string)
Open the serial port using the specified device name.
device
is something like "COM1"
on Windows, and "/dev/ttyS0"
on POSIX
platforms.
close(self)
Close the port.
Forward the call to the function with same name in Boost.Asio:
Any asynchronous read or write operations will be cancelled immediately, and will complete with the
boost::asio::error::operation_aborted
error.
cancel(self)
Cancel all asynchronous operations associated with the acceptor.
Forward the call to the function with same name in Boost.Asio:
This function causes all outstanding asynchronous read or write operations to finish immediately, and the handlers for cancelled operations will be passed the
boost::asio::error::operation_aborted
error.
send_break(self)
Send a break sequence to the serial port.
This function causes a break sequence of platform-specific duration to be sent out the serial port.
read_some(self, buffer: byte_span) → integer
Read data from the port and blocks current fiber until it completes or errs.
Returns the number of bytes read.