0

I have the following method/event in nesc. I am getting an error

event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
radio_count_msg_t* adammsg = (radio_count_msg_t*) payload;
val =adammsg -> counter;
dbg("RadioCountToLedsC", "The current summation is: %d \n", val);
return bufPtr;
}

on the 4th line of this block of code. The error specifically is: "Syntax error before '*'. It then says adammsg is undeclared in the next line

Can anyone tell me what my error could possibly be? I've been stuck on this for a while and it's been driving me insane. I'm working on the RadioCountsToLeds app that is included in Tinyos. Specifically I am trying to inject packets- send them to nodes- and then do computations on the information stored in the packets.

Thanks!

chevybow
  • 9,959
  • 6
  • 24
  • 39

1 Answers1

1

In C (and nesC as well), all declarations of variables must be at the begin of a function. So:

event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
radio_count_msg_t* adammsg = (radio_count_msg_t*) payload;
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
val =adammsg -> counter;
dbg("RadioCountToLedsC", "The current summation is: %d \n", val);
return bufPtr;
}
maral
  • 1,431
  • 1
  • 10
  • 15
  • Thanks! Ive only spent a few months with C and a few weeks with nesC so I completely forgot about this. I managed to fix this event and my whole program works as intended now. Thanks again – chevybow Jun 04 '16 at 22:25