[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip DripSend.h, NONE,
1.1 DripSendC.nc, NONE, 1.1 DripSendM.nc, NONE, 1.1
Gilman Tolle
gtolle at users.sourceforge.net
Fri Jun 10 12:18:16 PDT 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip/TestDrip
TestDrip.nc, 1.1, 1.2 TestDripM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip/TestDripSend
Makefile, NONE, 1.1 TestDripSend.h, NONE, 1.1 TestDripSend.nc,
NONE, 1.1 TestDripSendM.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2909
Added Files:
DripSend.h DripSendC.nc DripSendM.nc
Log Message:
DripSend is an interface to a single Drip channel (75) that provides the standard SendMsg, Send, and Receive interfaces. This is still pretty rough, but it's needed for the Clog component. (to come)
--- NEW FILE: DripSend.h ---
enum {
AM_DRIPSEND = 75,
};
typedef struct AddressMsg {
uint16_t source;
uint16_t dest;
uint8_t data[0];
} AddressMsg;
--- NEW FILE: DripSendC.nc ---
includes DripSend;
configuration DripSendC {
provides interface StdControl;
provides interface Send;
provides interface SendMsg;
provides interface Receive;
}
implementation {
components DripSendM;
components DripC;
components DripStateC;
components GroupManagerC;
StdControl = DripSendM;
StdControl = DripC;
Send = DripSendM;
SendMsg = DripSendM;
Receive = DripSendM;
DripSendM.DripReceive -> DripC.Receive[AM_DRIPSEND];
DripSendM.Drip -> DripC.Drip[AM_DRIPSEND];
DripC.DripState[AM_DRIPSEND] -> DripStateC.DripState[unique("DripState")];
DripSendM.GroupManager -> GroupManagerC;
}
--- NEW FILE: DripSendM.nc ---
module DripSendM {
provides interface StdControl;
provides interface Send;
provides interface SendMsg;
provides interface Receive;
uses interface Receive as DripReceive;
uses interface Drip;
uses interface GroupManager;
}
implementation {
enum {
DRIPSEND_OUTBUF_SIZE = TOSH_DATA_LENGTH - offsetof(DripMsg,data),
};
TOS_MsgPtr msgHolder;
uint8_t outBuf[DRIPSEND_OUTBUF_SIZE];
uint8_t outLength;
bool outBufBusy;
task void sendDoneTask();
command result_t StdControl.init() {
call Drip.init();
return SUCCESS;
}
command result_t StdControl.start() { return SUCCESS; }
command result_t StdControl.stop() { return SUCCESS; }
command void* Send.getBuffer(TOS_MsgPtr pMsg, uint16_t* length) {
DripMsg* dripMsg = (DripMsg*) &pMsg->data[0];
/* taken out for bridging
AddressMsg* addressMsg = (AddressMsg*) &dripMsg->data[0];
*length = TOSH_DATA_LENGTH -
offsetof(DripMsg,data) - offsetof(AddressMsg, data);
*/
*length = TOSH_DATA_LENGTH - offsetof(DripMsg,data);
return &dripMsg->data[0];
}
command result_t Send.send(TOS_MsgPtr msg, uint16_t length) {
// Does nothing.
return FAIL;
}
command result_t SendMsg.send(uint16_t dest, uint8_t length, TOS_MsgPtr msg) {
DripMsg* dripMsgIn = (DripMsg*) &msg->data[0];
AddressMsg* addressMsgIn = (AddressMsg*) &dripMsgIn->data[0];
AddressMsg* addressMsgOut = (AddressMsg*) &outBuf[0];
/* taken out for bridging
AddressMsg* addressMsgOut = (AddressMsg*) &outBuf[0];
DripMsg* dripMsgIn = (DripMsg*) &msg->data[0];
AddressMsg* addressMsgIn = (AddressMsg*) &dripMsgIn->data[0];
addressMsgOut->source = TOS_LOCAL_ADDRESS;
addressMsgOut->dest = dest;
memcpy(&addressMsgOut->data[0], &addressMsgIn->data[0], length);
*/
// dbg(DBG_USR1, "Addrmsg = %x, addrIn->dest=%d\n", &dripMsgIn->data[0],
// addressMsgIn->dest);
memcpy(addressMsgOut, addressMsgIn, length);
outLength = length;
msgHolder = msg;
dbg(DBG_USR1, "DripSendM: Sending a message to group %d\n",
addressMsgOut->dest);
call Drip.change();
post sendDoneTask();
return SUCCESS;
}
task void sendDoneTask() {
signal SendMsg.sendDone(msgHolder, SUCCESS);
}
event result_t Drip.rebroadcastRequest(TOS_MsgPtr msg, void *pData) {
AddressMsg* addressMsgOut = (AddressMsg*) &outBuf[0];
if (call GroupManager.isForwarder(addressMsgOut->dest)) {
dbg(DBG_USR1, "DripSendM: Forwarding a message for group %d\n",
addressMsgOut->dest);
memcpy(pData, &outBuf[0],
offsetof(AddressMsg,data) + outLength);
call Drip.rebroadcast(msg, pData, offsetof(AddressMsg,data) + outLength);
return SUCCESS;
} else {
return FAIL;
}
}
event TOS_MsgPtr DripReceive.receive(TOS_MsgPtr msg, void* payload,
uint16_t payloadLen) {
AddressMsg* addressMsgIn = (AddressMsg*) payload;
TOS_MsgPtr pMsg = msg;
// dbg(DBG_USR1, "DripSendM: Storing a message for group %d\n", addressMsgIn->dest);
memcpy(&outBuf[0], payload, payloadLen);
outLength = payloadLen;
if (call GroupManager.isMember(addressMsgIn->dest)) {
dbg(DBG_USR1, "DripSendM: Receiving a message dest=%d source=%d\n",
addressMsgIn->dest, addressMsgIn->source);
pMsg = signal Receive.receive(msg, &addressMsgIn->data[0],
payloadLen - offsetof(AddressMsg, data));
} else {
// dbg(DBG_USR1, "DripSendM: NOT receiving a message for group %d\n", addressMsgIn->dest);
}
return pMsg;
}
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip/TestDrip
TestDrip.nc, 1.1, 1.2 TestDripM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip/TestDripSend
Makefile, NONE, 1.1 TestDripSend.h, NONE, 1.1 TestDripSend.nc,
NONE, 1.1 TestDripSendM.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list