From 746c8189169bb444e90a6a5db9b911b1a2022b2b Mon Sep 17 00:00:00 2001 From: Elias Hawa Date: Wed, 15 May 2024 10:03:49 -0400 Subject: [PATCH 1/3] Add linear acceleration and angular velocity --- src/main.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index ac8f297..3d513b4 100644 --- a/src/main.c +++ b/src/main.c @@ -15,12 +15,20 @@ typedef enum { DTYPE_HUMIDITY = 3, /**< Humidity */ DTYPE_ALTITUDE = 4, /**< Altitude */ DTYPE_DNE = 5, /**< Data type does not exist */ + DTYPE_ACCELERATON = 6, /**< Linear acceleration*/ + DTYPE_VELOCITY = 7, /**< Angular velocity*/ } Dtype; /** String representation of the possible data types. */ const char *DTYPES[] = { - [DTYPE_TEMPERATURE] = "Temperature", [DTYPE_TIME] = "Time", [DTYPE_PRESSURE] = "Pressure", [DTYPE_DNE] = "", - [DTYPE_ALTITUDE] = "Altitude", [DTYPE_HUMIDITY] = "Humidity", + [DTYPE_TEMPERATURE] = "Temperature", + [DTYPE_TIME] = "Time", + [DTYPE_PRESSURE] = "Pressure", + [DTYPE_DNE] = "", + [DTYPE_ALTITUDE] = "Altitude", + [DTYPE_HUMIDITY] = "Humidity", + [DTYPE_ACCELERATON] = "Linear acceleration", + [DTYPE_VELOCITY] = "Angular velocity", }; /** The size of the buffer for reading sensor data input. */ @@ -158,6 +166,28 @@ int main(int argc, char **argv) { altitude_db_init((AltitudeDB *)packet_pos, last_time, 1000 * strtod(strtok(NULL, ":"), NULL)); break; + case DTYPE_ACCELERATON: + // if (!room_for_block(sizeof(AccelerationDB))) { + // continue; + // } + just_added_block_size = sizeof(AccelerationDB); + add_block_header(DATA_ACCEL, just_added_block_size); + acceleration_db_init((AccelerationDB *)packet_pos, last_time, strtod(strtok(NULL, ","), NULL) / 100, + strtod(strtok(NULL, ","), NULL) / 100, strtod(strtok(NULL, ","), NULL) / 100); + break; + + case DTYPE_VELOCITY: + // if (!room_for_block(sizeof(AngularVelocityDB))) { + // continue; + // } + just_added_block_size = sizeof(AngularVelocityDB); + add_block_header(DATA_ANGULAR_VEL, just_added_block_size); + angular_velocity_db_init((AngularVelocityDB *)packet_pos, last_time, + strtod(strtok(NULL, ","), NULL) / 10, strtod(strtok(NULL, ","), NULL) / 10, + strtod(strtok(NULL, ","), NULL) / 10); + printf("done\n"); + break; + default: fprintf(stderr, "Unknown input data type: %s\n", dtype_str); continue; // Skip to next iteration without storing block From c39da7c69e059b4fbd0a6c743bccaaa710dca1a7 Mon Sep 17 00:00:00 2001 From: Elias Hawa Date: Wed, 15 May 2024 10:06:06 -0400 Subject: [PATCH 2/3] Remove print --- src/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.c b/src/main.c index 3d513b4..b3d247d 100644 --- a/src/main.c +++ b/src/main.c @@ -185,7 +185,6 @@ int main(int argc, char **argv) { angular_velocity_db_init((AngularVelocityDB *)packet_pos, last_time, strtod(strtok(NULL, ","), NULL) / 10, strtod(strtok(NULL, ","), NULL) / 10, strtod(strtok(NULL, ","), NULL) / 10); - printf("done\n"); break; default: From c8243f9d169907ab9391e947d769847fa802a715 Mon Sep 17 00:00:00 2001 From: Elias Hawa Date: Wed, 15 May 2024 22:23:07 -0400 Subject: [PATCH 3/3] Fix encoding --- src/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index b3d247d..0262cd1 100644 --- a/src/main.c +++ b/src/main.c @@ -167,24 +167,18 @@ int main(int argc, char **argv) { break; case DTYPE_ACCELERATON: - // if (!room_for_block(sizeof(AccelerationDB))) { - // continue; - // } just_added_block_size = sizeof(AccelerationDB); add_block_header(DATA_ACCEL, just_added_block_size); - acceleration_db_init((AccelerationDB *)packet_pos, last_time, strtod(strtok(NULL, ","), NULL) / 100, - strtod(strtok(NULL, ","), NULL) / 100, strtod(strtok(NULL, ","), NULL) / 100); + acceleration_db_init((AccelerationDB *)packet_pos, last_time, strtod(strtok(NULL, ","), NULL) * 100, + strtod(strtok(NULL, ","), NULL) * 100, strtod(strtok(NULL, ","), NULL) * 100); break; case DTYPE_VELOCITY: - // if (!room_for_block(sizeof(AngularVelocityDB))) { - // continue; - // } just_added_block_size = sizeof(AngularVelocityDB); add_block_header(DATA_ANGULAR_VEL, just_added_block_size); angular_velocity_db_init((AngularVelocityDB *)packet_pos, last_time, - strtod(strtok(NULL, ","), NULL) / 10, strtod(strtok(NULL, ","), NULL) / 10, - strtod(strtok(NULL, ","), NULL) / 10); + strtod(strtok(NULL, ","), NULL) * 10, strtod(strtok(NULL, ","), NULL) * 10, + strtod(strtok(NULL, ","), NULL) * 10); break; default: