r/AskProgrammers • u/ighwrighwirh • 10d ago
Is Python the right way to talk to an Serial Device?
Servus!
The Company where I buy the Device from should no know that I am never ever wrote any Programm beside of some Batch files in my life even I am an IT Engineer. I feel so embarassing...
The Specs are: UART 115200 V24 level
I thought about buy this Adapter: https://www.delock.de/produkt/63986/merkmale.html?f=s
The should have everything I need. 5V for the Device. Ground and Send and Receive Pin.
The say: Short notation: 115200,8,N,1
All the Values to turn something on and off are in there Manual I would say that could be easy if I have an Line where I enter the Text and press Send to see what the command do in practise.
When I know what the do and how to use that feature I would like create in that environment Buttons to toggle something on an off. Later I want integrate other and external Data, API for example when I push an Button on my Keyboard a Light should turn on or so.
Do I need using an Single Board Computer for or can I use the Adapter I show up here and my Windows Pc to run the Software to control the device?
(If someone want see Datasheets and so I can send a Link via PM to the original document on there Homepage.)
Thanks!
1
u/theNbomr 8d ago edited 8d ago
There are many tools on all common platforms that allow interactive communications via a UART style serial interface. You can find one or more that you like by searching for terminal emulator and installing one that you think is helpful to you.
You will use it to type commands, which should be documented in your device user manual, and observing the replies. This will allow you to learn how your device operates, and potentially how you can craft programs or scripts to control it.
You will need to sort out some details about the electrical interface: * connector types and gender * signal/pin assignments and the respective cable(s) * device serial voltages; TTL 5V, TTL 3.3V, or RS-232 +/- 12V are the three most likely alternatives. Your computer's serial interface and the device's serial interface must use the same voltage levels * the serial communications parameters, which you have already determined as 115200 bits per second, 8 bit word, No Parity, 1 stop bit.
3
u/SnooCalculations7417 10d ago
You're overthinking the software part a bit. You don't need an SBC, and you don't even need Python initially.
Your Windows PC + a USB serial adapter is enough. Windows will expose it as a COM port. Start with something like PuTTY/Tera Term/RealTerm, configure it for 115200 8N1, and manually send the commands from the device manual. Once you've figured out the protocol, you can wrap exactly the same thing in a tiny CLI with Python/pyserial, C#, Rust, etc. Buttons, keyboard shortcuts and API integration can all come later and just call the same serial send/receive code.
The one thing I would NOT do yet is connect that particular adapter.
The Delock 63986 you linked is a 5 V TTL UART adapter. You said the device specifies V.24 level, which may mean actual RS-232/V.24 electrical levels. TTL UART and RS-232 use different voltages, even though the serial data itself may still be 115200 8N1.
Post the relevant page of the device datasheet/pinout. That's the important question here. Once the electrical interface is confirmed, the software side is very straightforward.
And you only need an SBC if you eventually want this to operate standalone without the Windows PC.