In "good ole C" one must declare local variables
at the top of code blocks (usually the beginning
of the function/method). For some reason the NESC
folks didn't mess with that...
MS
Fernando Gielow wrote:
> I keep getting a syntax error, and I am not exactly sure why.
>
> Here is the error of my compilation (make mica2):
> In component `RadioSenseToLedsC':
> RadioSenseToLedsC.nc: In function `Receive.receive':
> RadioSenseToLedsC.nc:117: syntax error before `*'
> RadioSenseToLedsC.nc:120: `val' undeclared (first use in this function)
> RadioSenseToLedsC.nc:120: (Each undeclared identifier is reported only
> once
> RadioSenseToLedsC.nc:120: for each function it appears in.)
> make: ** [exe0] Erro 1
>
>
>
> My .nc file corresponding to this piece of code:
> 103 event message_t* Receive.receive(message_t* bufPtr,
> 104 void* payload, uint8_t len) {
> 105
> 106
> 107 call Leds.led1Toggle();
> 108 if (len != sizeof(radio_sense_msg_t)) {return bufPtr;}
> 109 else {
> 110 am_addr_t tt = call AMPacket.source(bufPtr);
> 111 uint16_t ttt = (uint16_t) tt;
> 112 char str[64];
> 113 sprintf(str,"%d: Recebi msg do %d",TOS_NODE_ID, ttt);
> 114 printStr(str);
> 115
> 116
> 117 radio_sense_msg_t* rsm = (radio_sense_msg_t*)payload;
> 118
> 119 uint16_t val = rsm->data;
>
>
> But if I move the content of the lines 110~114 to BEFORE the IF
> condition it works perfectly! Why is that? Can someone explain to me
> where is my SYNTAX error?
>
> Actually.. Why does it says that val is not declared too?
>
> ps.: I use the sprintf only to convert that all to a single string, the
> printStr is part of another lib, used to print it in the middle of a
> simulation (I am not using TOSSIM, I am trying to use avrora)
>
>
> Thanks in advance,
> Fernando.
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help