3d Printer Hardware emulation, used to test some of my projects that require a real 3d printer response via USB serialport but without having the hardware available (mbed will reply to gcode commands - or any text+ENTER with an 'ok' ack data).

Revision:
0:fc0008071704
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 06 22:10:21 2012 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+//---------------------------------------------------------------------------------------------
+// USB serial port setup - debug messages
+//---------------------------------------------------------------------------------------------
+Serial pc(USBTX, USBRX); // tx, rx  
+
+//---------------------------------------------------------------------------------------------
+
+DigitalOut myled(LED1);
+
+//---------------------------------------------------------------------------------------------
+int main() {
+
+  int serialportdata = 0;
+
+  myled = 1;
+  wait(0.5);
+  myled = 0;  
+
+  //set communication speed
+  pc.baud(115200);
+  //test to see if comm is working
+  printf("ok\r\nok\r\n");
+  
+    while(1) {
+    
+        if(pc.readable()) {
+            serialportdata = pc.getc();
+             //printf("-> %c\r\n", serialportdata);
+            if( serialportdata == '\r' || serialportdata == '\n') {
+              printf("ok\r\n");
+              
+            }
+        }    
+    }
+}
+//---------------------------------------------------------------------------------------------
\ No newline at end of file