Hi David, I am assuming your packet count and packet number is known in each packet? With this 1 of 3 etc you would know what is arriving. At startup, reset a simple variable to all 1's (for instance, if the max packet count is 8 or less, then you can use an unsigned char, for 16 use an unsigned int etc etc) As each packet arrives, you go ahead and store it. You take the packet number and clear the bit for that in the variable above. Once this variable is ZERO you have all the packets. Because it simply clears the bits as a packet arrives, it does not matter now if a packet is received more than once. This will work but you have to be careful because after the packets arrive and you have a complete block, you may get another packet resent or does this not matter and you simply start populating a new block? This sound similar to your bit field idea and to be honest, this sounds like the easiest solution, even if it sounds messy, there is no worrying about packets arriving more than once with this method. You can either store or discard if already received. Good luck with it. Sounds like an interesting challenge! Dave. From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of David VanHorn Sent: 08 June 2010 04:26 To: AVR-Chat@yahoogroups.com Subject: [AVR-Chat] Bit fields I have an application that needs to receive a variable number of packets in a block of data. I store them into a block-sized array with a packet-sized offset multiplied by the packet number.. I need to know when I've received all the packets, but out-of-order and duplicate packets are possible. I was thinking of doing this with a bit-field but that seems pretty messy. Are there other good ways to know when I've received all the packets, given that they may arrive out of order? [Non-text portions of this message have been removed]
Message
RE: [AVR-Chat] Bit fields
2010-06-08 by Dave McLaughlin
Attachments
- No local attachments were found for this message.