I posted this ‘fix’ on Adafruits’ forum as well.
I have been playing with their mini Thermal Printer (https://www.adafruit.com/products/597).
I started testing the haspaper function in their thermal printer library which returns true if there is paper else false. In the library I have, it fails to detect paper out.
After researching the problem, the only comment I can find is this function is iffy. Might work, might not, depending on the printer.
That seemed kind of odd to me because the printer obviously knows paper is out – it flashes its LED 3 times fast to let the user know and if you attempt to print something, it will not let you print. So if the sensor is there, why wouldn’t they let the end-user sense it?
I found the datasheet for the printer (https://www.adafruit.com/datasheets/CSN-A2%20User%20Manual.pdf) and found the escape sequence to detect the printer status is <esc>v<null>. Looking at the code for hasprinter, they are sending <gs>r<null>.
<gr>r<null> is used to determine if the paper is nearly out. If there is no paper, it doesn’t indicate that.
I changed the escape sequence in the hasprinter function from
writeBytes(ASCII_GS, 'r', 0);
writeBytes(ASCII_ESC, 'v', 0);
Now the hasprinter() function in the Adafruit library works properly for me, letting me know when I’m out of paper.