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).

Files at this revision

API Documentation at this revision

Comitter:
botdream
Date:
Tue Nov 06 22:10:21 2012 +0000
Commit message:
Demo prototype of MBED 3d printer hardware emulation

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 06 22:10:21 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file