VLCB SDK
An opinionated SDK for VLCB protocol
|
#include "vlcb/net/adapter/can/packet_parse.h"
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "vlcb/platform/log.h"
Go to the source code of this file.
Functions | |
VlcbNetAdptErr | vlcb_net_adpt_ParseRawCanData (const VlcbCanFrameId id, const bool is_rtr, const 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_IsPacketValid (const VlcbNetAdptPkt *const packet) |
bool vlcb_net_adpt_IsPacketValid | ( | const VlcbNetAdptPkt *const | packet | ) |
Valid packet needs to have: CAN medium flag Payload must be smaller or equal to the MTU of the CAN device Payload must have size 0 if rtr flag is set CAN ID of this device must be in a valid range CAN Priority must be in range of known values
Definition at line 71 of file packet_parse.c.
|
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.