Hi,
 
I am trying to implement a two way uart communication.  I am communicating between a PIC microcontroller and a mote.  My application works fine with using HPLUART.put.  I have tested the serial communication and the PIC does send bytes to the mote and the mote does act accordingly, using HPLUART.get.  However when I try to use code that implements both HPLUART.put and HPLUART.get I get no communication to the PIC at all.  Below is some of my code listing.  Is it possibly a problem with asynchronous use of HPLUART.get?
 

// 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
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to