Hi All,
I just designed a small test for my project to collect the data.
In the .h file, i have a struct like this
typedef nx_struct HashMsg {
nx_uint16_t nodeid;
nx_uint8_t flag;
nx_uint64_t payload_hash;
nx_uint64_t payload_M;
nx_uint64_t payload_R;
nx_uint16_t payload_ID;
} HashMsg;
typedef struct Context
{
uint64_t hash;
uint64_t M;
uint64_t R;
uint16_t ID;
} Context;
in the test file I disigned the send and receive function.
========================================
Context a;
event void Timer0.fired() {
//uint64_t hash;
uint64_t cmd=0xFFFFFFFFFFFFFFFF;
uint64_t S=0x1111111111111111;
if(TOS_NODE_ID==0x00000001){
//call Squash.resetSquash(&squash);
call Squash.setSquash(cmd,S);
if (!busy) {
HashMsg* hmpkt =
(HashMsg*)(call Packet.getPayload(&pkt, sizeof(HashMsg)));
if (hmpkt == NULL) {
return;
}
hmpkt->nodeid = TOS_NODE_ID;
hmpkt->flag = 1;
hmpkt->payload_hash = 0x0000000000000000;
hmpkt->payload_M = 0x0000000000000000; // M
hmpkt->payload_R = 0x0000000000000000; // R
hmpkt->payload_ID = 0x0000;
if (call AMSend.send(destinationMote,
&pkt, sizeof(HashMsg)) == SUCCESS) {
call Leds.led0On();
busy = TRUE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){
if (len == sizeof(HashMsg)) {
HashMsg* hmpkt = (HashMsg*)payload;
if(hmpkt->flag==1){
a.hash=hmpkt->payload_hash;
}
}
return msg;
}
================================================
I can't compile it. the error is as follows: it said sth wrong with my
receive.receive event.
$ make telosb
mkdir -p build/telosb
compiling BlinkToRadioAppC to a telosb binary
ncc -o build/telosb/main.exe -Os -O -mdisable-hwmul -Wall -Wshadow
-Wnesc-all -
target=telosb -fnesc-cfile=build/telosb/app.c -board=
-DDEFINED_TOS_AM_GROUP=0x2
2 -I/opt/tinyos-2.x/tos/lib/printf -DIDENT_APPNAME=\"BlinkToRadioApp\"
-DIDENT_U
SERNAME=\"EIT\" -DIDENT_HOSTNAME=\"wsn\" -DIDENT_USERHASH=0xa200ffadL
-DIDENT_TI
MESTAMP=0x49a725ccL -DIDENT_UIDHASH=0x26925cc5L BlinkToRadioAppC.nc -lm
/opt/tinyos-2.x/tos/chips/cc2420/lpl/DummyLplC.nc:39:2: warning: #warning
"*** L
OW POWER COMMUNICATIONS DISABLED ***"
/opt/tinyos-2.x/tos/chips/msp430/usart/HplMsp430UsartInterrupts.nc: In
function
`BlinkToRadioC$Receive$receive':
/opt/tinyos-2.x/tos/chips/msp430/usart/HplMsp430UsartInterrupts.nc:49:
internal
error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html <http://gcc.gnu.org/bugs.html>> for
instructions.
make: *** [exe0] Error 1
==========================================================================
I know it is sth wrong with the struct. If I don't assign the received
message to the struct member as follows. It can be compiled. I am just
wonderig why it could have this kind of problem?
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){
uint64_t hash; //changed
if (len == sizeof(HashMsg)) {
HashMsg* hmpkt = (HashMsg*)payload;
if(hmpkt->flag==1){
hash=hmpkt->payload_hash; //changed
//a.hash=hmpkt->payload_hash; // original
}
}
return msg;
}
======================================================================================
Anyone can tell me what is the problem? Thanks in advance.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help