I'm trying to implement my own .Net based frontend for the kegbot software on the Arduino. I've been trying to parse the flow meter packets on the serial connection, and I'm running into some weird behavior.
The value of the KB_MESSAGE_TYPE_METER_STATUS_TAG_METER_READING tag seems to be rolling over and resulting in odd packets being sent across the wire. Basically, if I set test mode to increment the value by 1 (rather than the default 10), I can see the messages counting up to 127 until they reset to 63, then jump to 256 and repeat with those increments.
Basically, I get this packet:
10000d000105666c6f7731
02047f0000003f3f
Immediatly followed by this packet
10000d000105666c6f7731
02043f0000001755
Which then repeats all the way until I see this packet:
10000d000105666c6f7731
0204000100003f22
The important parts are bolded, this corresponds to the tag (0x02), followed by the length of the data (0x04 is the size of the unsigned long) followed by the data itself.
Because of the values occuring on values that would be boundaries, I'm worried that there is some weird data being pushed into the packets for some reason or I am reading it incorrectly.
As far as I can figure, the arduino code is perfect (the only possible place I can imagine is the serial_print_int function, but doing it by hand shows this to be correct).
Basically, has anybody else seen this? I'm using .Nets SerialPort.ReadLine() to read the full packet from the "KBSP v1:" string to the "\r\n". I can't see how I'd prevent that by reading byte by byte, but perhaps something is going awry.
Thanks.