Lely core libraries
2.3.4
|
Go to the source code of this file.
Data Structures | |
struct | can_msg |
A CAN or CAN FD format frame. More... | |
Macros | |
#define | CAN_MASK_BID UINT32_C(0x000007ff) |
The mask used to extract the 11-bit Base Identifier from a CAN frame. | |
#define | CAN_MASK_EID UINT32_C(0x1fffffff) |
The mask used to extract the 29-bit Extended Identifier from a CAN frame. | |
#define | CAN_MAX_LEN 8 |
The maximum number of bytes in the payload of a CAN format frame. | |
#define | CANFD_MAX_LEN 64 |
The maximum number of bytes in the payload of a CAN FD format frame. | |
#define | CAN_MSG_MAX_LEN CANFD_MAX_LEN |
The maximum number of bytes in the payload of a can_msg struct. | |
#define | CAN_MSG_INIT |
The static initializer for can_msg. | |
Enumerations | |
enum | { CAN_FLAG_IDE = 1u << 0, CAN_FLAG_RTR = 1u << 1, CAN_FLAG_FDF = 1u << 2 , CAN_FLAG_BRS = 1u << 3, CAN_FLAG_ESI = 1u << 4 } |
The flags of a CAN or CAN FD format frame. More... | |
enum | can_msg_bits_mode { CAN_MSG_BITS_MODE_NO_STUFF, CAN_MSG_BITS_MODE_WORST, CAN_MSG_BITS_MODE_EXACT } |
The method used to compute te size (in bits) of a CAN frame. More... | |
Functions | |
int | can_msg_bits (const struct can_msg *msg, enum can_msg_bits_mode mode) |
Computes the size (in bits) of the specified CAN format frame on the CAN bus. More... | |
int | snprintf_can_msg (char *s, size_t n, const struct can_msg *msg) |
Prints the contents of a CAN or CAN FD format frame to a string buffer. More... | |
int | asprintf_can_msg (char **ps, const struct can_msg *msg) |
Equivalent to snprintf_can_msg(), except that it allocates a string large enough to hold the output, including the terminating null byte. More... | |
uint_least16_t | can_crc (uint_least16_t crc, const void *ptr, int off, size_t bits) |
Computes a bitwise CRC-15-CAN checksum, based on the 0x4599 generator polynomial. More... | |
This header file is part of the CAN library; it contains the CAN frame declarations.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file msg.h.
anonymous enum |
The flags of a CAN or CAN FD format frame.
enum can_msg_bits_mode |
int can_msg_bits | ( | const struct can_msg * | msg, |
enum can_msg_bits_mode | mode | ||
) |
Computes the size (in bits) of the specified CAN format frame on the CAN bus.
msg | a pointer to a CAN frame format frame. |
mode | the method used to compute the size (one of CAN_MSG_BITS_MODE_NO_STUFF, CAN_MSG_BITS_MODE_WORST or CAN_MSG_BITS_MODE_EXACT). |
int snprintf_can_msg | ( | char * | s, |
size_t | n, | ||
const struct can_msg * | msg | ||
) |
Prints the contents of a CAN or CAN FD format frame to a string buffer.
The output mimics that of candump.
s | the address of the output buffer. If s is not NULL, at most n - 1 characters are written, plus a terminating null byte. |
n | the size (in bytes) of the buffer at s. If n is zero, nothing is written. |
msg | a pointer to the CAN frame to be printed. |
errno
. int asprintf_can_msg | ( | char ** | ps, |
const struct can_msg * | msg | ||
) |
Equivalent to snprintf_can_msg(), except that it allocates a string large enough to hold the output, including the terminating null byte.
ps | the address of a value which, on success, contains a pointer to the allocated string. This pointer SHOULD be passed to free() to release the allocated storage. |
msg | a pointer to the CAN frame to be printed. |
errno
. uint_least16_t can_crc | ( | uint_least16_t | crc, |
const void * | ptr, | ||
int | off, | ||
size_t | bits | ||
) |
Computes a bitwise CRC-15-CAN checksum, based on the 0x4599 generator polynomial.
The implementation uses a table with precomputed values for efficiency.
crc | the initial value. |
ptr | a pointer to the bits to be hashed. |
off | the offset (in bits) with respect to ptr of the first bit to be hashed. |
bits | the number of bits to hash. |