On Sun, 17 May 2009, Vitaliy wrote: > Olin Lathrop wrote: > >> : the 8 bit polynomial checksum > > > > 8 bits is very small for the size packets you are talking about. It may > > be > > good enough for your purposes if you don't really expect errors, which > > might > > be applicable in your case. > > I disagree. An 8-bit CRC is used in automotive protocols (including CAN), > which were specifically designed for noisy environments. > > > > You also need to think about timeouts when a ACK is not received. Think > > carefully about what happens when the ACK itself is lost. The receiving > > node got the command, executed it, and sent the ACK. The transmitting > > node > > has to assume the receiver never got the command. Most likely it will > > resend after a timeout, but you have to think carefully about what the > > receiving node might do if it receives two separate valid commands. A > > sequence number is the usual way around this, but there are other > > strategies. > > - Avoid "vague" commands ("toggle") in favor of more specific ones ("turn > off") > - Have the transmitter request the status before issuing the command again This implies that comms between two nodes is "serial" i.e. commands and responses must ping pong back and fore between two nodes (say A and B) before comms between other nodes can be accepted by either A or B otherwise things start getting really hairy. The other thing to consider is what happens if the "turn off" command is sent before the "turn on" command but arrives AFTER the "turn on" command. Here "toggle" actually is an advantage. Yes packet sequence numbers are definiately very useful for deciding what to do here. Regards Sergio Masci -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist