C CODE

Started by pruchj1 April 15, 2005

Hi!
Dont you have someone C code, which implement simple protocol on
UART? Ive Atmega128. I want to be sure, that recieve data are ok,
without mistakes. For example checksum after recieving message...
Thank you!

Honza.




--- pruchj1 <pruchj1@pruc...> wrote:

>
> Hi!
> Dont you have someone C code, which implement
> simple protocol on
> UART? Ive Atmega128. I want to be sure, that
> recieve data are ok,
> without mistakes. For example checksum after
> recieving message...
> Thank you!
>
> Honza. >
>

__________________________________



At 06:10 AM 4/15/2005, pruchj1 wrote: >Hi!
>Dont you have someone C code, which implement simple protocol on
>UART? Ive Atmega128. I want to be sure, that recieve data are ok,
>without mistakes. For example checksum after recieving message...
>Thank you!


Well, both sides of the conversation need to be speaking the same protocol.

One of the simplest is Xmodem, which implements a checksum of the data.
In an xmodem packet, you send the block number,
the complement of the block number, 128 data bytes, then the checksum.
The checksum is simply the result of adding all
the data into an 8 bit register, and throwing
away the carries. (modulus 8 addition)
If you get an errored packet, you send an ASCII
NAK in response, and the host sends the packet again.
If you get a good packet, you send an ASCII ACK,
and the host sends the next packet.

At the higher level, too many errors in a row
causes you to abort the transfer, by sending multiple ^X chars.
Something you should be aware of though, this
group is pretty much abandoned, and we are all over at AVR-Chat.