rikbeuncode

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 13:34:37 2015 +0200
Parent:
14:155f9a55ec51
Child:
16:4bdcdac223d8
Commit message:
Make the MtData2_getItem function use XbusMessage struct

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
xbus/mtdata2.c Show annotated file Show diff for this revision Revisions of this file
xbus/mtdata2.h Show annotated file Show diff for this revision Revisions of this file
xbus/xbusmessage.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue May 19 13:29:34 2015 +0200
+++ b/main.cpp	Tue May 19 13:34:37 2015 +0200
@@ -56,22 +56,22 @@
 
 static void mtDataHandler(struct XbusMessage const* message)
 {
-	if (message->mid == MTDATA2_MESSAGE_ID)
+	if (message->mid == XMID_MtData2)
 	{
 		pc.printf("MTData2:");
 		uint16_t counter;
-		if (MtData2_getItem(&counter, XDI_PacketCounter, message->data, message->length))
+		if (MtData2_getItem(&counter, XDI_PacketCounter, message))
 		{
 			pc.printf(" Packet counter: %5d", counter);
 		}
 		float ori[4];
-		if (MtData2_getItem(ori, XDI_Quaternion, message->data, message->length))
+		if (MtData2_getItem(ori, XDI_Quaternion, message))
 		{
 			pc.printf(" Orientation: (% .3f, % .3f, % .3f, % .3f)", ori[0], ori[1],
 					ori[2], ori[3]);
 		}
 		uint32_t status;
-		if (MtData2_getItem(&status, XDI_StatusWord, message->data, message->length))
+		if (MtData2_getItem(&status, XDI_StatusWord, message))
 		{
 			pc.printf(" Status:%X", status);
 		}
--- a/xbus/mtdata2.c	Tue May 19 13:29:34 2015 +0200
+++ b/xbus/mtdata2.c	Tue May 19 13:34:37 2015 +0200
@@ -51,9 +51,9 @@
 	}
 }
 
-bool MtData2_getItem(void* item, enum XsDataIdentifier id, uint8_t const* data, uint16_t dataLength)
+bool MtData2_getItem(void* item, enum XsDataIdentifier id, struct XbusMessage const* message)
 {
-	uint8_t const* raw = getPointerToData(id, data, dataLength);
+	uint8_t const* raw = getPointerToData(id, message->data, message->length);
 	if (raw)
 	{
 		switch (id)
--- a/xbus/mtdata2.h	Tue May 19 13:29:34 2015 +0200
+++ b/xbus/mtdata2.h	Tue May 19 13:34:37 2015 +0200
@@ -18,9 +18,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-
-/*! \brief Xbus message ID for MTData2 packets. */
-#define MTDATA2_MESSAGE_ID (0x36)
+#include "xbusmessage.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -39,7 +37,7 @@
 	XDI_StatusWord     = 0xE020,
 };
 
-bool MtData2_getItem(void* item, enum XsDataIdentifier id, uint8_t const* data, uint16_t dataLength);
+bool MtData2_getItem(void* item, enum XsDataIdentifier id, struct XbusMessage const* message);
 
 #ifdef __cplusplus
 }
--- a/xbus/xbusmessage.h	Tue May 19 13:29:34 2015 +0200
+++ b/xbus/xbusmessage.h	Tue May 19 13:34:37 2015 +0200
@@ -29,6 +29,7 @@
 	XMID_GotoConfigAck      = 0x31,
 	XMID_GotoMeasurement    = 0x10,
 	XMID_GotoMeasurementAck = 0x11,
+	XMID_MtData2            = 0x36
 };
 
 struct XbusMessage