Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hi,
can anyone help with this code ? I am missing the first char form the PC with the code.
#include "mbed.h" #include <string> void Rx_interrupt(void); Serial term(USBTX, USBRX); // tx, rx DigitalOut bootup_led(LED1); DigitalOut config_led(LED2); DigitalOut pc_config_led(LED3); DigitalOut Irq_led(LED4); string rx_string = "\0"; int main() { term.baud(115200); term.attach(&Rx_interrupt, Serial::RxIrq); bootup_led = 1; while(true) { if(rx_string == "c" || rx_string == "C") { config_led = 1; } else { config_led = 0; } if(rx_string == "PC-CONFIG") { pc_config_led = 1; } else { pc_config_led = 0; } wait(1); term.printf("\x1B[2J"); //VT100 erase screen term.printf("\x1B[H"); //VT100 home term.printf("rx_string: %s\r\n", rx_string); } } void Rx_interrupt() { Irq_led = 1; volatile char rx_buffer; //volatile char rx_buffer_array[25]; volatile int rx_buffer_array_count = 0; rx_string.clear(); while(term.readable()) { rx_buffer = term.getc(); term.putc(rx_buffer); rx_string += rx_buffer; } wait_ms(200); Irq_led = 0; }