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).
main.cpp
- Committer:
- botdream
- Date:
- 2012-11-06
- Revision:
- 0:fc0008071704
File content as of revision 0:fc0008071704:
#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"); } } } } //---------------------------------------------------------------------------------------------