[Tinyos-help] Using memcpy in NesC

nivedita datta sweetnivi88 at gmail.com
Sun Dec 1 03:12:57 PST 2013


Thank you for the reply.
Here I want to generate the value of var randomly and copy that value into
the array in[16]. I also tried doing the following to do the same:

*uint8_t in[16] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};*
*uint8_t var = 0x24;*
*in[0] = var;*

Following is the error I get when running the code.:

*In component `TestAESC':*
*TestAESC.nc:65: warning: type defaults to `int' in declaration of `in'*
*TestAESC.nc:65: conflicting types for `in'*
*TestAESC.nc:63: previous declaration of `in'*
*TestAESC.nc:65: invalid initializer*
*TestAESC.nc:65: (near initialization for `in')*
*TestAESC.nc:65: warning: data definition has no type or storage class*
*TestAESC.nc: In function `Boot.booted':*
*TestAESC.nc:86: warning: passing argument 1 of `AES.encrypt' from
incompatible pointer type*
*TestAESC.nc:98: warning: passing argument 3 of `AES.decrypt' from
incompatible pointer type*
*make: *** [sim-exe] Error 1*

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


On Sun, Dec 1, 2013 at 1:25 PM, Eric Decker <cire831 at gmail.com> wrote:

>
>
>
> On Sat, Nov 30, 2013 at 5:24 AM, nivedita datta <sweetnivi88 at gmail.com>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
>> Tinyos-help at millennium.berkeley.edu
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20131201/90a713de/attachment.htm 


More information about the Tinyos-help mailing list