Copyright © 2011-2021 Michael Santos <michael.santos@gmail.com>
dev() = iodata() | {fd, integer()}
errno() = {error, file:posix()}
fd() = any()
termios() = #termios{} | binary()
baud/1 | Return the constant defined for the baud rate for the platform. |
cfsetispeed/2 | Set the input speed of a serial device. |
cfsetospeed/2 | Set the input speed of the serial device. |
close/1 | Explicitly close a serial device. |
constant/0 | Map of atoms reprsenting terminal attribute constants to integers. |
constant/1 | |
flow/1 | Get/set serial device flow control. |
flow/2 | |
getfd/1 | Returns the file descriptor associated with the NIF resource. |
getflag/3 | Returns whether a flag is enabled. |
init/0 | |
ioctl/3 | Perform operations controlling a serial device. |
ispeed/1 | return the input speed of a serial device. |
ispeed/2 | |
mode/1 | Enable raw mode. |
offset/2 | |
open/1 | Open a serial device. |
ospeed/1 | return the output speed of a serial device. |
ospeed/2 | |
read/2 | Read from a serial device. |
readx/2 | Read the specified number of bytes from a serial device. |
readx/3 | |
setflag/2 | Returns an Erlang termios record used for setting the attributes of a serial device. |
tcgetattr/1 | Get the terminal attributes of a serial device. |
tcsetattr/3 | Sets the terminal attributes of a serial device. |
termios/1 | |
wordalign/1 | |
wordalign/2 | |
write/2 | Write data to a serial device. |
baud(Speed) -> any()
Return the constant defined for the baud rate for the platform
cfsetispeed(Termios::termios(), Speed::atom() | integer()) -> binary()
Set the input speed of a serial device
See the warning for tcsetattr/2.
Failure: badarg if Speed is an invalid atom.cfsetospeed(Termios::termios(), Speed::atom() | integer()) -> binary()
Set the input speed of the serial device.
See the warning for tcsetattr/2.
Failure: badarg if Speed is an invalid atom.Explicitly close a serial device
The device is automatically closed if the process holding open the serial device exits.constant() -> proplists:proplist()
Map of atoms reprsenting terminal attribute constants to integers
Varies across platforms.constant(X1::atom()) -> integer() | undefined
flow(Termios::<<_:64, _:_*8>> | #termios{}) -> boolean()
Get/set serial device flow control
flow/1 indicates whether flow control is enabled in a serial device's terminal attributes. flow/2 returns a termios structure that can be used for setting a serial device's flow control.flow(Termios::<<_:64, _:_*8>> | #termios{}, Bool::boolean()) -> #termios{}
getfd(X1::fd()) -> integer()
Returns the file descriptor associated with the NIF resource
The file descriptor can be used with erlang:open_port/2.getflag(Termios::<<_:64, _:_*8>> | #termios{}, Flag::cflag | iflag | lflag | oflag, Opt::atom()) -> boolean()
Returns whether a flag is enabled
Opt is one of the atoms returned using serctl:constant/0.init() -> any()
Perform operations controlling a serial device
The In argument is a binary holding the input parameter to the device request. The Out parameter will hold the result of the request if the ioctl is in/out.ispeed(Speed::binary() | #termios{}) -> non_neg_integer()
return the input speed of a serial device
Note the speed returned is the constant defined for the system and may differ between platforms.
ispeed/2 returns an Erlang termios record that can be used for setting the input speed of the serial device.
Failure: badarg if Speed is an invalid atom.ispeed(Termios::<<_:64, _:_*8>> | #termios{}, Speed::atom() | integer()) -> <<_:8, _:_*8>> | #termios{}
mode(X1) -> any()
Enable raw mode
Returns an Erlang termios record with attributes that can be used to put the serial device into raw mode.offset(Cc, X2) -> any()
Open a serial device
A serial device is a character device such as /dev/ttyUSB0.
A previously opened file descriptor can also be used. The fd should be opened with the O_NONBLOCK|O_NOCTTY flags.ospeed(Speed::binary() | #termios{}) -> non_neg_integer()
return the output speed of a serial device
Note the speed returned is the constant defined for the system and may differ between platforms.
ospeed/2 returns an Erlang termios record that can be used for setting the output speed of the serial device.
Failure: badarg if Speed is an invalid atom.ospeed(Termios::<<_:64, _:_*8>> | #termios{}, Speed::atom() | integer()) -> <<_:8, _:_*8>> | #termios{}
Read from a serial device
Size is an unsigned long.Read the specified number of bytes from a serial device
readx/2 will block forever.
readx/3 accepts a timeout value. The behaviour of readx/3 when the timeout is reached is to throw away any buffered data and return {error, eintr} to the caller, e.g., the caller will not be returned the contents of a partial read. (The justification for this behaviour: the caller has stated they require a fixed number of bytes so the contents of a partial read represents unspecified behaviour.)setflag(Termios::binary() | #termios{}, Opt::proplists:proplist()) -> #termios{}
Returns an Erlang termios record used for setting the attributes of a serial device
For example, to create attributes that can be used to enable hardware flow control on a serial device:
{ok, FD} = serctl:open("/dev/ttyUSB0"), {ok, Termios} = serctl:tcgetattr(FD), Termios1 = serctl:setflag(Termios, [{cflag, [{crtscts, true}]}]), ok = serctl:tcsetattr(FD, tcsanow, Termios1).
Get the terminal attributes of a serial device
Returns the contents of the system struct termios as a binary.tcsetattr(FD::fd(), Action::[atom()] | atom() | integer(), Termios::termios()) -> ok | errno() | {error, unsupported}
Sets the terminal attributes of a serial device
'tcsasoft' is a non-portable, BSD action. tcsetattr/3 will return{error,unsupported}
on other platforms. Warning: the contents of
Termios are passed directly to tcsettr(3). If the system tcsettr(3)
does not perform any validation of the structure, it is possible the
Erlang VM may crash.
termios(Termios::binary() | #termios{}) -> binary() | #termios{}
wordalign(Offset) -> any()
wordalign(Offset, Align) -> any()
Write data to a serial device
Partial writes return the number of bytes written.Generated by EDoc