cangaroo/types
Type definitions for cangaroo.
This module defines the core types used throughout cangaroo for representing CAN sockets, clients, frames, and filters. The main types you’ll interact with are:
CanClient: The primary handle for interacting with a CAN interfaceCanFrame: Represents a CAN frame with an ID and data payloadCanFilter: Defines filtering criteria for receiving certain frames
Types
Internal message type used by the CAN client actor.
These messages are handled internally by cangaroo and are not typically used directly by application code.
RawCanData: Contains raw CAN frame data received from the bus (standard frames)RawExtendedCanData: Contains raw CAN frame data for extended frames (29-bit ID)Shutdown: Signals the actor to close the socket and stopExcansockDown: The underlying Excansock GenServer process has exited
pub type ActorMessage {
RawCanData(frame_data: dynamic.Dynamic)
RawExtendedCanData(frame_data: dynamic.Dynamic)
Shutdown
ExcansockDown(reason: process.ExitReason)
}
Constructors
-
RawCanData(frame_data: dynamic.Dynamic) -
RawExtendedCanData(frame_data: dynamic.Dynamic) -
Shutdown -
ExcansockDown(reason: process.ExitReason)
An opaque type representing an active CAN client connection.
A CanClient is the primary handle for interacting with a CAN interface.
It encapsulates:
- The underlying CAN socket connection
- An OTP actor that handles incoming frames
- A subject for receiving CAN frames in your application
Create a client using cangaroo.start_link() and close it with
cangaroo.close() when you’re done.
To receive incoming CAN frames, use the messages() function to get the subject,
then select on it with gleam/erlang/process selectors.
pub opaque type CanClient
Defines a filter for receiving certain CAN frames.
Filters control which CAN frames are delivered to your application. Each filter has three components:
id: The CAN identifier to match againstmask: A bitmask that determines which bits of the ID must matchextended:Trueto filter extended frames,Falsefor standard frames
A frame passes the filter if: (frame_id & mask) == (filter_id & mask)
pub type CanFilter {
CanFilter(id: Int, mask: Int, extended: Bool)
}
Constructors
-
CanFilter(id: Int, mask: Int, extended: Bool)
Represents a CAN frame with an identifier and data payload.
A CAN frame is the basic unit of communication on a CAN bus. Each frame contains:
id: The CAN identifier, either 11-bit (standard) or 29-bit (extended)data: The payload as aBitArray, up to 8 bytes for standard CANextended:Truefor 29-bit extended IDs,Falsefor 11-bit standard IDs
pub type CanFrame {
CanFrame(id: Int, data: BitArray, extended: Bool)
}
Constructors
-
CanFrame(id: Int, data: BitArray, extended: Bool)
An opaque type representing a CAN socket connection.
This type wraps the underlying Excansock process and is managed internally
by CanClient. You typically don’t interact with CanSocket directly,
use CanClient and the functions in the main cangaroo module instead.
pub opaque type CanSocket
Values
pub fn messages(client: CanClient) -> process.Subject(CanFrame)