From 379075d29ce5710c9e97b4ec41772302b84a7035 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Mon, 25 May 2015 23:20:19 -0700 Subject: [PATCH 1/3] POSIX: Increased number of devmap entries The orb_advertise and/or orb_publish calls were failing because there were not enough devmap entries allocated for all the orb topics advertised. The number of entries was increased from 50 to 100. Signed-off-by: Mark Charlebois --- src/drivers/device/vdev.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/device/vdev.cpp b/src/drivers/device/vdev.cpp index 8ff8ae1fc8..3e3c02a939 100644 --- a/src/drivers/device/vdev.cpp +++ b/src/drivers/device/vdev.cpp @@ -64,7 +64,7 @@ private: px4_dev_t() {} }; -#define PX4_MAX_DEV 50 +#define PX4_MAX_DEV 100 static px4_dev_t *devmap[PX4_MAX_DEV]; /* From 79e084a154c3b4d945fb00d85fc2307667f9ae2f Mon Sep 17 00:00:00 2001 From: TSC21 Date: Tue, 26 May 2015 18:05:26 +0100 Subject: [PATCH 2/3] drivers: added validity check --- src/drivers/ll40ls/ll40ls.cpp | 2 ++ src/drivers/mb12xx/mb12xx.cpp | 4 ++++ src/drivers/trone/trone.cpp | 10 ++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/drivers/ll40ls/ll40ls.cpp b/src/drivers/ll40ls/ll40ls.cpp index 8984220625..d806638788 100644 --- a/src/drivers/ll40ls/ll40ls.cpp +++ b/src/drivers/ll40ls/ll40ls.cpp @@ -295,6 +295,8 @@ test(const bool use_i2c, const int bus) } warnx("periodic read %u", i); + warnx("valid %u", (float)report.current_distance > report.min_distance + && (float)report.current_distance < report.max_distance ? 1 : 0); warnx("measurement: %0.3f m", (double)report.current_distance); warnx("time: %lld", report.timestamp); } diff --git a/src/drivers/mb12xx/mb12xx.cpp b/src/drivers/mb12xx/mb12xx.cpp index afeb8e5545..ec07399f54 100644 --- a/src/drivers/mb12xx/mb12xx.cpp +++ b/src/drivers/mb12xx/mb12xx.cpp @@ -832,6 +832,7 @@ test() } warnx("single read"); + warnx("measurement: %0.2f m", (double)report.current_distance); warnx("time: %llu", report.timestamp); /* start the sensor polling at 2Hz */ @@ -860,6 +861,9 @@ test() } warnx("periodic read %u", i); + warnx("valid %u", (float)report.current_distance > report.min_distance + && (float)report.current_distance < report.max_distance ? 1 : 0); + warnx("measurement: %0.3f", (double)report.current_distance); warnx("time: %llu", report.timestamp); } diff --git a/src/drivers/trone/trone.cpp b/src/drivers/trone/trone.cpp index 23e52547a1..6150cc90e2 100644 --- a/src/drivers/trone/trone.cpp +++ b/src/drivers/trone/trone.cpp @@ -125,6 +125,7 @@ private: work_s _work; ringbuffer::RingBuffer *_reports; bool _sensor_ok; + uint8_t _valid; int _measure_ticks; bool _collect_phase; int _class_instance; @@ -211,7 +212,7 @@ static const uint8_t crc_table[] = { 0xfa, 0xfd, 0xf4, 0xf3 }; -/* static uint8_t crc8(uint8_t *p, uint8_t len) { + static uint8_t crc8(uint8_t *p, uint8_t len) { uint16_t i; uint16_t crc = 0x0; @@ -221,7 +222,7 @@ static const uint8_t crc_table[] = { } return crc & 0xFF; -}*/ +} /* * Driver 'main' command. @@ -234,6 +235,7 @@ TRONE::TRONE(int bus, int address) : _max_distance(TRONE_MAX_DISTANCE), _reports(nullptr), _sensor_ok(false), + _valid(0), _measure_ticks(0), _collect_phase(false), _class_instance(-1), @@ -586,6 +588,10 @@ TRONE::collect() /* TODO: set proper ID */ report.id = 0; + // This validation check can be used later + _valid = crc8(val, 2) == val[2] && (float)report.current_distance > report.min_distance + && (float)report.current_distance < report.max_distance ? 1 : 0; + /* publish it, if we are the primary */ if (_distance_sensor_topic >= 0) { orb_publish(ORB_ID(distance_sensor), _distance_sensor_topic, &report); From ff1f3ba7f1f8ca52a2e4cddac4d7436b8ccc8936 Mon Sep 17 00:00:00 2001 From: TSC21 Date: Tue, 26 May 2015 18:08:55 +0100 Subject: [PATCH 3/3] drivers: added validity check to sf0x --- src/drivers/sf0x/sf0x.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/drivers/sf0x/sf0x.cpp b/src/drivers/sf0x/sf0x.cpp index 431184d046..7861c0596b 100644 --- a/src/drivers/sf0x/sf0x.cpp +++ b/src/drivers/sf0x/sf0x.cpp @@ -854,7 +854,7 @@ test() } warnx("single read"); - warnx("val: %0.2f m", (double)report.current_distance); + warnx("measurement: %0.2f m", (double)report.current_distance); warnx("time: %llu", report.timestamp); /* start the sensor polling at 2 Hz rate */ @@ -885,7 +885,9 @@ test() } warnx("read #%u", i); - warnx("val: %0.3f m", (double)report.current_distance); + warnx("valid %u", (float)report.current_distance > report.min_distance + && (float)report.current_distance < report.max_distance ? 1 : 0); + warnx("measurement: %0.3f m", (double)report.current_distance); warnx("time: %llu", report.timestamp); }