Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 10:efd1e313fe8c, committed 2018-08-02
- Comitter:
- amateusz
- Date:
- Thu Aug 02 11:16:24 2018 +0000
- Parent:
- 9:a3062b9e4324
- Child:
- 11:e0ccc1072c42
- Commit message:
- New SDI-12 terminal, yikes!
Changed in this revision
| SDI12_device.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SDI12_device.h Wed Aug 01 18:13:52 2018 +0000
+++ b/SDI12_device.h Thu Aug 02 11:16:24 2018 +0000
@@ -22,15 +22,14 @@
Identification_struct _ident_struct;
- static int detect(SDI12 &sdi12, char indices[], int limit = -1){
+ static int detect(SDI12 &sdi12, char indices[], int stop = -1, int start = -1) {
char found = 0;
- for (size_t i = 0; i < (limit==-1?ADDRRICES.size():limit); ++i) {
+ for (size_t i = (start==-1?0:start); i < (stop==-1?ADDRRICES.size():stop+1); ++i) {
string question = "?!";
question[0] = ADDRRICES[i];
sdi12.sendCommand(question);
std::string response;
-// debug("SEARCHING: %d\r\n", i);
Timer detectTimer;
detectTimer.start();
while (detectTimer.read_ms() < RESPONSE_TIMEOUT) {
@@ -46,20 +45,21 @@
}
}
}
+ osDelay(200);
}
return found;
};
- SDI12_device (SDI12 &inst, char address, EventQueue &mainDispatcher) : _sdi12(inst),sensorQueue(4*EVENTS_QUEUE_SIZE){
+ SDI12_device (SDI12 &inst, char address, EventQueue &mainDispatcher) : _sdi12(inst),sensorQueue(4*EVENTS_QUEUE_SIZE) {
setAddress(address);
sensorQueue.chain(&mainDispatcher);
if(getIdentification(_ident_struct));
};
- //~SDI12_device () {
-// // unchain event queue
+ ~SDI12_device () {
+ // unchain event queue
// sensorQueue.cancel(_measurementEventId);
-// sensorQueue.chain(NULL);
-// }
+ sensorQueue.chain(NULL);
+ }
// // returns after how many seconds a measurement will be ready
@@ -77,7 +77,7 @@
return false;
}
}
-
+
unsigned char bufferSize = sdi12.RxBufferAvailable();
char buffer[bufferSize+1];
sdi12.getRxBuffer(buffer);