SensorDataParser library that supports Sensor Data Streamer binary packets and Sensor Monitor csv packets
SensorDataParser.h@0:145141a10e18, 2013-10-24 (annotated)
- Committer:
- screamer
- Date:
- Thu Oct 24 11:45:40 2013 +0000
- Revision:
- 0:145141a10e18
- Child:
- 1:e9d3bb2384a9
initial revision with support for Sensor Data Streamer (binary) and Sensor Monitor (csv)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:145141a10e18 | 1 | /* Copyright (c) 2010-2013 mbed.org, MIT License |
screamer | 0:145141a10e18 | 2 | * |
screamer | 0:145141a10e18 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
screamer | 0:145141a10e18 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
screamer | 0:145141a10e18 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
screamer | 0:145141a10e18 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
screamer | 0:145141a10e18 | 7 | * Software is furnished to do so, subject to the following conditions: |
screamer | 0:145141a10e18 | 8 | * |
screamer | 0:145141a10e18 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
screamer | 0:145141a10e18 | 10 | * substantial portions of the Software. |
screamer | 0:145141a10e18 | 11 | * |
screamer | 0:145141a10e18 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
screamer | 0:145141a10e18 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
screamer | 0:145141a10e18 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
screamer | 0:145141a10e18 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
screamer | 0:145141a10e18 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
screamer | 0:145141a10e18 | 17 | */ |
screamer | 0:145141a10e18 | 18 | |
screamer | 0:145141a10e18 | 19 | /** |
screamer | 0:145141a10e18 | 20 | * Maximum number of processed CSV values |
screamer | 0:145141a10e18 | 21 | */ |
screamer | 0:145141a10e18 | 22 | #define MAX_CSV_VALS 40 |
screamer | 0:145141a10e18 | 23 | |
screamer | 0:145141a10e18 | 24 | /** |
screamer | 0:145141a10e18 | 25 | * Processed data by parse_sensor_packet() |
screamer | 0:145141a10e18 | 26 | */ |
screamer | 0:145141a10e18 | 27 | typedef struct { |
screamer | 0:145141a10e18 | 28 | float ax; /**< Accelerometer X coordinate */ |
screamer | 0:145141a10e18 | 29 | float ay; /**< Accelerometer Y coordinate */ |
screamer | 0:145141a10e18 | 30 | float az; /**< Accelerometer Z coordinate */ |
screamer | 0:145141a10e18 | 31 | |
screamer | 0:145141a10e18 | 32 | float gx; /**< Gyroscope X coordinate */ |
screamer | 0:145141a10e18 | 33 | float gy; /**< Gyroscope Y coordinate */ |
screamer | 0:145141a10e18 | 34 | float gz; /**< Gyroscope Z coordinate */ |
screamer | 0:145141a10e18 | 35 | |
screamer | 0:145141a10e18 | 36 | double tx; /**< Teslameter X coordinate */ |
screamer | 0:145141a10e18 | 37 | double ty; /**< Teslameter Y coordinate */ |
screamer | 0:145141a10e18 | 38 | double tz; /**< Teslameter Z coordinate */ |
screamer | 0:145141a10e18 | 39 | |
screamer | 0:145141a10e18 | 40 | double hm; /**< Magnetic heading */ |
screamer | 0:145141a10e18 | 41 | double ht; /**< True heading */ |
screamer | 0:145141a10e18 | 42 | |
screamer | 0:145141a10e18 | 43 | double latitude; /**< Latitude */ |
screamer | 0:145141a10e18 | 44 | double longitude; /**< Longitude */ |
screamer | 0:145141a10e18 | 45 | double altitude; /**< Altitude */ |
screamer | 0:145141a10e18 | 46 | |
screamer | 0:145141a10e18 | 47 | int proximity; /**< Proximity sensor */ |
screamer | 0:145141a10e18 | 48 | |
screamer | 0:145141a10e18 | 49 | int touch1; /**< Touch point 1 present */ |
screamer | 0:145141a10e18 | 50 | int touch1x; /**< Touch point 1 X coordinate */ |
screamer | 0:145141a10e18 | 51 | int touch1y; /**< Touch point 1 Y coordinate */ |
screamer | 0:145141a10e18 | 52 | |
screamer | 0:145141a10e18 | 53 | int touch2; /**< Touch point 1 present */ |
screamer | 0:145141a10e18 | 54 | int touch2x; /**< Touch point 1 X coordinate */ |
screamer | 0:145141a10e18 | 55 | int touch2y; /**< Touch point 1 Y coordinate */ |
screamer | 0:145141a10e18 | 56 | } SENSOR_DATA; |
screamer | 0:145141a10e18 | 57 | |
screamer | 0:145141a10e18 | 58 | /** |
screamer | 0:145141a10e18 | 59 | * Parses a packaet that contains sensor data. |
screamer | 0:145141a10e18 | 60 | * Currently supported packet formats: |
screamer | 0:145141a10e18 | 61 | * - Sensor Data Streamer (binary) |
screamer | 0:145141a10e18 | 62 | * - Sensor Monitor (csv) |
screamer | 0:145141a10e18 | 63 | * |
screamer | 0:145141a10e18 | 64 | * @param buf The packet contents |
screamer | 0:145141a10e18 | 65 | * @param pd processed data |
screamer | 0:145141a10e18 | 66 | * |
screamer | 0:145141a10e18 | 67 | * @return 0 - Invalid packet type |
screamer | 0:145141a10e18 | 68 | * @return 1 - Sensor Data Streamer packet |
screamer | 0:145141a10e18 | 69 | * @return 2 - Sensor Monitor packet |
screamer | 0:145141a10e18 | 70 | */ |
screamer | 0:145141a10e18 | 71 | int parse_sensor_packet(char *buf, SENSOR_DATA *pd); |