Mini Receipt Printer - Get Printer Status?
Moderators: adafruit_support_bill, adafruit

Mini Receipt Printer - Get Printer Status?

by stephanie on Thu Mar 22, 2012 9:18 am

I've got my mini thermal receipt printer working well with an Arduino Mega, the printer is wired to Serial2 on the mega and there's no problem with getting printouts from it.

So I decided to try and poll the printer for its status. As per the users manual, it says to send Esc v to get a status report back:
Code: Select all | TOGGLE FULL SIZE
Serial2.write(27);
Serial2.write(118);


I've tried this, and using this routine to read data back from the printer:
Code: Select all | TOGGLE FULL SIZE
if(Serial2.available()) {
  char report[10];
  char c;
  int pos=0;
  while(Serial2.available()) {
    c=Serial2.read();
    report[pos]=c;
    pos++;
  }
  report[pos]='\0';
  Serial.print("Printer status: ");
  Serial.println(report);
}

This routine is one I've used repeatedly with success, for Serial debugging, for reading data from an Xbee (on Serial3) and so forth.

When communicating with the thermal printer, I'm only getting back what appears to be a single space rather than the status report. (The manual says the report would be formated as P#V##T##, eg P1V72T30 = paper good, voltage 7.2, temperature 30 deg C).

So I'm wondering if anyone else has tried or succeeded in reading status information back from their printer?

Thanks!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: Mini Receipt Printer - Get Printer Status?

by adafruit on Thu Mar 22, 2012 12:10 pm

Oooh! thats nice. do you mind putting an Issue in on github? we'll add this to the library :)
User avatar
adafruit
 
Posts: 11779
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Mini Receipt Printer - Get Printer Status?

by stephanie on Thu Mar 22, 2012 2:00 pm

I would love to - if it worked! :)

That's my question though... I'm not getting status info back from the printer, though it *should* work.

I will keep fiddling and if i get a result I will post the resolution.
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: Mini Receipt Printer - Get Printer Status?

by adafruit on Thu Mar 22, 2012 3:37 pm

we'll take a look - you dont have to submit full working code to file an issue :)
User avatar
adafruit
 
Posts: 11779
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Mini Receipt Printer - Get Printer Status?

by stephanie on Thu Mar 22, 2012 4:19 pm

Ah sorry! I thought you were suggesting that I should submit the status code once it was working. :)

I have made some progress - the manual appears to be wrong in regards to getting the status data from it.

First it's inconsistent in that it refers to "esc v" and "esc v n" in different places, but "n" is never defined. However, I've run a test sketch sending n from 0 to 255, and found that it does not matter what n is, but you have to send the n or the printer won't do anything as it waits for that last byte.

Second, I've found through experimenting that where I thought it was responding with a 'space' it was actually sending a single byte of data that only happened to be Dec 32 - space.

In binary, 0b100000 is returned when the printer is ready to print. Take away the paper and it changes to 0b100100, so the 4's column is paper status, good=0 and bad=1.

I've tried varying the input voltage a little, but that did not change the status at all. Nor did changing the temperature. I know the printer has this info in it, as it prints it on the testpage! But it's not returning the data like it shows in the manual.

Still, at least there's a way to get the paper status out of it.

Asking for the auto-status does appear to work, but returns slightly different data. As per the manual I'm turning auto status on by sending 29, 97, 4. In this case, the printer immediately responds with a '0' (all good) then if I remove the paper I get a '0b100', so the auto-status reports do not include the 0x100000 bit, whatever that means.

Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: Mini Receipt Printer - Get Printer Status?

by adafruit on Fri Mar 23, 2012 10:53 am

could still be handy for something like the tweeting printer - it could flash the LED when paper runs out...
User avatar
adafruit
 
Posts: 11779
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Mini Receipt Printer - Get Printer Status?

by rivettim on Mon Dec 03, 2012 12:38 pm

Helloooooo,

I try to use the code you posted, but my printer when get the code keep get stuch without any datas on serial!!!!
Any help?
Should I've to post the code?

Thank youuuuuuuuuuu
Massimiliano
rivettim
 
Posts: 1
Joined: Mon Dec 03, 2012 12:35 pm