Hello, Thanks everyone. Symon your code is what I was looking for. In my case works perfectly.
Maybe I try to modify it because I would like to use more than 3 motes. Sonia 2009/3/3 Symon Vezina <[email protected]> > Something like this maybe ? I have not tested it much. > > Symon > > > #include <stdio.h> > #include <stdint.h> > #include <string.h> > > typedef struct { > uint8_t *pkt1; > uint8_t *pkt2; > uint8_t *pkt3; > uint8_t *pktOut; > uint8_t cmplen; > }cmpPktInfo_t; > > uint8_t* pktcmp(cmpPktInfo_t *cpi) { > uint8_t i; > for(i=0; i<cpi->cmplen; i++) { > if(!((cpi->pkt1[i] ^ cpi->pkt2[i]) || (cpi->pkt1[i] ^ cpi->pkt3[i]))) { > cpi->pktOut[i] = cpi->pkt1[i]; > }else if(!(cpi->pkt1[i] ^ cpi->pkt2[i])) { > cpi->pktOut[i] = cpi->pkt1[i]; > }else if(!(cpi->pkt1[i] ^ cpi->pkt3[i])) { > cpi->pktOut[i] = cpi->pkt1[i]; > }else if(!(cpi->pkt2[i] ^ cpi->pkt3[i])) { > cpi->pktOut[i] = cpi->pkt2[i]; > } > } > return cpi->pktOut; > } > int main() { > uint8_t answer[6] = {0}; > cmpPktInfo_t cpi = {"HELLO", "MaULO", "HELLR", (uint8_t*)&answer, > sizeof(answer)}; > printf("pktOut: %s\n", pktcmp(&cpi)); > return 0; > } > > > > Date: Tue, 3 Mar 2009 14:49:37 -0500 > > From: [email protected] > > To: [email protected] > > CC: [email protected] > > Subject: Re: [Tinyos-help] compare bit to bit or byte to byte > > > > > Hi! > > > > On Tue, 3 Mar 2009, Sonia Pardo wrote: > > > > > Hi, > > > > > > Sorry for my explanation but I think is not clear. Let's try again. > > > > > > I've one mote which send packets in broadcast. On the other side I've > three > > > motes that receive the packets from first mote. One mote of them is > > > connected whit the PC (mote B). I've made a programm that show the data > > > content of the received packets in mote B. > > > Maybe mote B receives packets whit errors in data content, then I send > a > > > message to the others receiver motes and they send mote B the received > > > packet again. (I guess that packets of this motes can have others > errors in > > > data content). > > > Now I've three packets in mote B. I can show the data content of the > three > > > packets in my application. I want to compare bit to bit the data > content of > > > this three received packets to create a good data content and I only > show > > > that in my application. > > > > > > I don't know how to make this comparison bit to bit. > > > I make an example: > > > > > > Transmitter: Send Hello > > > Receiver (mote B): Receive Mello > > > Receiver C: Receive HeUlo > > > Receiver D: Receive HellR > > > > > > I want to compare bit to bit (Mello, HeUlo and HellR) to create the > word > > > Hello using majority voting. > > > > I still don't know exactly what you mean by 'bit to bit' but the > > explanations on pages 24-25 from here might be useful: > > http://www.ti.com/lit/gpn/cc2420 > > As you can see the bytes are broken into two symbols and each is then > > transmitted as 32 chips. Is this what you were looking for? > > > > -- > > Razvan ME > > > > > I hope that you understand my explanation better. > > > > > > Thanks in advanced, > > > > > > Sonia > > > > > > 2009/3/3 Razvan Musaloiu-E. <[email protected]> > > > > > >> Hi! > > >> > > >> On Tue, 3 Mar 2009, Sonia Pardo wrote: > > >> > > >> Dear All, > > >>> > > >>> We can't use memcmp because this function only say us if the packet > is the > > >>> same or not. > > >>> We would like to compare bit to bit because I want to rebuild the > packet. > > >>> > > >>> For example, we receive three packets from three different motes (But > > >>> three > > >>> motes send the same information). One of them receives Hello. Other > mote > > >>> receives Hello too, but the third packet receives Mello. This packet > has > > >>> errors, but if I compare the three packets bit to bit, I can rebuild > the > > >>> message of the third packet and I can say that the information of > this > > >>> packet is Hello too. > > >>> > > >>> I need a function which compare bit to bit, because I don't know how > can I > > >>> do this...and I think that memcmp is not valid for this. > > >>> > > >>> Can anyone help us? > > >>> > > >>> > > >> CC2420 and RF230 are packet-based radios so you don't have access to > > >> information about the quality of each bit. CC1000 from mica2 is not > > >> packet-based so what you want should be possible there. > > >> > > >> -- > > >> Razvan ME > > >> > > >> > > >> 2009/3/2 Janos Sallai <[email protected]> > > >>> > > >>> How about memcmp in string.h? This is standard C. > > >>>> > > >>>> Janos > > >>>> > > >>>> On Mon, Mar 2, 2009 at 11:13 AM, Jordi Pérez <[email protected]> > wrote: > > >>>> > > >>>>> Dear all, > > >>>>> > > >>>>> I have a Base Station which receives the same packet from three > > >>>>> different > > >>>>> motes. The packets must be the same, but maybe, one of them could > have > > >>>>> some > > >>>>> errors. So, I want to make a task which compare bit to bit, or byte > to > > >>>>> byte, > > >>>>> the three packet received to rebuild a new packet without errors. > > >>>>> > > >>>>> How could I do this task? I don't know how to compare bit to bit > (or > > >>>>> byte to > > >>>>> byte) a received packet. Can you help me please? > > >>>>> > > >>>>> Thanks in advanced, > > >>>>> > > >>>>> Jordi > > >>>>> > > >>>>> > > >>>>> > > >>>> > > >>>> > > > > > ------------------------------ > Messenger has tons of new features that make chatting more fun. Click here > to learn more. <http://go.microsoft.com/?linkid=9650730> >
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
