Zephyr API 3.6.99
Loading...
Searching...
No Matches
SocketCAN library

SocketCAN library . More...

Data Structures

struct  sockaddr_can
 struct sockaddr_can - The sockaddr structure for CAN sockets More...
 
struct  socketcan_frame
 CAN frame for Linux SocketCAN compatibility. More...
 
struct  socketcan_filter
 CAN filter for Linux SocketCAN compatibility. More...
 

Macros

#define CAN_RAW   1
 Protocols of the protocol family PF_CAN.
 
#define SOCKETCAN_MAX_DLEN   8U
 SocketCAN max data length.
 
#define CAN_MTU   (sizeof(struct socketcan_frame))
 CAN frame MTU.
 
#define CANFD_BRS   0x01
 Bit rate switch (second bitrate for payload data)
 
#define CANFD_ESI   0x02
 Error state indicator of the transmitting node.
 
#define CANFD_FDF   0x04
 Mark CAN FD for dual use of struct canfd_frame.
 

Functions

static void socketcan_to_can_frame (const struct socketcan_frame *sframe, struct can_frame *zframe)
 Translate a socketcan_frame struct to a can_frame struct.
 
static void socketcan_from_can_frame (const struct can_frame *zframe, struct socketcan_frame *sframe)
 Translate a can_frame struct to a socketcan_frame struct.
 
static void socketcan_to_can_filter (const struct socketcan_filter *sfilter, struct can_filter *zfilter)
 Translate a socketcan_filter struct to a can_filter struct.
 
static void socketcan_from_can_filter (const struct can_filter *zfilter, struct socketcan_filter *sfilter)
 Translate a can_filter struct to a socketcan_filter struct.
 

Linux SocketCAN compatibility

The following structures and functions provide compatibility with the CAN frame and CAN filter formats used by Linux SocketCAN.

typedef uint32_t socketcan_id_t
 CAN Identifier structure for Linux SocketCAN compatibility.
 

Detailed Description

SocketCAN library .

SocketCAN utilities .

Since
1.14
Version
0.8.0

Macro Definition Documentation

◆ CAN_MTU

#define CAN_MTU   (sizeof(struct socketcan_frame))

#include <zephyr/net/socketcan.h>

CAN frame MTU.

◆ CAN_RAW

#define CAN_RAW   1

#include <zephyr/net/socketcan.h>

Protocols of the protocol family PF_CAN.

◆ CANFD_BRS

#define CANFD_BRS   0x01

#include <zephyr/net/socketcan.h>

Bit rate switch (second bitrate for payload data)

◆ CANFD_ESI

#define CANFD_ESI   0x02

#include <zephyr/net/socketcan.h>

Error state indicator of the transmitting node.

◆ CANFD_FDF

#define CANFD_FDF   0x04

#include <zephyr/net/socketcan.h>

Mark CAN FD for dual use of struct canfd_frame.

◆ SOCKETCAN_MAX_DLEN

#define SOCKETCAN_MAX_DLEN   8U

#include <zephyr/net/socketcan.h>

SocketCAN max data length.

Typedef Documentation

◆ socketcan_id_t

#include <zephyr/net/socketcan.h>

CAN Identifier structure for Linux SocketCAN compatibility.

The fields in this type are:

+------+--------------------------------------------------------------+
| Bits | Description |
+======+==============================================================+
| 0-28 | CAN identifier (11/29 bit) |
+------+--------------------------------------------------------------+
| 29 | Error message frame flag (0 = data frame, 1 = error message) |
+------+--------------------------------------------------------------+
| 30 | Remote transmission request flag (1 = RTR frame) |
+------+--------------------------------------------------------------+
| 31 | Frame format flag (0 = standard 11 bit, 1 = extended 29 bit) |
+------+--------------------------------------------------------------+

Function Documentation

◆ socketcan_from_can_filter()

static void socketcan_from_can_filter ( const struct can_filter * zfilter,
struct socketcan_filter * sfilter )
inlinestatic

#include <zephyr/net/socketcan_utils.h>

Translate a can_filter struct to a socketcan_filter struct.

Parameters
zfilterPointer to can_filter struct.
sfilterPointer to socketcan_filter struct.

◆ socketcan_from_can_frame()

static void socketcan_from_can_frame ( const struct can_frame * zframe,
struct socketcan_frame * sframe )
inlinestatic

#include <zephyr/net/socketcan_utils.h>

Translate a can_frame struct to a socketcan_frame struct.

Parameters
zframePointer to can_frame struct.
sframePointer to socketcan_frame struct.

< Mark CAN FD for dual use of struct canfd_frame

< Bit rate switch (second bitrate for payload data)

◆ socketcan_to_can_filter()

static void socketcan_to_can_filter ( const struct socketcan_filter * sfilter,
struct can_filter * zfilter )
inlinestatic

#include <zephyr/net/socketcan_utils.h>

Translate a socketcan_filter struct to a can_filter struct.

Parameters
sfilterPointer to socketcan_filter struct.
zfilterPointer to can_filter struct.

◆ socketcan_to_can_frame()

static void socketcan_to_can_frame ( const struct socketcan_frame * sframe,
struct can_frame * zframe )
inlinestatic

#include <zephyr/net/socketcan_utils.h>

Translate a socketcan_frame struct to a can_frame struct.

Parameters
sframePointer to sockecan_frame struct.
zframePointer to can_frame struct.

< Mark CAN FD for dual use of struct canfd_frame

< Bit rate switch (second bitrate for payload data)