neilh10 / ModularSensors

A forked ModularSensors for a rugged solar powered logger; Mayfly.
https://github.com/neilh10/ModularSensors/wiki
Other
1 stars 1 forks source link

SDI-12 add CRC capability #68

Open neilh10 opened 3 years ago

neilh10 commented 3 years ago

Add CRC capability to a command and response. The CRC adds reliability to the message, for the response any corruption is detected, ~ and discarded.

SDI-12_version-1_4-Jan-30-2021.pdf has a section 4.4.12 Requesting a Cyclic Redundancy Check The commands supported are
Start Measurement and RequestCRC* | aMC!
Send Data aD0! (IF aMC! or aCC!)
Additional Measurements and Request CRC
Additional Concurrent Measurements aC1! ... aC9! Start Concurrent Measurement and Request CRC aCC!
Additional ConcurrentMeasurements and Request CRC aCC1! ... aCC9!
Continuous Measurements and Request CRC aRC0! ... aRC9!

Insitu SDI-12_Commands_Tech_Note 2020-05-22.pdf identifies supports v1.3 Command Set
Insitu SDI-12-Commands-and-Level-TROLL-400-500-700-Responses 20140210.pdf
manual identifies it supports V1.3 Command Set, CRC response. aMC1!, aCC!, aRCx! response for ADx!,

neilh10 commented 3 years ago

Investigating, the SDI12, requested data with "1D!" processes characters as a stream (not a buffer).

class SDI12Sensors : public Sensor

SDI12 _SDI12Internal; class SDI12 : public Stream To read buffer and verify a CRC at the end of the stream is going to take reworking SDI12.cpp and also SDI12Sensors.cpp

The partitioning of functions is scattered across two or more classes. Requesting and processing an SDI-12 msg, is split between class SDI12Sensors.cpp and class SDI12 and class String, so introducing a CRC is conceptually rearranging the processing.. Typically its nice to get the whole buffer in, to , verify the CRC, then process the values in the buffer. If they are processed inline, and the last float is variable up to 9 characters, and CRC happen to be number '0 to '9' how to detect them before reaching the

1C! 1C!100103 ~ request concurrent, and response is wait 10mS and then returns 3 variables 1D0! 1+0.01571+20.5635+0.03628 1CC! 1CC!100103 ~ request concurrent, with CRC and response is wait 10mS and then returns 3 variables 1D0! 1+0.01582+20.6165+0.03652Nl\ ~ result with CRC= Nl\