On 09:29 am, n...@craig-wood.com wrote:
Wolfgang Rohdewald <wolfg...@rohdewald.de> wrote:
 On Sunday 13 September 2009, Nadav Chernin wrote:
> I'm writing program that read data from some instrument trough
>  RS232. This instrument send data in VT100 format. I need only to
>  extract the text without all other characters that describe how to
>  represent data on the screen. Is there some library in python for
>  converting VT100 strings?

 that should be easy using regular expressions

At a basic level parsing VT100 is quite easy, so you can get rid of
the VT100 control.  They start with ESC, have other characters in the
middle then end with a letter (upper or lowercase), so a regexp will
make short work of them.  Something like r"\x1B[^A-Za-z]*[A-Za-z]"

You might need to parse the VT100 stream as VT100 builds up a screen
buffer though and the commands don't always come out in the order you
might expect.

I think twisted has VT100 emulator, but I couldn't find it in a brief
search just now.

Yep, though it's one of the parts of Twisted that only has API documentation and a few examples, no expository prose-style docs. If you're feeling brave, though:

http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalTransport.html

http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalProtocol.html

http://twistedmatrix.com/projects/conch/documentation/examples/ (the insults section)

It's not really all that complicated, but without adequate docs it can still be tricky to figure things out. There's almost always someone on IRC (#twisted on freenode) to offer real-time help, though.

Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to