[Tinyos-help] C mig generated files

Michael Schippling schip at santafe.edu
Fri Dec 1 12:58:50 PST 2006


 From the description it sounds like your ReportMsg_field_get() function
is expecting to get a pointer to the payload, not the full message.

Unless things are very different in T2, the message payload should
be at a fixed offset from the beginning of the packet and shouldn't
vary with payload type (although the actual length might vary). The
old standby technique is something like:

   TOS_Msg *msg = (TOS_Msg*) (packet + 1); // assume +1 skips sync byte?
   tmsg_t *tmsg = (tmsg_t *) msg->data;

Which seems to be what the prettylisten.c example is doing.
MS



Dimas Abreu Dutra wrote:
> Hello everybody,
> 
> I use TinyOS 2.0 and have used mig to generate c files for the active 
> messages I receive over the serial port. However, the 
> prefix_fname_get(tmsg_t *msg) functions generated by mig do not get the 
> proper values of the payload fields, instead they interpret the header 
> as the beggining of the payload.
> ______________________________________________________
> My code is as follows:
> {
> uint8_t *packet = read_sf_packet(fd, &len);
> ...
> tmsg_t *msg = new_tmsg(packet + 1, len - 1);
> ...
> ReportMsg_field_get(msg);
> }
> _______________________________________________________
> where ReportMsg.c is my mig generated source.
> 
> Does anyone know how to get the proper field? I tried using the
> void *payload = tmsg_data(msg) + spacket_data_offset(0);
> like in support/sdk/c/prettylisten.c, but it requires me to parse each 
> AM type in a different function.
> 
> thanks in advance.
> ~Dimas~
> 
> 
> ------------------------------------------------------------------------
> Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu 
> celular. Registre seu aparelho agora! 
> <http://us.rd.yahoo.com/mail/br/tagline/mobile_alerts/*http://br.mobile.yahoo.com/mailalertas/> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


More information about the Tinyos-help mailing list