I also used the python-escpos library to get the paper status at first, but I always got an error, when I used the pySerial library to get the paper status, I found it works! I recommend you to use the pySerial library.
Here are some simple examples:
import serial
# connect your serial port
serialPort = serial.Serial(
port="COM2",
baudrate=115200,
bytesize=8,
parity="N",
stopbits=1,
timeout=1.00)
# Write a ESC/POS command to get the paper status
get_paper_roll_sensor_status= serialPort.write(b'\x10\x04\x04')
# Read the returned hexadecimal
paper_status = serialPort.read().hex()
# Print according to the hexadecimal value returned by the printer
if paper_status == "12":
print('Paper adequate')
elif paper_status == "1e":
print('Paper near-end is detected by the paper roll near-end sensor')
elif paper_status == "72":
print('Paper roll end detected by paper roll sensor')
elif paper_status == "7e":
print('Both sensors detect that the printer is out of paper')
else:
print('other unset values')
You can refer to here, the example I wrote before.