node-escpos / driver

🖨️ ESC/POS Printer driver for Node.js.
Other
318 stars 32 forks source link

usage getStatus and getStatuses functions #24

Closed saitahmety closed 1 year ago

saitahmety commented 2 years ago

I want to use getStatus function and when I call it as follows, PrinterStatus and other classes not exported. So, let printerStatus = printer.getStatus(PrinterStatus); // class type can't work

this exports can be added image

or let printerStatus = printer.getStatus("PrinterStatus"); // string type can't work this code can be added image

Or is there any other solution besides these ? How should I use getStatus() function ?

saitahmety commented 2 years ago

Moreover, getStatuses function does not return response when at least one of these 4 statuses is undefined. Because of "if (buffer.length < 4)" condition. image

But I want to get the other statuses even if the byte data of one status is undefined. When I remove "if (buffer.length < 4)" condition output like this, image

Can we remove this condition ?

Please revision code and release NPM. It's important for my project. Thanks for this awesome project.

felipeguimaraes2 commented 1 year ago

@saitahmety the printer must return all four statuses in this method if the memory switch 1-3 is set to "receive buffer full" from "receive buffer full or offline", as you can see here https://github.com/mike42/escpos-php/issues/43#issuecomment-389453232

"receive buffer full" => printer always responds "receive buffer full or offline" => printer does not respond in some situations such as cover open or paper out

After changing this memory switch, it always returns successfully.

But there is still a bug because the promise is not rejected when "receive buffer full or offline" is set, so I created a pull https://github.com/node-escpos/driver/pull/46 to solve it

saitahmety commented 1 year ago

Oh I got it, thank you so much @felipeguimaraes2 , solved on this https://github.com/node-escpos/driver/pull/46