paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Paparazzi-devel] Paparazzi modem protocol - checksum help


From: Greg Jones
Subject: [Paparazzi-devel] Paparazzi modem protocol - checksum help
Date: Sun, 16 May 2010 22:14:25 +0100

Hi,

I have been trying to implement the checksum applied to messages
transmitted using the Paparazzi protocol (as opposed to the XBee
protocol.)

The Checksum detailed in 'modem.ml' looks relatively simple and seems to
XOR the contents of the message and inserts this value into the last but
one packet of each message.

However I must be missing something as I cannot correctly compute this
checksum - could somebody who understands the checksum or OCAML please
give me a clue what the following code extract is doing?

let checksum = fun msg ->
    let l = String.length msg in
    let ck_a = ref 0 in
    for i = 1 to l - 3 do
      ck_a := Char.code msg.[i] lxor !ck_a
    done;
    !ck_a = Char.code msg.[l-2] && Char.code msg.[l-1] = etx


My code tries to replicate the above and does the following:

1) Zero the checksum variable
2) Loop through STX, Length and the message XORing each byte with the
checksum variable
3) Write the checksum to the message
4) Write the ETX (by the way what should ETX be, STX seemed to be 0x99?)

Where am I going wrong? OCAML is a bit of a nightmare to the
uninitiated.

Many thanks

Greg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]