Re: VT100 in Python

Discussion in 'Python' started by Wolfgang Rohdewald, Sep 14, 2009.

  1. 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

    --
    Wolfgang
    Wolfgang Rohdewald, Sep 14, 2009
    #1
    1. Advertising

  2. Wolfgang Rohdewald

    Guest

    On 09:29 am, wrote:
    >Wolfgang Rohdewald <> 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
    , Sep 14, 2009
    #2
    1. Advertising

  3. Wolfgang Rohdewald

    Nobody Guest

    On Mon, 14 Sep 2009 04:29:57 -0500, Nick Craig-Wood wrote:

    > 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]"


    While this pattern is common, unfortunately there are some exceptions.

    Also, "vt100" has become a generic term for "terminal emulation". There
    is no guarantee that the OP actually wants to parse vt100 escapes and
    nothing else.
    Nobody, Sep 17, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Free Doc

    VT100

    Free Doc, Apr 30, 2004, in forum: C Programming
    Replies:
    1
    Views:
    528
    Martin Dickopp
    Apr 30, 2004
  2. Dominique Bouré

    Python and VT100

    Dominique Bouré, Mar 5, 2005, in forum: Python
    Replies:
    2
    Views:
    456
    Christos TZOTZIOY Georgiou
    Mar 6, 2005
  3. Daniele C.

    Curses for win32 with VT100/ANSI support

    Daniele C., May 20, 2006, in forum: C Programming
    Replies:
    48
    Views:
    1,562
    Dave Thompson
    Jun 8, 2006
  4. Jeff Silverman
    Replies:
    2
    Views:
    289
    Thomas Dickey
    Dec 29, 2005
  5. Grehom
    Replies:
    0
    Views:
    169
    Grehom
    Mar 17, 2008
Loading...

Share This Page