Sniff (sniff v0.1.7)

Elixir Serial Port NIF.

#this echo sample requires a loopback plug
iex(1)> {:ok, nid} = Sniff.open("/dev/ttyUSB0", 9600, "8N1")
{:ok, #Reference<0.83505167.3498704899.238160>}
iex(2)> Sniff.write(nid, "hello")
:ok
iex(3)> Sniff.read(nid)
{:ok, "hello"}
iex(4)> Sniff.close(nid)
:ok

The Serial Port is auto closed if its owner process exits.

Link to this section Summary

Functions

Closes the Serial Port.

Opens the Serial Port.

Reads from the Serial Port (non blocking).

Writes to the Serial Port.

Link to this section Functions

Closes the Serial Port.

Returns :ok | {:er, reason}.

Link to this function

open(device, speed, config)

Opens the Serial Port.

Returns {:ok, nid} | {:er, reason}.

Reads from the Serial Port (non blocking).

Returns {:ok, data} | {:er, reason}.

Link to this function

write(nid, data)

Writes to the Serial Port.

Returns :ok | {:er, reason}.