opqdan

# Aug 17 2010 - 10:08 PM

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:
10000d000105666c6f773102047f0000003f3f
Immediatly followed by this packet
10000d000105666c6f773102043f0000001755
Which then repeats all the way until I see this packet:
10000d000105666c6f77310204000100003f22

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.




opqdan

# Aug 18 2010 - 12:08 AM

As with most problems, as soon as I posted about it, I fixed it.

Apparently ReadString was my problem, and reading each byte individually is producing better results.




mike

# Aug 18 2010 - 12:08 AM

That's rather... strange..!

First, I wonder if the CRC is valid? This could help determine whether we should look at the firmware or the serial handling on the windows side. Can you send an unaltered binary dump of a few messages of serial output?

What sort of Arduino board & arduino SDK are you using? The next thing I'd wonder is if there's some interfering with the counting: running out of memory on your particular config, non-volatile value or similar bug in the kegboard code, etc.

I could also build the fw & send you the hex; this could help rule out some issue with compiling it..

mike




mike

# Aug 18 2010 - 1:08 AM

Ah, glad you got it sorted!