qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
841 stars 274 forks source link

Better bi-directional support for BOCA printers #922

Open tresf opened 2 years ago

tresf commented 2 years ago

Quoting:

The default factory mode of BOCA Printer for USB is USB class 7. We have the ability to change this mode to USB HDI class 3 by sending a simple FGL command to printer.

In the BOCA manuel they say, there are 3 drivers mode and with spool bidirectional modes we could have all status informations .

Would you have a way to read easily these data ?

Printer Driver Modes

There are currently three modes for a Boca Systems FGL printer driver. Those Modes are:

  1. Spool – Unidirectional mode. This mode is used by most ticketing systems.
    The ticketing systems using this configuration use the spooler to print. This mode does not include reading status back from the printer. In this mode a printer can be set up as a shared network printer. It can also be reached from web applications.

  2. Direct – Bidirectional mode. This mode is used by ticketing systems that want to read all status generated by the FGL printer.
    With constant monitoring of the status, a ticketing system can always know the state of the printer before sending the next ticket.
    In this mode a printer can be used local to the PC only.

  3. Spool – Bidirectional mode. This is the default mode for the newest Boca Systems drivers. In this mode the spooler is used to write to the printer. A printer/port monitor is used to read status back from the printer and maintain some of the operating systems variables contained within the PRINTER_INFO_2 & PRINTER_INFO_6 structures. Ticketing systems can now read these variables to see when the printer is Ready, Jammed, Out of stock or Offline. In this mode a printer can be set up as a shared network printer and reached from web applications.

Driver modes 1 & 2 are available on all current Windows operating systems, such as Windows 7, 8.1, 10 and Server 2012 R2. Driver mode 3 is available on Windows 8.1 and 10. These modes correspond to which printer driver ports/advanced properties are currently selected as shown below.

In addition:

The possibility to get printer answers:

[BOCA] uses ReadPrinter method from winspool.drv to get printer answers.

[DllImport("winspool.Drv", EntryPoint = "ReadPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
.  public static extern bool ReadPrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwRead);
...

[Which is needed] to get printer remaining memory : when printing a lot of tickets, we send first tickets logo images to BOCA memory and then we send printing job with FGL raw data. Tickets FGL raw data contains only image memory references in BOCA memory. So the printing process is faster.

tresf commented 2 years ago

Some additional information:

For Information, I didn’t get BOCA printers errors status , when there were no more paper in BOCA printer.

I use Bi-directional spool driver mode, and according to your code and BOCA reference, error BOCA printer status should be sent. But I ‘ve got only OK Status from BOCA printer when there was no more paper.

This was my test : initially the printer was fed with paper :

  • The web page open connection with QZ-Tray and connect to BOCA printer
  • Web page sended a first successful print job
  • Web page sended a second fail print job (because of paper out) Below all the status I got from QZ Tray when sending print jobs to BOCA with no more paper: Maybe the reason is : because error status BOCA is sent to PRINTINFO_6 structure and not PRINTERINFO_2 structure?
tresf commented 2 years ago

In addition:

The possibility to get printer answers:

[BOCA] uses ReadPrinter method from winspool.drv to get printer answers.

[DllImport("winspool.Drv", EntryPoint = "ReadPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
.  public static extern bool ReadPrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwRead);
...

[Which is needed] to get printer remaining memory : when printing a lot of tickets, we send first tickets logo images to BOCA memory and then we send printing job with FGL raw data. Tickets FGL raw data contains only image memory references in BOCA memory. So the printing process is faster.