I cannot print using Python.
I use the following code, copied from arduino example
import serial
ser = serial.Serial('/dev/serial0',
baudrate=19200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)
# Modify the print speed and heat
ser.write(27)
ser.write(55)
ser.write(7) # Default 64 dots = 8 *('7' + 1)
ser.write(255) # default 80 or 800us
ser.write(255) # default 2 or 20us
# Modify the print density and timeout
ser.write(18)
ser.write(35)
ser.write(255)
# print
ser.write(b'Hello World\n')
ser.write(10)
ser.close()
I can print from bash (echo “Hello” > /dev/serial0).
Also the combination 18 35 does not exists in the manual, what does it do ?
Also the combination 18 35 does not exists in the manual, what does it do ?
Unfortunately I’m not sure either, it may be something left over from an older version of the thermal printer that never got removed from the example code.
As for your code, I can’t debug that, but the following sequence of bytes will setup the printer and print a hello world message. These are in HEX, you will need to convert them to decimal for your code unless you can alter the code to make the conversion for you.
Setup:
1B 37 07 FF FF 12 23 FF
Hello World!
12345678901234567890123456789012
48 65 6C 6C 6F 20 57 6F 72 6C 64 21 0D 0A 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 0D 0A 0A 0A
Thanks for the immediate response.
the hex values you 've sent me are the the same values I used in decimal.
Still it doesnt print. It only prints the very first line of the text (view image below)
https://drive.google.com/file/d/1ExHmDv … sp=sharing
If I try to print more than 4 characters (not numbers) the printer just prints the very first line
https://drive.google.com/file/d/1G-hAZp … sp=sharing
echo 1 > /dev/serial0
echo 10 > /dev/serial0
echo 100 > /dev/serial0
echo 1000 > /dev/serial0
echo 10000 > /dev/serial0
echo a > /dev/serial0
echo ab > /dev/serial0
echo abc > /dev/serial0
echo abcd > /dev/serial0
echo abcde > /dev/serial0
echo abcdef > /dev/serial0
echo abcdefg > /dev/serial0
Anyway, I will go with Arduino. It works flawlessly on it.
Not sure what might be causing the issue in Python but I’m glad it works OK for you in Arduino.