Python Serial to Hardware [VIDEO]
Who the hell uses serial ports anymore?
Turns out...it's everywhere.
But our computers no longer have DB-9 connectors and native hardware to make the weird +/-12V signaling.
All the serial communication is still there, it's just encapsulated in USB now. Now in addition to knowing how to deal with serial comms, you have to know how to deal with USB.
A friend came to me with a straightforward goal "I want my computer to talk to serial hardware."
This problem aligns so nicely with the Lean Hardware Workshop, which is a 6-week course for software professionals to get real hardware skills. This is the type of problem that lives in both domains (hardware & software) and as we do good design, we'll see more of. Get ready.
Let's look at that technology stack to take our first baby step with this. We have:
- The underlying serial protocol with it's weird +/-12V physical layer.
- A manufacturer-specific ASIC that does serial-to-USB translation.
- The USB protocol (enumeration, device classes, physical layer).
- The operating system driver and the API presented to a programmer.
- Usually a library to interface with that API.
- Finally our application code, which has to be aware of the constraints from the rest of the tech stack.
Don't give up. It's not as bad as you think.
I made a short video to try to help.
In this video we take a first look at Python, and using the PySerial module for serial communications. We use the Linux OS to inspect the USB hardware and access the device with PySerial.
I also made a small loopback adapter to send the transmitted signal back into the receive channel for testing.
If you're starting out with serial comms (or Python) check out the video below. I hope it helps!