Hello,

I'm having a problem getting some code to work, where the application prints a message to the serial port, blocks while the uart transmits data, then prints another message. I don't know whether I'm misunderstanding the execution order or the use of atomic sections, but here's the scenario:

There's a module, MyDebugger, with the following interface:
async command error_t write(uint8_t *msg); /* writes message to uart0 */
async event void writeDone(); /* write complete */

This is tested and works fine. Basically just a wrapper around the UartStream provided by the Atm128 via PlatformSerial.

The problem is in my app:

bool blocking;

event void Boot.booted() {
  bool tb = TRUE;
  call MyDebugger.write("Booting, Part 1\r\n");
  while (tb) {
    atomic {
      tb = blocking;
    }
  }
  call MyDebugger.write("Booting, Part 2\r\n");
}

async event void MyDebugger.writeDone() {
  atomic {
    blocking = FALSE;
  }
}

Running this program, all I get is the first line of output:
Booting, Part1

But it looks like the while loop in Boot.booted() never terminates. The event handler is called. When I change it to:

async event void MyDebugger.writeDone() {
  bool tb;
  atomic {
    tb = blocking;
    blocking = FALSE;
  }
  if (tb) {
    call MyDebugger.write("Got here\r\n");
  }
}

Then I get:
Booting, Part 1
Got here

The while loop in Boot.booted() doesn't seem to pick up that the global variable 'blocking' has changed.

Any clue as to why the app can't print the "Booting, Part 2" line?

Thanks very much,

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

Reply via email to