Assume you want to offer an interface for other programmers, that enables them to write code like that:
# connect to remote Linux device
>>> conn = myClass('/dev/ttyUSB0', 115200, '8N1')
>>> conn.login('myname', 'mypass')
>>> output = conn.command('ls -al')
>>> print output
total 3
drwxr-xr-x 49 myname myname 4096 Jun 21 15:13 .
drwxr-xr-x 4 root root 4096 Mar 20 14:43 ..
drwxr-xr-x 49 myname myname 1005 Jun 14 11:23 .vimrc
>>> output2 = conn.command('cd ..')
>>> print output2
>>>
How would you go about implementing it?
I first thought about pyserial, but it seems to treat the serial connection simply as a file like object, not like a terminal. I found from it's source code that pyserial itself uses termios, which at least seems to enable some terminal like configuration options. But which framework enables terminal-like IO? I'm just a beginner in this whole embedded system world in general, but until now it seems to me as if terminal IO via serial connection should be a common daily problem in this environment and there should be already a framework doing the "hard work". But till now I failed to find it.
At the moment most people in my company test their embedded system development topics manually. But we want to switch to a more automatic scenario with a lot of unittest
like scripting. Because we already have a terminal like interface per UART on our embedded systems I'd like to give the authors of those test scripts the opportunity to write code more intuitively as they would have interacted with the devices via minicom or screen anyway.
The serial console is a connection over the RS-232 or serial port connection that allows a person access to a computer or network device console. Usually, a console is accessed over an SSH connection.
Click the instance you want to connect to. Under Remote access, click Connect to serial console to connect on the default port (port 1). If you want to connect to another serial port, click the down arrow next to the Connect to serial console button and change the port number accordingly.
Baud Rate - In short, baud rate is how fast your data is being transmitted and received. 9600 is the standard rate, but other speeds are typical amongst certain devices.
I would strongly consider looking into Twisted and the projects using Twisted for Python projects talking to terminals. I have seen a terminal screen scraper written on Twisted, and at least one public telnet client on GitHub - https://github.com/fjogstad/twisted-telnet-client.
I'm not sure which terminal interface you are trying to talk to, but here at least is an example of a terminal emulator in Twisted: https://launchpad.net/python-tvi955.
A nice thing about using an asynchronous framework like Twisted would be that you could have one test server driving testing on several virtual machines or physical machines in parallel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With