Search code examples
macosprintingusbiokitthermal-printer

Xprinter xp-370b - print from OS X


I want to send message to thermal printer Xprinter xp-370b (connected through USB) from program that written for OS X.

I use IOKit. I can get interface of my printer IOUSBInterfaceInterface **usbInterface; and open it successfully (*usbInterface)->USBInterfaceOpen(usbInterface);.

Then I try to send a message, the result of WritePipe is successful, but nothing happens, printer doesn't react on it.

kern_return_t kr;
UInt8 pipe_ref = 0x01;
char message[] = "SELFTEST";
kr = (*usbInterface)->WritePipe(usbInterface, pipe_ref, message, sizeof(message));

Maybe there is some special format of commands for that printer?


Solution

  • Maybe there is some special format of commands for that printer?

    Yes, there's almost certainly some kind of binary messaging format you need to follow. USB based printers are typically nothing like the old LPT parallel port printers where you could simply pipe ASCII text down the port and get a useful result.

    You'll need the spec from the manufacturer, or the source code for the driver on another platform. Or in the worst case, reverse engineer the protocol by other means.