El dv 11 de 01 del 2008 a les 21:27 -0500, en/na [EMAIL PROTECTED]
va escriure:
> Hi All
>
> I wan't to implement static multihop i.e
>
> mote1 -> mote2 -> mote3 ->mote4
>
> -> means send packet
>
> I am using telosb
>
> If anybody has implemented please help me its urgent.
>
>
> regards
> Nazish
>
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
includes AM;
module trxM{
provides{
interface StdControl;
}
uses{
interface Timer;
interface BareSendMsg;
interface ReceiveMsg;
interface Leds;
interface StdControl as Control;
interface HPLUART;
}
}
implementation{
TOS_Msg datos;
TOS_Msg datosRecibidos;
TOS_MsgPtr buffer;
unsigned long num_datos_enviados; //32 bits = 4bytes
unsigned long num_datos_recibidos;
unsigned long num_datos_erroneos;
bool escrito;
char serie[33];
unsigned char* pserie;
int i;
int j;
command result_t StdControl.init(){
call Control.init();
call Leds.init();
datos.data[0] = 1;
datos.length = 1;
num_datos_enviados = 0;
num_datos_recibidos = 0;
num_datos_erroneos = 0;
buffer = NULL;
i = 0;
j = 0;
return SUCCESS;
}
command result_t StdControl.start(){
call HPLUART.init();
call Control.start();
call Timer.start(TIMER_REPEAT, 1000);
return SUCCESS;
}
command result_t StdControl.stop(){
call Control.stop();
call Timer.stop();
call HPLUART.stop();
return SUCCESS;
}
task void receiveTask(){
if (TOS_LOCAL_ADDRESS != 1){
if (buffer->data[0] == (TOS_LOCAL_ADDRESS -1)){
num_datos_recibidos++;
call Leds.yellowToggle();//AZUL
}else{
num_datos_erroneos++;
call Leds.redToggle();//ROJO
}
buffer->addr=TOS_LOCAL_ADDRESS+1;
buffer->length=1;
buffer->data[0] = TOS_LOCAL_ADDRESS;
call BareSendMsg.send(buffer);
}
}
task void sendDataHPLUARTTask(){
if (TOS_LOCAL_ADDRESS != 1){
call HPLUART.put('0'+buffer->data[0]);
}
}
event result_t Timer.fired(){
if(TOS_LOCAL_ADDRESS == 1){
datos.addr = TOS_LOCAL_ADDRESS+1;
datos.data[0] = ((uint8_t)TOS_LOCAL_ADDRESS);
call BareSendMsg.send(&datos);
//post sendDROkUART_task();
// call HPLUART.put('0'+pserie[i]);
}
return SUCCESS;
}
event result_t BareSendMsg.sendDone(TOS_MsgPtr m, result_t success){
uint8_t valor;
if (success == SUCCESS){
if(TOS_LOCAL_ADDRESS == 1){
valor = '0'+datos.data[0];
}else{
valor = '0'+buffer->data[0];
}
call Leds.greenToggle();//AMARILLO
//call HPLUART.put(valor);
num_datos_enviados++;
}else{//problema al enviar los datos
call Leds.redToggle();//ROJO
}
return SUCCESS;
}
event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m){
TOS_MsgPtr tmp;
uint16_t tempAddr;
tmp = buffer;
buffer = m;
tempAddr = TOS_LOCAL_ADDRESS;
if(tempAddr == buffer ->addr){
post receiveTask();
post sendDataHPLUARTTask();
}
return tmp;
}
async event result_t HPLUART.get(uint8_t Dato){
uint8_t ACIERTO = 0x55;
uint8_t ERROR = 0x56;
uint8_t ENVIO = 0x57;
if (Dato == ACIERTO){
//i=0;
pserie = (unsigned char *)&num_datos_recibidos;
//itoa((int)pserie[i],serie,16);
//call HPLUART.put(serie[0]);
//i++;
}else if(Dato == ERROR){
//i=0;
pserie = (unsigned char *)&num_datos_erroneos;
//itoa((int)pserie[i],serie,16);
//call HPLUART.put(serie[0]);
//i++;
}else if(Dato == ENVIO){
pserie = (unsigned char *)&num_datos_enviados;
}
if( (Dato == ACIERTO) || (Dato == ERROR) || (Dato == ENVIO)){
i=0;
itoa((int)pserie[i],serie,16);
call HPLUART.put(serie[0]);
i++;
}
return SUCCESS;
}
async event result_t HPLUART.putDone(){
if (i<4){
j = 0;
call HPLUART.put(serie[1]);
itoa((int)(pserie[i]),serie,16);
call HPLUART.put(serie[0]);
i++;
//j++;
}else{
if (j == 0){
call HPLUART.put(serie[1]);
j = 1;
}
}
return SUCCESS;
}
}
includes AM;
configuration trx{
}
implementation{
components Main, trxM, RadioCRCPacket, LedsC, TimerC, HPLUARTC;
Main.StdControl -> trxM.StdControl;
Main.StdControl -> TimerC.StdControl;
trxM.Leds -> LedsC.Leds;
trxM.Control ->RadioCRCPacket.Control;
trxM.Timer -> TimerC.Timer[unique("Timer")];
trxM.BareSendMsg -> RadioCRCPacket.Send;
trxM.ReceiveMsg -> RadioCRCPacket.Receive;
trxM.HPLUART -> HPLUARTC;
}
COMPONENT=trx
include $(MAKERULES)
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help