read write test for UART/RS232, debug via USB

Dependencies:   mbed

Fork of DataLoggerRS232trial by Terry Tam

Revision:
0:87fb6735eb09
Child:
1:875d121e9ce9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DataLoggerRS232/DataLoggerRS232.cpp	Mon Jun 16 23:05:40 2014 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "DataLoggerRS232.h"
+
+
+DataLoggerRS232::DataLoggerRS232(PinName tx, PinName rx, const char* name) : Serial(tx, rx, name) {
+    printf("Here!! \r\n");
+    // set up ring buffer
+    ringBuffer = new char[65536];
+    // pointer to first sample 
+    rHead = ringBuffer;
+    // pointer to indicate position in the Ring Buffer
+    rPos = ringBuffer;
+    // pointer to indicate display position in the Ring Buffer
+    rDisplay = ringBuffer;
+    
+    printf("DataLogger_RS232 Ring Buffer setup complete!\r\n");
+}
+
+void DataLoggerRS232::get_ECU_databyte() {
+        
+        while(Serial::readable()) {
+            
+            MSserial = Serial::getc();
+                // save the sample into ring buffer
+                if( rPos == &ringBuffer[65535] )
+                rPos = ringBuffer;
+                else 
+                rPos++;
+            
+            *rPos = MSserial;
+            
+            count++;
+        }
+        printf("get_ECU_databyte !!\r\n");
+}
+
+void DataLoggerRS232::display_ECU_databyte() {
+        
+        while (rDisplay != rPos) {
+            printf("%d, %X\n\r",count,rDisplay);
+            if( rDisplay == &ringBuffer[65535] )
+                rDisplay = ringBuffer;
+                else 
+                rDisplay++;   
+        }
+        printf("display_ECU_databyte !!\r\n");
+}
+
+
+DataLoggerRS232::~DataLoggerRS232() {
+}
\ No newline at end of file