3D Printer as Serial Communication Test Device
Reading about novel programming patterns and contemplating unexpected hardware platform potential are great... but none of it is real until I sit down and make some code run. Since my motivation centered around controlling external peripherals via serial port, I'll need a piece of hardware to experiment against. In the interest of reducing variables, I didn't want to start with one of my own past projects. I expect to run into enough headaches debugging what went wrong, I don't need to wonder if the problem is my code or my project hardware.
So what do I have sitting around at home that are serial controlled hardware? The easy answer is the brains of a 3D printer. And the most easily accessible item is my MatterHackers Pulse XE printer, which is conveniently sitting on the same table as the computer.
In order to get an idea of what I'm getting into, I connected to the printer via serial port terminal of PuTTY. I saw that a greeting message is sent out via serial as soon as I connected. This is great, because it meant I have some data to read immediately upon connect, no need to worry about sending a command before getting a response.
Moving to the development platform, I loaded up the UWP example program Custom Serial Device Access. After reading the source code to get a rough feel of what the application did, I compiled and ran it. It was able to enumerate the USB serial connection, but when I connect, I did not see the greeting message. Even though the parameters I used for PuTTY (250000 N 8 1) were also used here.
As tempting as it might have been to blame the example program and say it is wrong, I thought it was more likely that one of the other parameters of SerialDevice
had to be changed from their default value. Flipping settings one by one to see if they change behavior, I eventually figured out that I needed to set IsDataTerminalReadyEnabled
to true
in order to receive data from a Pulse XE. I'm lucky it was only a single boolean value I had to change because if I had to change multiple values to a specific combination, there would have been too many possibilities to find by trial and error.
It's always good to start as simple as possible because I never know what seemingly basic issue would crop up. IsDataTerminalReadyEnabled
wasn't even the only surprise I found, ReadTimeout
behavior was also unexpected.