From e5da1bc769e6d010f13f2181988a7b271b8cb415 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:42:22 -0700 Subject: Use platform agnostic path --- motionMonitor/motionMonitor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 0af8728..d02c20d 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -19,8 +19,7 @@ double yAccImpact[N_CHANGE_BLOCKS]; double zAccImpact[N_CHANGE_BLOCKS]; uint64_t timestamps[N_CHANGE_BLOCKS]; -static const char FormatStr[] = - "/sys/devices/i2c-0/0-0068/iio:device0/in_%s_%s"; +static const char FormatStr[] = "/sys/bus/iio/devices/iio:device0/in_%s_%s"; static const char AccType[] = "accel"; static const char GyroType[] = "anglvel"; static const char CompX[] = "x_raw"; -- cgit v1.2.3 From e2a584ccb925e1f2657d2f9757ab0f5d657d8aba Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:45:24 -0700 Subject: Re-add path formatting --- motionMonitor/motionMonitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index d02c20d..3ded30e 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -45,23 +45,27 @@ le_result_t brnkl_motion_getCurrentAcceleration(double* xAcc, char path[256]; double scaling = 0.0; + snprintf(path, sizeof(path), FormatStr, AccType, CompScale); r = ioutil_readDoubleFromFile(path, &scaling); if (r != LE_OK) { goto done; } + snprintf(path, sizeof(path), FormatStr, AccType, CompX); r = ioutil_readDoubleFromFile(path, xAcc); if (r != LE_OK) { goto done; } *xAcc *= scaling; + snprintf(path, sizeof(path), FormatStr, AccType, CompY); r = ioutil_readDoubleFromFile(path, yAcc); if (r != LE_OK) { goto done; } *yAcc *= scaling; + snprintf(path, sizeof(path), FormatStr, AccType, CompZ); r = ioutil_readDoubleFromFile(path, zAcc); *zAcc *= scaling; -- cgit v1.2.3 From c13d4424489d0791ad54fed9cfc1dff06e4a2a11 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:46:49 -0700 Subject: Copy timestamps with impact vector --- motionMonitor/motionMonitor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 3ded30e..89786f8 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -94,7 +94,9 @@ le_result_t brnkl_motion_getSuddenImpact(double* xAcc, double* yAcc, size_t* ySize, double* zAcc, - size_t* zSize) { + size_t* zSize, + uint64_t* timestampssOut, + size_t* timeSize) { if (!totalImpacts) LE_INFO("No Sudden Impacts to Report"); else { @@ -108,6 +110,7 @@ le_result_t brnkl_motion_getSuddenImpact(double* xAcc, xAcc[i] = xAccImpact[i]; yAcc[i] = yAccImpact[i]; zAcc[i] = zAccImpact[i]; + timestampssOut[i] = timestamps[i]; } *xSize = *ySize = *zSize = totalImpacts; -- cgit v1.2.3 From 397cc2e1baeac8f0c0eb94ed665c537099fed283 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:48:01 -0700 Subject: Remove log in polling routine --- motionMonitor/motionMonitor.c | 1 - 1 file changed, 1 deletion(-) diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 89786f8..4ac6045 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -70,7 +70,6 @@ le_result_t brnkl_motion_getCurrentAcceleration(double* xAcc, *zAcc *= scaling; done: - LE_INFO("Showing accel X: %f Y: %f Z: %f ", *xAcc, *yAcc, *zAcc); return r; } -- cgit v1.2.3 From eac57a51c8b42d3174b40659f44c6a8352d6ef67 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:48:17 -0700 Subject: Fix size check --- motionMonitor/motionMonitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 4ac6045..2622ea6 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -102,7 +102,7 @@ le_result_t brnkl_motion_getSuddenImpact(double* xAcc, pthread_mutex_lock(&impactMutex); // check - if (totalImpacts < *xSize || totalImpacts < *ySize || totalImpacts < *zSize) + if (totalImpacts > *xSize || totalImpacts > *ySize || totalImpacts > *zSize) return LE_OUT_OF_RANGE; for (int i = 0; i < totalImpacts; i++) { -- cgit v1.2.3 From 7e57174dddf1b955590485fc431a33575669939b Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 24 Oct 2018 22:48:39 -0700 Subject: Add timestamps & wrap lines --- brnkl_motion.api | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/brnkl_motion.api b/brnkl_motion.api index fd7c9b5..ad4262a 100644 --- a/brnkl_motion.api +++ b/brnkl_motion.api @@ -1,5 +1,13 @@ DEFINE N_CHANGE_BLOCKS = 200; -FUNCTION le_result_t getSuddenImpact (double x [N_CHANGE_BLOCKS] OUT, double y [N_CHANGE_BLOCKS] OUT, double z [N_CHANGE_BLOCKS] OUT); -FUNCTION le_result_t getCurrentAcceleration (double x OUT, double y OUT, double z OUT); - \ No newline at end of file +FUNCTION le_result_t getSuddenImpact( + double x [N_CHANGE_BLOCKS] OUT, + double y [N_CHANGE_BLOCKS] OUT, + double z [N_CHANGE_BLOCKS] OUT, + uint64 timestamps[N_CHANGE_BLOCKS] OUT +); +FUNCTION le_result_t getCurrentAcceleration( + double x OUT, + double y OUT, + double z OUT +); -- cgit v1.2.3