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?
Current Status
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.
Background
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.