// This function implements HPLUART.put
task void cmdInterpret() {
struct RobotCmdMsg * cmd = (struct RobotCmdMsg *) msg->data;
// do local packet modifications: update the hop count and packet source
cmd->hop_count++;
cmd->source = TOS_LOCAL_ADDRESS;
// Interpret the command: Display the level on red and green led
if (cmd->hop_count & 0x1)
call Leds.greenOn();
else
call Leds.greenOff();
if (cmd->hop_count & 0x2)
call Leds.redOn();
else
call Leds.redOff();
// Execute the command
switch (cmd->action) {
case FORWARD_2:
call Leds.yellowToggle();
move = 'f';
break;
case FORWARD:
call Leds.yellowToggle();
move = 'g';
break;
case BACK_2:
call Leds.yellowToggle();
move = 'b';
break;
case BACK:
call Leds.yellowToggle();
move = 'c';
break;
case RIGHT_90:
call Leds.yellowToggle();
move = 'r';
break;
case RIGHT:
call Leds.yellowToggle();
move = 't';
break;
case LEFT_90:
call Leds.yellowToggle();
move = 'l';
break;
case LEFT:
call Leds.yellowToggle();
move = 'm';
break;
case STOP:
call Leds.yellowToggle();
move = 's';
break;
}
atomic
{
if(canSend)
{
atomic canSend = FALSE;
//call Leds.redToggle();
call HPLUART.put(move);
move = 'q';
call HPLUART.put(move);
}
}
pending =0;
signal ProcessCmd.done(msg, SUCCESS);
}
/**
* Initialization for the application:
* 1. Initialize module static variables
* 2. Initialize communication layer
* @return Returns <code>SUCCESS</code> or <code>FAILED</code>
**/
command result_t StdControl.init() {
msg = &buf;
pending = 0;
atomic canSend = TRUE;
call HPLUART.init();
return rcombine(call CommControl.init(), call Leds.init());
}
// This function is my HPLUART.get
async event result_t HPLUART.get(uint8_t data){
if (data ="" call SounderControl.start();
else call SounderControl.stop
}
Yvonne Kidd
_______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
