Suppose you want to offer an interface for other programmers, which allows them to write code like this:
# 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 could you implement it?
Current state
I first thought of pyserial , but it seems to treat the serial connection just as a file, similar to an object, and not like a terminal. I found from it the source code that pyserial itself uses termios , which at least seems to allow some terminal configuration options. But what structure allows terminal-like IO? Iβm just a newbie in the whole world of embedded systems in general, but so far it seems to me that an IO terminal through a serial connection should be a normal everyday problem in this environment, and there should already be a structure that performs βhard work.β But so far then I could not find him.
Background
Currently, most people in my company are checking their topics for developing an embedded system manually. But we want to switch to a more automatic script with a lot of unittest like scripts. Since we already have an interface like UART for our embedded systems, I would like to give the authors of these test scripts the opportunity to write code more intuitively, since in any case they could interact with devices through a minicomputer or screen.
erikbwork
source share