mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.53k stars 860 forks source link

Star TSP100 (143IIIU) USB Printer Not Working #916

Open RYoder97 opened 4 years ago

RYoder97 commented 4 years ago

Hello. I'm using a Star USB TSP100 futurePRNT printer and Ubuntu 19.04.

I made sure to give my apache permission to access /dev/usb/lp0, but when I run my file via the terminal, nothing happens.

Here is the code I was using:

<?php
/* Call this file 'hello-world.php' */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
use Mike42\Escpos\CapabilityProfile;
$connector = new FilePrintConnector("/dev/usb/lp0");
$profile = CapabilityProfile::load("SP2000");
$printer = new Printer($connector,$profile);

$printer -> initialize();
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();
?>

I also tried via CUPS as well. Here is the CUPS code:

<?php
/* Change to the correct path if you copy this example! */
require __DIR__ . '/../../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\CupsPrintConnector;

try {
    $connector = new CupsPrintConnector("TSP143");

    /* Print a "Hello world" receipt" */
    $printer = new Printer($connector);
    $printer -> text("Hello World!\n");
    $printer -> cut();

    /* Close printer */
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
?>

With the CUPS code, I get a toast notification that says it's printing, but still nothing happens.

I've made sure to set the paper size correctly in CUPS, and am using the SP2000 profile for the standard USB. I've also installed the drivers for the TSP143 by using the PPD with CUPS and by running the installer for the drivers provided by Star. The printer shows up under my connected printers in settings.

Any clear reason why this isn't working? I copied/pasted the hello world code almost verbatim. I added the initialization line just in case. Does the CUPS connector need a capability profile?

RYoder97 commented 4 years ago

I also just tried printing from Chrome, just something random. Still get a notification saying it's printing but no luck. Am I missing something with printer installation?

RYoder97 commented 4 years ago

Update:

Tried printing using USB on a Raspberry Pi Zero using /dev/usb/lp0.

While the script returns/throws no errors, receipt printer is still unresponsive and does nothing. I am running the script via the command line as "php index.php".

Does the printer actually need to be "installed" using the typical Linux GUI before running the script, or does this software function as the driver itself?

<?php
/* Change to the correct path if you copy this example! */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;

/**
 * On Linux, use the usblp module to make your printer available as a device
 * file. This is generally the default behaviour if you don't install any
 * vendor drivers.
 *
 * Once this is done, use a FilePrintConnector to open the device.
 *
 * Troubleshooting: On Debian, you must be in the lp group to access this file.
 * dmesg to see what happens when you plug in your printer to make sure no
 * other drivers are unloading the module.
 */
try {
    // Enter the device file for your USB printer here

    $profile = CapabilityProfile::load("SP2000");
    $connector = new FilePrintConnector("/dev/usb/lp0");
    //$connector = new FilePrintConnector("/dev/usb/lp1");
    //$connector = new FilePrintConnector("/dev/usb/lp2");

    /* Print a "Hello world" receipt" */
    $printer = new Printer($connector,$profile);
    $printer -> text("Hello World!\n");
    $printer -> cut();

    /* Close printer */
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}

?>
RYoder97 commented 4 years ago

Update: Took a screenshot of terminal "usb-devices" to show that printer is connected, and driver=lp.

modprobe usblp doesn't return anything in the terminal, meanwhile insmod usblp says there is no such file or directory. I've seen usblp discussed in regards to the Raspberry Pi, so it should be included in the kernel. Trying to echo anything to the printer from the terminal also does nothing. :(

image

RYoder97 commented 4 years ago

Update: I dug around in CUPS and found that every test job I sent to it (even as root) says 'stopped "Filter failed"'. Is there an issue with the driver?

olizyusuf commented 1 year ago

i have client who use TSP143 and with OS linux, i tried tsp143 USB cant sent esc/pos direct from usb at os linux, but you can instal cups driver but you still cant direct sent command esc/pos for this printer, if you using image print you can print via driver cups. Available direct print esc/pos using os windows, may you replace printer TSP143 to BSC10 series or TSP655 series to sent via dev/usb/lp0.