Hi all,
i want to fill the first 8 bytes of a uint8_t* pointer with the values 0x01
0x02 0x03 0x04 0x05 0x06 0x07 0x08, and send it by radio (micaz motes):
This is the code of my app (App.nc):
<----------------------------------------------------
uint8_t* pointer;
call interface.function(pointer);
----------------------------------------------------->
In other module/file, i have got the implementation of that function:
<------------------------------------------------------------------------------------------------------------------------------------
command void interface.function(uint8_t* pointer)
{
uint8_t x = 1;
memset(pointer, 0, 8*sizeof(uint8_t)); //For security, fill the first 8
bytes of the pointer with ‘0x00’
for(i=0; i<8; i++) {
memcpy(pointer+i, &x, sizeof(uint8_t));
printf("pointer[%d]: 0x%02X \n", i, pointer[i]);
x++;
}
}
------------------------------------------------------------------------------------------------------------------------------------>
Output:
pointer[1614823456ð]: 0x00
pointer[1]: 0x00
pointer[2]: 0x03
pointer[3]: 0x04
pointer[4]: 0x05
pointer[5]: 0x06
pointer[6]: 0x07
pointer[7]: 0x08
As you can see, first two bytes of the pointer are wrong.
First byte of pointer got a wrong index: ‘1614823456ð’, and his value should be
pointer[0] = 0x01
Second byte got a correct index, but a value of ‘0x00’, when it should be
pointer[1] = 0x02
What i’m doing wrong? I hope that someone can help me, i took several days
without solving this problem.
Thanks for your time,
Felipe._______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help