CANDEV
Generic CAN device structure
Synopsis:
#include <hw/libcan.h>
#include <sys/can_dcmd.h>
#include <sys/iofunc.h>
#include <sys/siginfo.h>
typedef struct can_dev_entry
{
iofunc_attr_t attr;
iofunc_mount_t mount;
CANDEV_TYPE devtype;
int can_unit;
int dev_unit;
CANDEV_MODE mode;
canmsg_list_t *free_queue;
canmsg_list_t *msg_queue;
int rsmid;
uint32_t cflags;
struct sigevent event;
CLIENTWAITQ *wait_free_queue;
CLIENTWAITQ *wait_client_queue;
} CANDEV;Description:
The CANDEV structure represents an initialized CAN device. The CAN resource manager uses this information to facilitate communication with clients.
The members include:
- attr
The data and state associated with the individual CAN service offered by the CAN resource manager.
- mount
Data managed by libcan.
- devtype
The CAN device type; CANDEV_TYPE_RX (receiver) or CANDEV_TYPE_TX (transmitter).
- can_unit
The CAN unit number. Corresponds to the X in the /dev/canX/rxY path.
- dev_unit
The device unit number. Corresponds to the Y in the /dev/canX/rxY path.
- mode
The CAN driver mode; CANDEV_MODE_IO (I/O) or CANDEV_MODE_RAW_FRAME (raw frames).
- free_queue
The free element queue; a pointer to the
canmsg_list_tinstance.- msg_queue
The active TX or RX queue; a pointer to the
canmsg_list_tinstance. When transmitting, dequeue messages from this queue. When receiving, add messages to this queue.- rsmid
The resource manager link ID.
- cflags
CAN device flags. Setting bit 31 to:
- event
Data that libcan manages.
- wait_free_queue
Free elements in the client wait queue; a pointer to the
CLIENTWAITQinstance.- wait_client_queue
Queue of blocked clients waiting for a response from the driver; a pointer to the
CLIENTWAITQinstance.
The only member that should be directly modified by the implementation is cflags to control the read/write message size; specify 8 bytes for standard CAN and 64 bytes for CAN FD.
The free_queue and msg_queue instances must be manipulated using the cansmsg_dequeue_element() and canmsg_queue_element() functions when receiving and transmitting CAN messages.
The devtype, mode, can_unit, and dev_unit members are copied from the CANDEV_INIT instance passed to the can_resmgr_init_device() function and shouldn't be modified.
All other members are initialized and managed by libcan and must not be modified by the implementation.
