read write test for UART/RS232, debug via USB

Dependencies:   mbed

Fork of DataLoggerRS232trial by Terry Tam

Committer:
terrytamyh
Date:
Mon Jun 16 23:05:40 2014 +0000
Revision:
0:87fb6735eb09
Child:
1:875d121e9ce9
Sample RS232 class lib inherits Serial Class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
terrytamyh 0:87fb6735eb09 1 #include "mbed.h"
terrytamyh 0:87fb6735eb09 2 #include "DataLoggerRS232.h"
terrytamyh 0:87fb6735eb09 3
terrytamyh 0:87fb6735eb09 4 Serial pc (USBTX, USBRX); // tx, rx
terrytamyh 0:87fb6735eb09 5 DataLoggerRS232 dataLogger (p9,p10); // tx, rx
terrytamyh 0:87fb6735eb09 6
terrytamyh 0:87fb6735eb09 7 char DLcommand;
terrytamyh 0:87fb6735eb09 8
terrytamyh 0:87fb6735eb09 9 int main() {
terrytamyh 0:87fb6735eb09 10
terrytamyh 0:87fb6735eb09 11 pc.baud(115200);
terrytamyh 0:87fb6735eb09 12 pc.printf("PC and Datalogger serial set up complete !!\n\r");
terrytamyh 0:87fb6735eb09 13 dataLogger.baud(115200);
terrytamyh 0:87fb6735eb09 14 pc.printf("Here !!\n\r");
terrytamyh 0:87fb6735eb09 15
terrytamyh 0:87fb6735eb09 16 while(1) {
terrytamyh 0:87fb6735eb09 17 if(pc.readable()) {
terrytamyh 0:87fb6735eb09 18
terrytamyh 0:87fb6735eb09 19 dataLogger.count = 0;
terrytamyh 0:87fb6735eb09 20 DLcommand = pc.getc();
terrytamyh 0:87fb6735eb09 21 pc.printf("\n\r%c\n\r",DLcommand);
terrytamyh 0:87fb6735eb09 22
terrytamyh 0:87fb6735eb09 23 dataLogger.putc(DLcommand);
terrytamyh 0:87fb6735eb09 24 dataLogger.get_ECU_databyte();
terrytamyh 0:87fb6735eb09 25 }
terrytamyh 0:87fb6735eb09 26 dataLogger.display_ECU_databyte();
terrytamyh 0:87fb6735eb09 27 }
terrytamyh 0:87fb6735eb09 28 }