ASCII parser library for CAN-Ethernet-Gateway V2
1.0
|
Parser for ASCII CAN messages. More...
Data Structures | |
struct | AsciiCanFrame |
Functions | |
int | ParseAsciiFrame (const unsigned char *pszBuf_p, struct AsciiCanFrame *pFrame_p, const unsigned char **ppEndBuf_p) |
Parses the string pointed to by pszBuf_p. More... | |
Parser for ASCII CAN messages.
int ParseAsciiFrame | ( | const unsigned char * | pszBuf_p, |
struct AsciiCanFrame * | pFrame_p, | ||
const unsigned char ** | ppEndBuf_p | ||
) |
Parses the string pointed to by pszBuf_p.
pszBuf_p | pointer to string which is parsed |
pFrame_p | pointer to can frame which is filled with parsed data |
ppEndBuf_p | pointer to byte after parsed data |
0 | if successful |
1 | ppEndBuf_p is NULL |
2 | pszBuf_p is NULL |
3 | pFrame_p is NULL |
4 | the header '$CAN;' does not match |
5 | the CAN ID type is neither 'S' nor 'E' |
6 | ';' after CAN ID type is missing |
7 | the CAN data type is neither 'D' nor 'R' |
8 | ';' after CAN data type is missing |
9 | CAN ID could not be parsed |
10 | prefix '0x' for DLC is wrong |
11 | DLC number could not be parsed |
12 | DLC is greater than 8 |
13 | ';' after CAN ID is missing |
14 | CAN data could not be parsed |
15 | end character '#' is missing |
This function parsed the string pointed to by pszBuf_p. It expects the fixed ASCII format e.g.
$CAN;S;D;0x123;8;0x00;0x01;0x02;0x03;0x04;0x05;0x06;0x07;#
Any whitespaces before this string are skipped. In case of an error the pointer passed per ppEndBuf_p is set to the next character after the error was detected.