GDP group 24 node core
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue
Diff: sensorinterface.cpp
- Revision:
- 1:27b35752c5d0
- Parent:
- 0:fcab3b154e49
- Child:
- 3:71b090ec5c69
--- a/sensorinterface.cpp Tue Nov 11 17:33:41 2014 +0000 +++ b/sensorinterface.cpp Tue Nov 18 18:28:52 2014 +0000 @@ -8,6 +8,10 @@ char buffer[255]; + #ifdef DEBUG + printf("[SIF] Scanning for devices...\r\n"); + #endif + for (char i=1; i<=254; i=i+2) { //last bit determines read/write not actual address @@ -31,13 +35,22 @@ void sensorinterface::requestData() { - currentSensor = sensors.begin(); - - #ifdef DEBUG - printf("[SIF] Beginning device query chain from 0x%.2X\r\n", currentSensor->first); - #endif - - sendRequest(currentSensor->first); + if (sensors.size() > 0) + { + currentSensor = sensors.begin(); + + #ifdef DEBUG + printf("[SIF] Beginning device query chain from 0x%.2X\r\n", currentSensor->first); + #endif + + sendRequest(currentSensor->first); + } + else + { + #ifdef DEBUG + printf("[SIF] Data requested, but no devices present\r\n"); + #endif + } } void sensorinterface::readyTrigger()