pyserial - escape codes transportation

Discussion in 'Python' started by ObservantP, Dec 11, 2009.

  1. ObservantP

    ObservantP Guest

    need help. newbie. pyserial and dot matrix printer.
    issue- escape codes arrive at printer ( verified from hex dump) but do
    not get applied.
    printer make/model STAR POS printer SP500.
    oddly, printer commands not initiated with the escape code .i.e. a
    symbol, work fine.


    import serial
    ser=serial.Serial(0)

    ser.bytesize=7
    ser.timeout=1
    ser.dsrdtr=1
    ser.write('PySerial'+'\n')
    ser.write('Star SP500'+'\n')



    #Double Width On 14 SO =  Or ESC W 1 / 0
    # Off 20 DC4= 

    ser.write('' +'Double Width-Symbol\n') #Good
    ser.write('' +'Reset\n') #Good
    ser.write('\n') #Good

    ser.write('Xw1\n'+'Double Width-ESC\n') #Nope ( Nor CHR(027)
    '\x1b'
    ser.write('Xw0\n'+'Reset\n') #X is symbol not
    showing up here.
    ser.write('\n')
    ser.write('\n')
    ser.write('\n')


    ser.close()
     
    ObservantP, Dec 11, 2009
    #1
    1. Advertising

  2. On 2009-12-11, ObservantP <> wrote:
    > need help. newbie. pyserial and dot matrix printer.
    > issue- escape codes arrive at printer ( verified from hex dump) but do
    > not get applied.


    What you're saying is your printer isn't working correctly.

    > printer make/model STAR POS printer SP500. oddly, printer
    > commands not initiated with the escape code .i.e. a symbol,
    > work fine.
    >
    >
    > import serial
    > ser=serial.Serial(0)
    >
    > ser.bytesize=7
    > ser.timeout=1
    > ser.dsrdtr=1
    > ser.write('PySerial'+'\n')
    > ser.write('Star SP500'+'\n')
    >
    >
    >
    > #Double Width On 14 SO =  Or ESC W 1 / 0
    > # Off 20 DC4= 
    >
    > ser.write('' +'Double Width-Symbol\n') #Good
    > ser.write('' +'Reset\n') #Good
    > ser.write('\n') #Good
    >
    > ser.write('Xw1\n'+'Double Width-ESC\n') #Nope ( Nor CHR(027)


    FWIW, that's _not_ sending an ASCII escape character. It's
    sending a string starting with a caret and a square bracket.

    I don't know what you're actually trying to send, but my guess
    is that you want is '\033w1' or '\x1Bw1'

    --
    Grant Edwards grante Yow! I'm also against
    at BODY-SURFING!!
    visi.com
     
    Grant Edwards, Dec 11, 2009
    #2
    1. Advertising

  3. On 2009-12-11, Grant Edwards <> wrote:
    > On 2009-12-11, ObservantP <> wrote:
    >> need help. newbie. pyserial and dot matrix printer. issue-
    >> escape codes arrive at printer ( verified from hex dump) but
    >> do not get applied.

    >
    > What you're saying is your printer isn't working correctly.


    BTW, I (among others) filter out all posts made from google
    groups. I only stumbled across your posting by accident while
    playing with my newsreader configuration. I won't see any
    follow-up postings you make if they're from google groups.

    --
    Grant Edwards grante Yow! ! Everybody out of
    at the GENETIC POOL!
    visi.com
     
    Grant Edwards, Dec 11, 2009
    #3
  4. ObservantP

    ObservantP Guest

    On Dec 11, 7:58 pm, Grant Edwards <> wrote:
    > On 2009-12-11, Grant Edwards <> wrote:
    >
    > > On 2009-12-11, ObservantP <> wrote:
    > >> need help. newbie. pyserial and dot matrix printer. issue-
    > >> escape codes arrive at printer ( verified from hex dump) but
    > >> do not get applied.

    >
    > > What you're saying is your printer isn't working correctly.

    >
    > BTW, I (among others) filter out all posts made from google
    > groups. I only stumbled across your posting by accident while
    > playing with my newsreader configuration.  I won't see any
    > follow-up postings you make if they're from google groups.
    >
    > --
    > Grant Edwards                   grante             Yow! !  Everybody out of
    >                                   at               the GENETIC POOL!
    >                                visi.com            


    Hi Grant

    Thanks for the tip.

    Had used the hex version alright.

    Looking again at the code, one realizes the difference between 'W' and
    'w'...

    Sorted. All is well. Delighted to get this resolved.

    John
     
    ObservantP, Dec 11, 2009
    #4
    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. Replies:
    1
    Views:
    4,636
    Jack Klein
    Jan 12, 2005
  2. Deepak
    Replies:
    1
    Views:
    1,260
    Mike Wahler
    Jan 11, 2005
  3. Replies:
    2
    Views:
    2,988
    Malcolm
    Aug 20, 2005
  4. slomo
    Replies:
    5
    Views:
    1,632
    Duncan Booth
    Dec 2, 2007
  5. linkswanted
    Replies:
    0
    Views:
    333
    linkswanted
    Jan 6, 2008
Loading...

Share This Page