View Source Cantastic.Socket (Cantastic v1.0.1)

Cantastic.Socket is a utility module allowing to interact with the libsocketcan Linux sockets.

If you do not want to use Cantastic's declarative way of defining frames, you could use this module to interact directly with the CAN Bus.

Summary

Functions

Bind the CAN socket in ISOTP mode on the interface, you have to provide the request_frame_id, response_frame_id and an optional tx_padding.

Bind the CAN socket in RAW mode on the interface.

Receive one message frame on the socket. This function will block indefinitely until a message is received.

Send one raw frame on the socket.

Functions

Link to this function

bind_isotp(interface, request_frame_id, response_frame_id, tx_padding \\ nil)

View Source

Bind the CAN socket in ISOTP mode on the interface, you have to provide the request_frame_id, response_frame_id and an optional tx_padding.

Returns: {:ok, socket}

Examples

iex> Cantastic.Socket.bind_isotp("can0", 0x799, 0x771, 0x0)
{:ok, socket}

Bind the CAN socket in RAW mode on the interface.

Returns: {:ok, socket}

Examples

iex> Cantastic.Socket.bind_raw("can0")
{:ok, socket}

Receive one message frame on the socket. This function will block indefinitely until a message is received.

Returns: {:ok, %Cantastic.SocketMessage{} = message}

Examples

iex> Cantastic.Socket.receive_message(socket)
{:ok, %Cantastic.SocketMessage{} = message}

Send one raw frame on the socket.

Returns: :ok

Examples

iex> Cantastic.Socket.send(socket, <<....>>)
:ok