ASCII parser library for CAN-Ethernet-Gateway V2  1.0
Data Structures | Functions
asciiparse.h File Reference

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...
 

Detailed Description

Parser for ASCII CAN messages.

Author
A. Stein

Function Documentation

int ParseAsciiFrame ( const unsigned char *  pszBuf_p,
struct AsciiCanFrame pFrame_p,
const unsigned char **  ppEndBuf_p 
)

Parses the string pointed to by pszBuf_p.

Parameters
pszBuf_ppointer to string which is parsed
pFrame_ppointer to can frame which is filled with parsed data
ppEndBuf_ppointer to byte after parsed data
Return values
0if successful
1ppEndBuf_p is NULL
2pszBuf_p is NULL
3pFrame_p is NULL
4the header '$CAN;' does not match
5the CAN ID type is neither 'S' nor 'E'
6';' after CAN ID type is missing
7the CAN data type is neither 'D' nor 'R'
8';' after CAN data type is missing
9CAN ID could not be parsed
10prefix '0x' for DLC is wrong
11DLC number could not be parsed
12DLC is greater than 8
13';' after CAN ID is missing
14CAN data could not be parsed
15end 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.