[Tinyos-help] Access and set individual bit in payload

Ittipong Khemapech ik.tinyos at googlemail.com
Fri Jan 30 05:18:00 PST 2009


Hi Mindaugas,

Many thanks to your reply. I'll try and let you know.

Ittipong

2009/1/30 Mindaugas Jaraminas <minde.j at gmail.com>

> Hi Ittipong
>
> Here is quick example:
>
> #include <stdio.h>
> #include <string.h>
> #define UINT8 unsigned char
>
> void display(UINT8 * buffer, UINT8 Length){
>        UINT8 * tmp = buffer;
>        UINT8 mask;
>        int i, y;
>        for (i = 0; i < Length; i++) {
>                mask = 1;
>                printf ("Printing byte 0x%02X,  bits = ", *tmp);
>                for (y=0; y < 8; y++ ){
>                        printf ("%X,", (*tmp & mask) >> y);
>                        mask = mask << 1;
>                }
>                printf ("\n");
>                tmp ++;
>        }
> }
>
> int main ()
> {
>  UINT8 buff[3]= {0x01, 0xAA, 0x03,};
>  UINT8 len = sizeof(buff);
>
>  display(buff, len);
>
>  return 0;
> }
>
> The output is:
>
> Printing byte 0x01,  bits = 1,0,0,0,0,0,0,0,
> Printing byte 0xAA,  bits = 0,1,0,1,0,1,0,1,
> Printing byte 0x03,  bits = 1,1,0,0,0,0,0,0,
>
> --
> Best regards
> Mindaugas Jaraminas
>
> George Carlin  - "May the forces of evil become confused on the way to
> your house."
>
>
> 2009/1/30 Ittipong Khemapech <ik.tinyos at googlemail.com>:
> > Hi,
> >
> > Is it possible to access and set value to each individual bit of
> message_t
> > payload? I've been through the archives and found nothing. If you have
> done
> > before, please share or give me some hints.
> >
> > Many thanks in advance,
> > Ittipong
> >
> >
> > _______________________________________________
> > Tinyos-help mailing list
> > Tinyos-help at millennium.berkeley.edu
> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090130/19139b04/attachment.htm 


More information about the Tinyos-help mailing list