Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: [AVR-Chat] Bit fields

Re: [AVR-Chat] Bit fields

2010-06-07 by John Samperi

At 09:08 AM 8/06/2010, you wrote:
>Not that I expect this, but say the last packet arrives first...
>Or the middle packet arrives three times. (very possible)

What information is in the packet that tells you the sequence?

If a packet can be received more than once in a particular sequence
do they have some time stamp from the source or is this done at the
receiving end? Do you discard multiple packets and keep the newest one?

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: [AVR-Chat] Bit fields

2010-06-08 by David VanHorn

> What information is in the packet that tells you the sequence?

There's a byte in each that says which one it is.

> If a packet can be received more than once in a particular sequence
> do they have some time stamp from the source or is this done at the
> receiving end? Do you discard multiple packets and keep the newest one?

The source flings them out into a mesh network, so I may get multiple copies.
I can discard dupes, I just need to know when I have all the "slots" full.


Initially I was thinking that I'd do a bit array, set the unused bits
to 1, the "not arrived yet bits" to 0, and then flip them to 1 as the
packets arrive.  When the array ands to FF, then I'm done.   Seems
simple in concept, but messy so far in C.

Re: [AVR-Chat] Bit fields

2010-06-08 by Robert Adsett

On 6/7/2010 9:07 PM, David VanHorn wrote:
> Initially I was thinking that I'd do a bit array, set the unused bits
> to 1, the "not arrived yet bits" to 0, and then flip them to 1 as the
> packets arrive.  When the array ands to FF, then I'm done.   Seems
> simple in concept, but messy so far in C.

To set received bit

receive_fl |= 1 << pktnum;


To check all received

if( receive_fl == 0xFF) {}

Setting not used to one is a little more work but assuming that they are 
not scattered a very straightforward loop will do it.

receive_fl=0;
for( i =  first_not_rec; i < 8; i++) {
     receive_fl |= 1 << i;
     }

Obvious optimizations for known fixed receive groups left as an 
exercise.  Syntax errors and typos are to check if you are following ;)

Looks simple and clean to me.

Robert

-- 
http://www.aeolusdevelopment.com/

  From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time?  37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."

RE: [AVR-Chat] Bit fields

2010-06-08 by Dave McLaughlin

Damn!! I didn't scroll down far enough from your initial message!! Same idea
I thought of but reversed bit state!!
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of David VanHorn
Sent: 08 June 2010 08:07
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Bit fields

 

  

> What information is in the packet that tells you the sequence?

There's a byte in each that says which one it is.

> If a packet can be received more than once in a particular sequence
> do they have some time stamp from the source or is this done at the
> receiving end? Do you discard multiple packets and keep the newest one?

The source flings them out into a mesh network, so I may get multiple
copies.
I can discard dupes, I just need to know when I have all the "slots" full.

Initially I was thinking that I'd do a bit array, set the unused bits
to 1, the "not arrived yet bits" to 0, and then flip them to 1 as the
packets arrive. When the array ands to FF, then I'm done. Seems
simple in concept, but messy so far in C.



[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.