Module port
AtomVM port driver APIs.
Description
This module contains functions that are intended to be used by drivers that
rely on a port interface rather than nifs.
The port driver should be initialized with:
open_port({spawn, "Name"}, Param)
Where Name is an atom(), and is the name of the driver. The return from open_port/2
will be the Pid that will be required for future port:call/2 or port:call/3 use.
Examples:
open_port({spawn, "i2c"}, Param)
or
open_port({spawn, "spi"}, Params)
Function Index
| call/2 | Send a message to a given port driver pid. |
| call/3 | Send a message to a given port driver pid with a timeout. |
Function Details
call/2
call(Port::pid(), Message::term()) -> term()
Port: Pid to which to send messagesMessage: the message to send
returns: term() | {error, Reason}.
Send a message to a given port driver pid.
This function is used to send a message to an open port divers pid and will
return a term or {error, Reason}.
call/3
call(Port::pid(), Message::term(), Timeout::timeout()) -> term() | {error, timeout}
Port: Pid to which to send messagesMessage: the message to sendTimeout: the timeout value in milliseconds
returns: term() | {error, Reason}.
Send a message to a given port driver pid with a timeout.
This function is used to send a message to an open port divers pid and will return
a term or {error, Reason}, or{error, timeout} if the TimeoutMs is reached first.