0

hello every one i want to ask you if you know a way to extract data from message_t in the oldest version of TinyOs there are TOS_Msg and TOS_MsgPtr but in message_t i could't find a way please help me and i want to know if there is any data type to store data like table or array list

typedef nx_struct message_localization{
    nx_uint8_t   NodeId;
    bool       ancre_nature;
    nx_uint8_t   x_coordinate;
    nx_uint8_t   y_coordinate; 
    x_uint8_t   energie_transmited;

 } message_localization_t;
runDOSrun
  • 10,359
  • 7
  • 47
  • 57

1 Answers1

0

The Packet interface has a command getPayload which does want you want:

command void *getPayload(message_t *msg, uint8_t len);

See the documentation for more information.

To access the data field, you may do as follows:

message_t msg;
message_localization_t *payload =
    (message_localization_t *)call Packet.getPayload(
        &msg, sizeof(message_localization_t));
payload->x_coordinate = x;
payload->y_coordinate = y;
/* and so on */

The same command is for convenience included in interfaces Send and AMSend. Packet and AMSend are provided by the ActiveMessageC configuration.

maral
  • 1,431
  • 1
  • 10
  • 15