Friday 15 July 2011

python - Interacting programmatically with serial terminal -


Assume that you want to provide an interface for other programmers, which helps them write code:

  # connect to remote Linux device & gt; & Gt; & Gt; Conn = myClass ('/ dev / ttyUSB0', 115200, '8N1') & gt; & Gt; & Gt; Conn.login ('myname', 'mypass') & gt; & Gt; & Gt; Output = conn.command ('ls -al')> gt; & Gt; & Gt; Print output total 3 drwxr-xr-x 49 myname myname 4096 Jun 21 15:13. Drwxr-xr-x 4 root route 4096 March 20 14:43 .. drwxr-xr-x 49 myname myname 1005 June 14 11:23 .vimrc & gt; & Gt; & Gt; Output2 = conn.command ('cd ..') & gt; & Gt; & Gt; Print Output 2 & gt; & Gt; & Gt;   

How would you go about implementing it?

current situation

I thought earlier, but it seems that the serial connection to behave as a file like an object, not like the terminal. I have found from its source code that uses pyserial , which seems to enable at least some of the terminal to be configured as configuration options, but which framework enables IO like a terminal ? I am simply starting the world of this embedded system in general, but till now I feel like there should be a normal daily problem in this environment through Terminal IO serial connection and already "hard work" But till now I have failed to find it.

Background

Most of my company's people currently have their own embedded system development topics But we want to switch to a more automated scenario with scripting like much more unittest , because we already have a terminal like our URIent interface on our embedded system, I want to give writers of those test scripts an opportunity to write code more readily because they will interact with devices through minicom . screen Anyway.

I have a twisted project that I talk to Python terminals with a terminal Screen Scraper is seen, and at least one public Telnet client - on

I'm not sure which terminal interface you are trying to talk to, but here's an example of a terminal emulator in the least twisted.

A good thing about using one twisted asynchronous framework will be that you can test a test server in parallel on multiple virtual machines or physical machines.

No comments:

Post a Comment