read write test for UART/RS232, debug via USB
Dependencies: mbed
Fork of DataLoggerRS232trial by
Diff: main.cpp
- Revision:
- 1:875d121e9ce9
- Parent:
- 0:87fb6735eb09
- Child:
- 2:6ebf09171de9
diff -r 87fb6735eb09 -r 875d121e9ce9 main.cpp --- a/main.cpp Mon Jun 16 23:05:40 2014 +0000 +++ b/main.cpp Wed Sep 14 10:32:49 2016 +0000 @@ -2,15 +2,15 @@ #include "DataLoggerRS232.h" Serial pc (USBTX, USBRX); // tx, rx -DataLoggerRS232 dataLogger (p9,p10); // tx, rx +DataLoggerRS232 dataLogger (PA_2,PA_3); // tx, rx char DLcommand; - +char DLcommand2; int main() { pc.baud(115200); pc.printf("PC and Datalogger serial set up complete !!\n\r"); - dataLogger.baud(115200); + dataLogger.baud(9600); pc.printf("Here !!\n\r"); while(1) { @@ -23,6 +23,22 @@ dataLogger.putc(DLcommand); dataLogger.get_ECU_databyte(); } - dataLogger.display_ECU_databyte(); + //dataLogger.display_ECU_databyte(); + wait(2); +//----------------------------------------------- + if(dataLogger.readable()) { + + dataLogger.count = 0; + DLcommand = dataLogger.getc(); + DLcommand2 = dataLogger.getc(); + pc.printf("\n\r%c\n\r",DLcommand); + pc.printf("\n\r%c\n\r",DLcommand2); + dataLogger.putc(DLcommand); + dataLogger.get_ECU_databyte(); + } + dataLogger.display_ECU_databyte(); + + wait(2); + } } \ No newline at end of file