Add LPC1768

Dependencies:   mbed-rtos mbed Xbus

Fork of MTi-1_example by Xsens

Files at this revision

API Documentation at this revision

Comitter:
Alex Young
Date:
Tue May 19 14:01:33 2015 +0200
Parent:
16:4bdcdac223d8
Child:
18:2073072bad51
Commit message:
Better handling of zero length messages

For a zero length message there is no data buffer allocated, so the
message data pointer should be NULL. When checking if the received
message is valid it should have a correct checksum and either zero
length or a valid data pointer.

Changed in this revision

xbus/xbusparser.c Show annotated file Show diff for this revision Revisions of this file
--- a/xbus/xbusparser.c	Tue May 19 13:40:33 2015 +0200
+++ b/xbus/xbusparser.c	Tue May 19 14:01:33 2015 +0200
@@ -101,6 +101,7 @@
 			if (byte == XBUS_NO_PAYLOAD)
 			{
 				parser->currentMessage.length = byte;
+				parser->currentMessage.data = NULL;
 				parser->state = XBPS_Checksum;
 			}
 			else if (byte < XBUS_EXTENDED_LENGTH)
@@ -142,7 +143,9 @@
 
 		case XBPS_Checksum:
 			parser->checksum += byte;
-			if ((parser->checksum == 0) && parser->currentMessage.data)
+			if ((parser->checksum == 0) &&
+					((parser->currentMessage.length == 0) ||
+					 parser->currentMessage.data))
 			{
 				parser->callbacks.handleMessage(&parser->currentMessage);
 			}