On Sat, Nov 30, 2013 at 5:24 AM, nivedita datta <[email protected]>wrote:
> I am working on a small code in TinyOS 2.x in which I want to copy values
> into an array as following.
>
> uint8_t in[16] =
> {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
> uint8_t var = 0x24;
> memcpy(&in, &var, sizeof(uint8_t));
>
what on earth are you actually trying to do? The reason I ask is because
the code you are presenting doesn't make a lick of sense. You could write
what you have written if you want to set the 1st byte of in to 0x24. But
why would you want to use memcpy for that. The code generated is much more
than a simple, in[0] = var;
memcpy copies memory from one block of memory to another. The dst block
needs to be at least as big as the source block (or at least as big as the
3rd parameter).
If you are on a Linux box try reading "man memcpy" it will give you the
details.
perhaps what you are trying to do is set the "in" array to the value of
var, in which case you want to use
memset(in, var, sizeof(in));
will set in to all 0x24.
also when you ask for help it is always better to be explicit about what
error you are seeing. You just say you got errors which doesn't really
tell us anything.
think about if someone was asking you a question, what you would need to
know to answer it reasonably.
the more you help us understand what is happening the easier it is for us
to answer. And the easier it is to answer the more likely you will get an
answer.
get it?
>
> Here I want to generate the value of var randomly and copy that value into
> the array in[16]. I tried using memcpy as shown above but I am getting
> errors. The code I am trying to modify is TestAES.nc taken from the
> following link:
> https://github.com/tyll/tinyos-2.x-contrib/tree/master/crypto. Could you
> please let me know what am I doing wrong here?
>
> Thanking you for the time & effort.
>
> Regards,
> Nivedita Datta
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
--
Eric B. Decker
Senior (over 50 :-) Researcher
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help