Home |
Printer Class Driver AX772/AX178 and AX172 USB-Ethernet Drivers |
Printer Class DriverThe printer driver supports all USB printers using USB class 7 (Printer), subclass 1, and protocol 1 or 2 (uni- or bidirectional). Up to four printers can be operated simultaneously; additional printers are ignored. The driver is registered using its callback USBPrinter. USBPrinterInfo can be called to return a string with information about an attached printer. USBPrinterStatus returns the current printer status. USBPrinterInit can be used to initialize and reset a printer. USBPrintData sends data to print to a printer and USBPrintCancel cancels all pending print jobs. Example:int main(void) { RTURegisterCallback(USBKeyboard); // include USB keyboard driver RTURegisterCallback(USBPrinter); // and USB printers FindUSBControllers(); // start USB RTUWaitInitialEnumDone(); // wait until the USB stack has // found all attached devices int PrinterIndex = 0; const char * PInfo = USBPrinterInfo(PrinterIndex); if (PInfo == NULL) { printf("sorry, no printer found\n"); exit(1); } else printf("Printer info: %s\n", PInfo); // let's assume the printer can print ASCII data. const char * Hello = "Hello, USB Printer!\n\f"; BYTE Result = USBPrintData(PrinterIndex, Hello, strlen(Hello), 5000); if (Result & USB_PRN_OUT_OF_PAPER) printf("Out of paper\n"); if (Result & USB_PRN_TIMEOUT) printf("timeout\n"); // could do a retry here if (Result & USB_PRN_IO_ERROR) printf("I/O error or printer disconnected\n"); if ((Result & USB_PRN_SELECTED) == 0) printf("printer offline?\n"); return 0; } The RTUSB-32 Reference Manual contains additional information about the driver's API.
|