Got it, I just had to define each value to be sent in a separate variable
instead of a sending in a single as, e.g.,:
typedef nx_struct beaconpkt{
nx_uint8_t beacon_trigger;
nx_uint8_t beacon_nn;
nx_int32_t beacon_mu;
nx_int32_t beacon_eta0;
nx_int32_t beacon_eta1;
}beaconpkt;
Stupid mistake and sorry for the spam.
Best,
Jose
From: Bdiri Sadok [mailto:[email protected]]
Sent: den 31 mars 2014 14:51
To: José Silva Oliveira Araujo
Subject: Re: [Tinyos-help] transmit packet with negative/signed int values
hello,
you don't send int32 or int16.... in a packet. You send bytes. So convert your
variable type into byte then send.
On Mon, Mar 31, 2014 at 2:45 PM, José Silva Oliveira Araujo
<[email protected]<mailto:[email protected]>> wrote:
Hi all,
I had one question on a problem I am getting. I am trying to send int32 values
in a packet in my TelosB nodes and some of the values may be negative. Tried
looking online but couldn't find anyone with the same issue or a solution to
the problem.
I am defining the packet defined as
typedef nx_struct beaconpkt{
nx_int32_t beaconvals[4];
}beaconpkt;
and I am printing a value from the packet at the sender and it is being
correctly defined and is signed. However, when the packet is received, the
positive value is correct but the negative values are giving a nonsense value.
I had in my mind that I had already tried to send negative values in a packet
and all worked fine but maybe I am mistaken. Does anybody have experience on
this?
I am sending the packet like:
message_t pktToActuator;
nx_int32_t eta0tmp;
beaconpkt* apkt = (beaconpkt*)(call Packet.getPayload(&pktToActuator, sizeof
(beaconpkt)));
eta0tmp = -1000;
apkt->beaconvals[3] = eta0tmp;
if (!busy) {
if (call AMSend.send(AM_BROADCAST_ADDR, &pktToActuator, sizeof(beaconpkt)) ==
SUCCESS) {busy = TRUE;}
}
And reading the packet as:
beaconpkt* apkt = (beaconpkt*)payload;
eta0tmp = (apkt->beaconvals[3]);
Thanks for the help!
Best,
José Araújo
_____________________________
PhD student
Department of Automatic Control
KTH Royal Institute of Technology
http://people.kth.se/~araujo/
_______________________________________________
Tinyos-help mailing list
[email protected]<mailto:[email protected]>
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
--
M.Sc., Dipl.-Ing. Sadok Bdiri
Research Assistant in HTWK Leipzig, Germany
___________________________________________________
Ph.D student
Master of Science in Robotics
Computer & Embedded Systems Engineer
Horchule für Technik, Wirtschaft und Kultur Leipzig
University of Applied Sciences Leipzig
Universität Chemnitz,Fakultät für Elektro- und Informationstechnik Technische,
Lehrstul für Mess-und Sensortechnick (MST)
Mobile :+49-152-55394310
Address: Wächterstraße 13, 04107 Leipzig, Germany
----------------------------"One can have no smaller or greater mastery than
mastery of oneself" --[Leonardo Da Vinci]---------------------------
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help