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/
Diff: parser.h
- Revision:
- 0:566fc5f530fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parser.h Wed May 02 06:01:00 2012 +0000 @@ -0,0 +1,32 @@ +/* + * + */ + +#ifndef _PARSER_H_ +#define _PARSER_H_ + +#include "string" +#include "list" + +#define WRAP_SEND 1 +#define WRAP_ABORT 2 +#define WRAP_FINISHED 3 + +#define HEADER_CHAR 'A' +#define FOOTER_CHAR 'B' +#define DLE_CHAR '+' + +void unwrap_protocol(char *, string *buffer, list<string> *messages, + unsigned int max_message_size = 255, unsigned int max_message = 5, + char header=HEADER_CHAR, char footer=FOOTER_CHAR, char dle=DLE_CHAR); + + +int wrap_protocol(char *c, string *buffer, list<string> *messages, + char header=HEADER_CHAR, char footer=FOOTER_CHAR, char dle=DLE_CHAR); + + +// these have to be declared somewhere else for consistency +extern DigitalOut message_led; + + +#endif