PDA

View Full Version : Checksum


GATJR
04-11-07, 06:59 PM
We use the ServoPod as an extensible, intelligent front end for connection between a PC platform and our vehicle. It controls all of the servos and I/O to the vehicle.

We communicate to it using command line FORTH words that we create. It is easy for us to add a new FORTH word so extensibility and field testing is awesome. We also can request data that is simply reported back to us over the command line. Just execute the FORTH word in interpretive mode and observe the results on the serial port.

That is a real nice, but the serial line is without any form of message or command validity checking like a checksum.

Would there be a way that would add and require a checksum before the receipt of a CR and the transmission of a CR.

The concept would be that a command line would be typed into ServoPod and that it would expect the last two characters to be the 8 bit hex checksum of the characters in the line. If the checksum was wrong then the line was ignored. The checksum would be the 8 bit modulo addition of all characters received since the last CR.

When the ServoPod is transmitting a line of text that before each CR it transmitted the two ascii hex character of the checksum of everything that was transmitted since the last CR.

I am trying to add command line assurity without significantly disturbing the archicture of the system as it is. We have over 3000 hours of driving on the FORTH code base.

I think that this would be a replacement of the interpreter and PAD sender outer, but I'm a bit fuzzy on this. But I believe this is the beauty of FORTH is the ability to do this level of modular change.

What do you think?

GATJR
04-20-07, 12:08 PM
RDUMSE, what do you think about this. Is there a way to do this to add secure FORTH command line communications?

twe
04-28-07, 03:06 AM
: calculate ( s -- n ) count 0 tuck do >r count r> xor loop nip ;
: checkit bl word number 0 word calculate = if here evaluate then ;

checkit 34 command line words that you normally send


The word checkit is the first word to execute. It grabs the next word, gets its numerical value and then checks it against the checksum for the rest of the line. The above is just pseudocode but it could create a manageable solution. The calculated checksum is a simple low tech algorithm.

TWE

GATJR
04-30-07, 10:58 AM
Thanks for this. I'm trying to figure out how thia can help when using a serial stream to communicate with the FORTH command line.

For transmit: I believe what is needed is something that keeps a running total of the values that the FORTH buffer (pad?) has sent such that it can be read and sent at the end. What are transmitted is a string of various numbers

For receive: I believe that a similar running count is needed for all characters received into the buffer prior to FORTH execution. and it could be read and used. What is received is several FORTH words that then cause a response.

Is there a way to use checkit and calculate to do this?