Dear Jan amd TinyOS community,
I am working on the hash message transmission part of the Australia
government funded project. However I experienced some odd probelms related
to the interfaces you developed. Could you help me out what is wrong? I
can't see any problems. It could be something wrong with the interface you
designed. Thanks.
If anyone can help me out, it will be really appreciated.
Here is the code: in the main file.
#include <Timer.h>
#include "printf.h"
#include "sha1.h"
module App {
uses interface Boot;
uses interface Leds;
uses interface Timer<TMilli> as Timer0;
uses interface Packet;
uses interface AMPacket;
uses interface AMSend;
uses interface Receive;
uses interface SplitControl as AMControl;
uses interface sha1;
uses interface LocalTime<TMilli>;
}
implementation {
uint8_t sha1sum[20];
//uint64_t cmd=0x0000000000000000; //R XOR S=m
uint32_t destinationMote=0x00000002;
uint8_t message[8]={0};
uint8_t length=8;
message_t pkt;
SHA1Context ctx;
SHA1Context temp;
bool busy = FALSE;
uint8_t msg1=0;
event void Boot.booted() {
call AMControl.start();
}
event void AMControl.startDone(error_t err) {
if (err == SUCCESS) {
call Timer0.startOneShot(2000);
}
else {
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err) {
}
event void Timer0.fired() {
uint64_t R=0x0000000000000000; //R XOR S=m
uint64_t S=0x1234567890ABCDEF;
uint64_t M=0x0000000000000000;
uint64_t m=0x0000000000000000;
int i;
//uint64_t hash;
call Leds.led1On();
R=call LocalTime.get();
m=R^S^M;
for(i=0;i<8;i++){
message[i]=(uint8_t)(m&0x000000ff);
m>>=8;
}
//printf("m= %lx \n",m);
//printfflush();
//*message="abc";
call sha1.reset(&ctx);
call sha1.update(&ctx, message,length);
call sha1.digest(&ctx, sha1sum);
if(TOS_NODE_ID==0x00000001){
if (!busy) {
HashMsg* hmpkt =
(HashMsg*)(call Packet.getPayload(&pkt, sizeof(HashMsg)));
if (hmpkt == NULL) {
return;
}
hmpkt->flag=1;
hmpkt->nodeid = TOS_NODE_ID;
hmpkt->payload_MD1 = ctx.Intermediate_Hash[0];
hmpkt->payload_MD2 = ctx.Intermediate_Hash[1];
hmpkt->payload_MD3 = ctx.Intermediate_Hash[2];
hmpkt->payload_MD4 = ctx.Intermediate_Hash[3];
hmpkt->payload_MD5 = ctx.Intermediate_Hash[4];
hmpkt->payload_M=M;
hmpkt->payload_R=R;
if (call AMSend.send(destinationMote,
&pkt, sizeof(HashMsg)) == SUCCESS) {
//call Leds.led0On();
busy = TRUE;
}
}
}
}
event void AMSend.sendDone(message_t* msg, error_t err) {
if (&pkt == msg) {
busy = FALSE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){
uint32_t receivedMD[5]={0};
uint64_t receivedR=0;
uint64_t receivedM=0;
uint64_t receivedm=0;
uint64_t receivedS=0x1234567890ABCDEF;
int i;
HashMsg* hmpkt = (HashMsg*)payload;
receivedMD[0]=hmpkt->payload_MD1;
receivedMD[1]=hmpkt->payload_MD2;
receivedMD[2]=hmpkt->payload_MD3;
receivedMD[3]=hmpkt->payload_MD4;
receivedMD[4]=hmpkt->payload_MD5;
receivedR=hmpkt->payload_R;
receivedM=hmpkt->payload_M;
receivedm=receivedR^receivedM^receivedS;
for(i=0;i<8;i++){ //if I
removed this FOR part, i can compile it.
message[i]=(uint8_t)(receivedm&0x000000ff);
receivedm>>=8;
}
call sha1.reset(&temp);
call sha1.update(&temp, message,length);
call sha1.digest(&temp, sha1sum);
call Leds.led1On();
return msg;
}
}
If I removed the red highlight part, I can compile it otherwise I got the
errors as follows:
/opt/tinyos-2.x/tos/chips/msp430/usart/HplMsp430UsartInterrupts.nc: In
function
`App$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
Thanks.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help