Hi guys,
I'm creating two devices that communicate together with a simple packet, formated like this:
!H,12.01,42.24,Checksum\r\n
Where the 12.01 and 42.24 values are used to transmit floating point numbers. Generally, the two devices will be used together, but there might be a scenario where they are used separately.
The transmitting device pretty much reads out several sensors. How would you go about transmitting a bad state (sensor channel disconnected, shorted...) to the upper system? At the moment I'm setting the float values to nan, which is then conveniently printf'd into "nan" and on the other side it's scanf'd back into nan.
Transmitting some special string (say, "ERR") when the sensor is broken complicates things on both sides, but it would look much nicer. The parsing at the moment can be achieved by one sscanf line.
If you were buying a device, would you be OK with "nan" used when the specific channel has an error, or would you prefer "ERR"?
Thanks,
David