Serial's sample

07 Jan 2011
I am new for mbed and get a question about the following sample for serial 

#include "mbed.h"

Serial pc(USBTX, USBRX);
Serial uart(p28, p27);

DigitalOut pc_activity(LED1);
DigitalOut uart_activity(LED2);

int main() {
    while(1) {
        if(pc.readable()) {
            uart.putc(pc.getc());
            pc_activity = !pc_activity;
        }
        if(uart.readable()) {
            pc.putc(uart.getc());
            uart_activity = !uart_activity;
        }
    }
}


I think that the correct result is that a charactor inputed from terminal on PC will be send to uart, then send back to pc terminal, pc_activity and uart_activity will be on or off alternately.
Is my understanding correct?
But in my test, the charactor isn't sent back to pc's terminal and the uart_activity is always on. Anything wrong, pls suggest.
07 Jan 2011

Your understanding appears correct. The obvious question is have you connected p28 to p27 to form a loopback?

07 Jan 2011

Thanks so much, Andy! It works fine now.