SensorDataParser library that supports Sensor Data Streamer binary packets and Sensor Monitor csv packets
Diff: SensorDataParser.h
- Revision:
- 0:145141a10e18
- Child:
- 1:e9d3bb2384a9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SensorDataParser.h Thu Oct 24 11:45:40 2013 +0000 @@ -0,0 +1,71 @@ +/* Copyright (c) 2010-2013 mbed.org, MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + * Maximum number of processed CSV values + */ +#define MAX_CSV_VALS 40 + +/** + * Processed data by parse_sensor_packet() + */ +typedef struct { + float ax; /**< Accelerometer X coordinate */ + float ay; /**< Accelerometer Y coordinate */ + float az; /**< Accelerometer Z coordinate */ + + float gx; /**< Gyroscope X coordinate */ + float gy; /**< Gyroscope Y coordinate */ + float gz; /**< Gyroscope Z coordinate */ + + double tx; /**< Teslameter X coordinate */ + double ty; /**< Teslameter Y coordinate */ + double tz; /**< Teslameter Z coordinate */ + + double hm; /**< Magnetic heading */ + double ht; /**< True heading */ + + double latitude; /**< Latitude */ + double longitude; /**< Longitude */ + double altitude; /**< Altitude */ + + int proximity; /**< Proximity sensor */ + + int touch1; /**< Touch point 1 present */ + int touch1x; /**< Touch point 1 X coordinate */ + int touch1y; /**< Touch point 1 Y coordinate */ + + int touch2; /**< Touch point 1 present */ + int touch2x; /**< Touch point 1 X coordinate */ + int touch2y; /**< Touch point 1 Y coordinate */ +} SENSOR_DATA; + +/** + * Parses a packaet that contains sensor data. + * Currently supported packet formats: + * - Sensor Data Streamer (binary) + * - Sensor Monitor (csv) + * + * @param buf The packet contents + * @param pd processed data + * + * @return 0 - Invalid packet type + * @return 1 - Sensor Data Streamer packet + * @return 2 - Sensor Monitor packet + */ +int parse_sensor_packet(char *buf, SENSOR_DATA *pd);