VLCB SDK
An opinionated SDK for VLCB protocol
|
Go to the source code of this file.
Typedefs | |
typedef uint16_t | VlcbCanFrameId |
CAN frame id used in transmission. | |
Functions | |
VlcbNetAdptErr | vlcb_net_adpt_ParseRawCanData (VlcbCanFrameId id, bool is_rtr, uint8_t payload_len, const VlcbNetAdptPayload *const payload, VlcbNetAdptPkt *const packet) |
Parse the CAN packet data into the inner format. | |
int | vlcb_net_adpt_NewCanFrameIdFromPkt (const VlcbNetAdptPkt *const packet, VlcbCanFrameId *const id) |
Construct new CAN frame ID from a packet. | |
bool | vlcb_net_adpt_IsCanAdptPktValid (const VlcbNetAdptPkt *const packet) |
Check if the packed passed in is correctly constructed. | |
typedef uint16_t VlcbCanFrameId |
CAN frame id used in transmission.
This type is used to store the CAN ID (11 bits wide). First 7 bits contain the VlcbCanId (node alias used on CAN bus). Rest of the bits contain the VlcbCanPriority (CAN bus priority used to prioritize some OPCODEs over others).
Definition at line 16 of file packet_parse.h.
bool vlcb_net_adpt_IsCanAdptPktValid | ( | const VlcbNetAdptPkt *const | packet | ) |
Check if the packed passed in is correctly constructed.
Valiates the packet to check if it is a valid packet targeted for the CAN bus.
[in] | packet | The packet to be validated |
true | The packet is valid |
false | The packet is invalid |
|
inline |
Construct new CAN frame ID from a packet.
This method is useful when constructing outbound packets, provides minimal validation to the packet and maps certain values, like priority, based on the OPCODE.
It is worthy to note that unknown priority values get alias to the default one.
[in] | packet | The device packet we're about to send out |
[out] | id | The variable to store the constructed frame id |
0 | The id is valid |
1 | The id is invalid |
Definition at line 52 of file packet_parse.c.
|
inline |
Parse the CAN packet data into the inner format.
This function validates and constructs a new VlcbNetAdptPacket from raw data and flags passed in from the device deriver adapter. Device driver adapters should use this function instead of their own implementation, unless it's desirable.
It is worthy to note that unknown priority values get aliased to the default one.
[in] | id | The raw value of CAN ID (11 bits, does not have to be masked) |
[in] | is_rtr | Whether the received CAN frame had RTR flag set |
[in] | payload_len | Length of the received payload. [0, 8] |
[in] | payload | The payload buffer containing data from received CAN frame |
[out] | packet | Destination memory space for the constructed packets |
Definition at line 9 of file packet_parse.c.