I have embedded system which runs on linux. I need to send some strings from this system using python script to other device, which is visible as USB serial COM port. Both devices connected to the same PC and are visible as serial COM ports. The data lines is physically connected between the devices.
When I write to the terminal this line
echo Hello! > /dev/ttyS1
I am successfully receiving the message on another COM port (terminal). How I can do same transmission using python? I saw that is used subprocess module for this task, and I think if I could fit it successfully, I would just stay with it, because I don't need to install a third party libraries on a low resource embedded system.
Now what I was trying to do using this module, F.e. when I tried to run ls -l command using subprocess, I get the correct output in the open embedded system terminal:
import subprocess
subprocess.call(["ls", "-l"])
When an Echo command is launched
import subprocess
subprocess.call(["echo", "Hello!"])
print("Executed")
but how can I use echo Hello! > /dev/ttyS1
command in this python script? I tried to implement it analogously but not very successful.
question from:
https://stackoverflow.com/questions/65626286/send-strings-using-python-to-dev-tty 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…