Re: [Tinyos-help] Weird error when transmitting serial data

2007-08-24 Thread Hristo Bojkov
Hi Inderjit,

I think that it works when you have uint8_t* p; because for some reason you
have longer message than the length of TOS_Msg. Then only when you have
defined the pointer, you have enough space.

You have a check for valid length, and you compare with this expression 
MSG.length > TOSH_DATA_LENGTH
But then in the data filed you copy MSG.data and msg.type. 
If in the msg.length you have only length of the msg.data then your check is
not valid and after that with copy you use more space than is allocated by
definition of TOS_Msg tosMsg;

This can be checked easy. Just initialize p with value after lines with
memcopy and just before send. If I am right packets will contain the content
of p.


Cheers,
Hristo
 
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


[Tinyos-help] Weird error when transmitting serial data

2007-08-13 Thread Inderjit Singh
Hi,

I have a weird problem. I am running Tmote Sky with TinyOS 1.x app. I am
transmitting serial data with following function:


command result_t Comm.transmit(const COMM_Msg msg)
{
TOS_Msg tosMsg;
uint8_t* p;

//Valid msg type if sent by rfm?
if(msg.destAddr != COMM_SERIAL &&
(msg.type != COMM_MSG_TYPE_CONPACKET && msg.type !=
COMM_MSG_TYPE_DATPACKET))
return COMM_E_INVALID_TYPE;

//Valid length?
if(msg.length <= 0 || msg.length > TOSH_DATA_LENGTH)
return COMM_E_INVALID_LENGTH;

//Transmiiting?
if(mSending == TRUE)
return COMM_E_BUSY;

//Block all new transmission while sending
mSending = TRUE;

//Add message type
memcpy(tosMsg.data, &msg.type, sizeof(tMsgType));

//Add message
memcpy(tosMsg.data + sizeof(tMsgType), msg.data, msg.length);

//Add length
tosMsg.length = sizeof(tMsgType) + msg.length;

//Send the message
if(call Send.send(msg.destAddr, tosMsg.length, &tosMsg) != SUCCESS)
{
//Available for others to transmit
mSending = FALSE;

//Didn't succeed to transmit the package
return COMM_E_TRANS_FAILED;
}

return SUCCESS;
}


Now, this works fine. BUT if i  remove the statement (uint8_t* p) at the
top, i get strange data out. It's not doing anything anyway... Does anyone
know what is wrong???

Thanks

Inderjit
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help