Just a small test for frames and serial (RS232) communication, with ideas from http://eli.thegreenplace.net/2009/08/20/frames-and-protocols-for-the-serial-port-in-python/

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers parser.h Source File

parser.h

00001 /*
00002  *
00003  */
00004 
00005 #ifndef _PARSER_H_
00006 #define _PARSER_H_
00007 
00008 #include "string"
00009 #include "list"
00010 
00011 #define WRAP_SEND   1
00012 #define WRAP_ABORT  2
00013 #define WRAP_FINISHED  3
00014 
00015 #define HEADER_CHAR 'A'
00016 #define FOOTER_CHAR 'B'
00017 #define DLE_CHAR '+'
00018 
00019 void unwrap_protocol(char *, string *buffer, list<string> *messages,
00020                      unsigned int max_message_size = 255, unsigned int max_message = 5,
00021                      char header=HEADER_CHAR, char footer=FOOTER_CHAR, char dle=DLE_CHAR);
00022 
00023 
00024 int wrap_protocol(char *c, string *buffer, list<string> *messages,
00025                    char header=HEADER_CHAR, char footer=FOOTER_CHAR, char dle=DLE_CHAR);
00026 
00027 
00028 // these have to be declared somewhere else for consistency
00029 extern DigitalOut message_led;
00030 
00031 
00032 #endif