Expand description
The Broadcast Manager protocol provides a command based configuration interface to filter and send (e.g. cyclic) CAN messages in kernel space. Filtering messages in kernel space may significantly reduce the load in an application.
A BCM socket is not intended for sending individual CAN frames. To send invidiual frames use the tokio-socketcan crate.
§Example
use std::time;
use tokio_socketcan_bcm::*;
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() {
let socket = BCMSocket::open_nb("vcan0").unwrap();
let ival = time::Duration::from_millis(0);
// create a stream of messages that filters by the can frame id 0x123
let mut can_frame_stream = socket
.filter_id_incoming_frames(0x123.into(), ival, ival)
.unwrap();
while let Some(frame) = can_frame_stream.next().await {
println!("Frame {:?}", frame);
()
}
}Structs§
- BCMSocket
- A socket for a CAN device, specifically for broadcast manager operations.
- BcmFrame
Stream - BcmMsg
Head - BcmMsgHead
- BcmMsg
Head Frame Less - BcmMsgHeadFrameLess
- BcmStream
- CANAddr
- CANFrame
- CANFrame
- Frame
Flags - TxMsg
Enums§
- CANMessage
Id - 11-bit or 29-bit identifier of can frame.
- Construction
Error - Error that occurs when creating CAN packets
Constants§
- AF_CAN
- defined in socket.h
- CAN_BCM
- CAN_
FD_ FRAME - MAX_
NFRAMES - PF_CAN
- defined in socket.h
- RX_
ANNOUNCE_ RESUM - refers also to the time-out supervision of the management RX_SETUP. By setting this flag, when an RX-outs occours, a RX_CHANGED will be generated when the (cyclic) receive restarts. This will happen even if the user data have not changed.
- RX_
CHANGED - sent if the first or a revised CAN message was received
- RX_
CHECK_ DLC - A change of the DLC leads to an RX_CHANGED.
- RX_
DELETE - remove RX content filter subscription
- RX_
FILTER_ ID - Filter by can_id alone, no frames required (nframes=0)
- RX_
NO_ AUTOTIMER - If the timer ival1 in the RX_SETUP has been set equal to zero, on receipt of the CAN message the timer for the timeout monitoring is automatically started. Setting this flag prevents the automatic start timer.
- RX_READ
- read properties of RX content filter subscription
- RX_
RTR_ FRAME - the filter passed is used as CAN message to be sent when receiving an RTR frame.
- RX_
SETUP - create RX content filter subscription
- RX_
STATUS - reply to RX_READ request
- RX_
TIMEOUT - cyclic message is absent
- SETTIMER
- Flags
- SOCK_
DGRAM - datagram (connection less) socket
- STARTTIMER
- start the timer with the actual value of ival1, ival2 and count. Starting the timer leads simultaneously to emit a can_frame.
- TX_
ANNOUNCE - A change of data by the process is emitted immediatly. (Requirement of ‘Changing Now’ - BAES)
- TX_
COUNTEVT - create the message TX_EXPIRED when count expires
- TX_
CP_ CAN_ ID - Copies the can_id from the message header to each subsequent frame in frames. This is intended only as usage simplification.
- TX_
DELETE - remove (cyclic) transmission task
- TX_
EXPIRED - notification on performed transmissions (count=0)
- TX_READ
- read properties of (cyclic) transmission task
- TX_
RESET_ MULTI_ ID - forces a reset of the index counter from the update to be sent by multiplex message even if it would not be necessary because of the length.
- TX_SEND
- send one CAN frame
- TX_
SETUP - OpCodes
- TX_
STATUS - reply to TX_READ request