CheckSum

Started by David Sousa Mendes April 19, 2005
Hello
My program is sending data (stored in EEPROM) to the PC or to a GSM mobile phone connected to it...
What kind of Checksum (Data Integrity Verification) would you recomend? Does someone have an algorithm to do it?
Cheers
David Mendes

----- Original Message -----
From: arhodes19044
To: basicx@basi...
Sent: Monday, April 18, 2005 11:35 PM
Subject: [BasicX] Re: IP Theft. Was (DC motor Questions (was PWM Generation))
And sometimes the similarity is due to the fact that there is ONE
good way to do the job.

I once wrote some ASM code to use the PC FPU for some intense 80 bit
repetetive math operations. Not many variables, but a TON or
recursive calculations. It was possible to do nearly all the
calculations in the FPU stack. It was as streamlined as I knew how
to do it. I spent a lot of time thinking and writing.

Not long afterward, I saw some software that did the same stuff. I
disasm'd it and found..... voila the same code. Exactly the same.
Not many lines were used for the recursive calculations, but the
technique and the sequence were identical.

That is because for the relatively simple task, and the relatively
constrained spectrum of possible methods, there is only one BEST way
to do it. If you find the BEST way, then someone else is likely to
do the same.

Smetimes IP theft is not.

-Tony

P.S. I also never charge people for my IP. I give it away (I
suppose because I have a different day job with an entirely
different sort of intellectual demands). It really annoys me that
everyone wants to charge people for basic info. Like once I was
looking for a reference to how to tune the carburetor on my
snowblower. Lots of places on the internet wanted to SELL me a
manual. I just needed to see an exploded diagram. Never did find
one for free. I had to get on my knees and look. Then it was easy.

--- In basicx@basi..., "tombhandley" <gr13tbs@c...> wrote:
>
> re: "Hardware design is REALLY the same as software design. You
> steal someone else's idea, make a few mods and viola you are done."
------
Yahoo! Groups Links

a.. To



David,

> Hello
> My program is sending data (stored in EEPROM) to the PC or to a GSM
> mobile phone connected to it...
> What kind of Checksum (Data Integrity Verification) would you
> recomend? Does someone have an algorithm to do it?
> Cheers
> David Mendes
>
Part of the answer depends on what the PC or phone is expecting but
assuming you can do anything then the easiest from the BasicX side is to
simply add each byte into a checksum byte. BasicX automatically discards
anything above 255 so you have a nice modulo 256 checksum which is
sufficient for most purposes. If you want error detection or error
correction that is a whole other story.

Mike



I have a rather simple 16 bit true CRC
neil

Mike Perks wrote:

> David,
>
> > Hello
> > My program is sending data (stored in EEPROM) to the PC or to a GSM
> > mobile phone connected to it...
> > What kind of Checksum (Data Integrity Verification) would you
> > recomend? Does someone have an algorithm to do it?
> > Cheers
> > David Mendes
> >
> Part of the answer depends on what the PC or phone is expecting but
> assuming you can do anything then the easiest from the BasicX side is to
> simply add each byte into a checksum byte. BasicX automatically discards
> anything above 255 so you have a nice modulo 256 checksum which is
> sufficient for most purposes. If you want error detection or error
> correction that is a whole other story.
>
> Mike > *>.





--- In basicx@basi..., nmj <njepsen@i...> wrote:
> I have a rather simple 16 bit true CRC.

I have BasicX code that computes the Internet checksum (RFC 1071) if
that would be useful. It is used in IP packets.

Don


Mike,
Your suggestion seems suitable for me. But:
1- How do I add that checksum byte?
2- What is that "nice modulo 256 checksum " that you mention?

Cheers
David ----- Original Message -----
From: Mike Perks
To: basicx@basi...
Sent: Wednesday, April 20, 2005 3:20 AM
Subject: Re: [BasicX] CheckSum David,

> Hello
> My program is sending data (stored in EEPROM) to the PC or to a GSM
> mobile phone connected to it...
> What kind of Checksum (Data Integrity Verification) would you
> recomend? Does someone have an algorithm to do it?
> Cheers
> David Mendes
>
Part of the answer depends on what the PC or phone is expecting but
assuming you can do anything then the easiest from the BasicX side is to
simply add each byte into a checksum byte. BasicX automatically discards
anything above 255 so you have a nice modulo 256 checksum which is
sufficient for most purposes. If you want error detection or error
correction that is a whole other story.

Mike ------
Yahoo! Groups Links

a.. To



David,

A simple algorthim for calculating a checksum - caution untested code as
away from my BX :)

Const MessageLength as Integer = 11
Dim i as Integer
Dim Message(1 to MessageLength) as Byte
Dim Checksum as Byte
Checksum = 0
For i=1 to MessageLength - 1
Checksum = Checksum + Message(i)
Next
Message(MessageLength) = Checksum

Mike

> Your suggestion seems suitable for me. But:
> 1- How do I add that checksum byte?
> 2- What is that "nice modulo 256 checksum " that you mention?
>
> Cheers
> David > ----- Original Message -----
> From: Mike Perks
> To: basicx@basi...
> Sent: Wednesday, April 20, 2005 3:20 AM
> Subject: Re: [BasicX] CheckSum > David,
>
> > Hello
> > My program is sending data (stored in EEPROM) to the PC or to a GSM
> > mobile phone connected to it...
> > What kind of Checksum (Data Integrity Verification) would you
> > recomend? Does someone have an algorithm to do it?
> > Cheers
> > David Mendes
> >
> Part of the answer depends on what the PC or phone is expecting but
> assuming you can do anything then the easiest from the BasicX side
> is to
> simply add each byte into a checksum byte. BasicX automatically
> discards
> anything above 255 so you have a nice modulo 256 checksum which is
> sufficient for most purposes. If you want error detection or error
> correction that is a whole other story.
>
> Mike > ------
> >.





--- In basicx@basi..., Mike Perks <basicx@a...> wrote:
> Message(MessageLength) = Checksum

It is common for the negative of the checksum to be appended to the
message so that when the receiver processes the message the sum of the
computed checksum and the transmitted checksum is zero.

Of course, the sender and receiver have to agree on the methodology.
If you are creating code for both ends of the link you can do whatever
you want. If you have to talk to an existing system, you have to
generate the checksum or CRC in the same manner as does the other end
of the link.


I generally just do a compare, rather than generate the negative CRC and
add. Doesn't make any difference of course. It goes without saying that
thebreceiving end must use the same generation algorithm.
neil
\Don Kinzer wrote:

>
> --- In basicx@basi..., Mike Perks <basicx@a...> wrote:
> > Message(MessageLength) = Checksum
>
> It is common for the negative of the checksum to be appended to the
> message so that when the receiver processes the message the sum of the
> computed checksum and the transmitted checksum is zero.
>
> Of course, the sender and receiver have to agree on the methodology.
> If you are creating code for both ends of the link you can do whatever
> you want. If you have to talk to an existing system, you have to
> generate the checksum or CRC in the same manner as does the other end
> of the link. >
>
> *>.