I'm completely new to the ESC/POS thing, and I've looked around but couldn't find a solution to my problem. I'm trying to print a barcode using a generic USB POS-58 Thermal Printer, but all that shows up on the printer is the barcode data, not the barcode itself. The code I'm using is the following:
$barcode = "12345678901";
$handle = fopen('/dev/usb/lp0', 'w');
if (!$handle) {
echo 'Cannot open printer';
exit(0);
}
fwrite($handle, chr(hexdec('1D')).'f'.chr(0));
fwrite($handle, chr(hexdec('1D')).'H'.chr(2));
fwrite($handle, chr(hexdec('1D')).'h'.chr(60));
fwrite($handle, chr(hexdec('1D')).'w'.chr(2));
fwrite($handle, chr(hexdec('1D')).'k'.chr(1));
fwrite($handle, $barcode.chr(0));
fwrite($handle, chr(hexdec('0A')));
fclose($handle);
Please note that I'm using PHP but I get the same results using printf from the command line (or C). What I get on the printer is
12345678901
No barcode at all. Could it be possible that the printer doesn't support barcode printing? The "manual" is not very helpful, it just states that the printer is compatible with the ESC/POS command set. Am I missing something?