pyserial - escape codes transportation

O

ObservantP

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()
 
G

Grant Edwards

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'
 
G

Grant Edwards

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

ObservantP

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.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top