Open onurerdog4n opened 2 years ago
Hello. (might help)
As far I know at the moment CUPS server should be already installed on your machine and you should be able to use cups driver, if not first install CUPS server https://github.com/apple/cups. If your printer support you could even use Ethernet / LAN driver.
If CUPS installed mine advice enable CUPS web interface it will give you more details about jobs, printers etc. After enabling it should be accessible using: http://localhost:631/printers/
cupsctl WebInterface=yes
To use CUPS driver make sure printer is connected and added to the device (Mac) (it should be listed in Preferences > Printers & Scanners) if printer not listed you should add it manually. Or event install printer drivers first.
CUPS driver requires you to use printer name in snake format to get correct name use this or check Web interface:
lpstat -v
Example output:
device for CUSTOM_Engineering_VKP80III: usb://.....
device for Kyocera_ECOSYS_M2135dn: dnssd://......
device for PRP_300: socket://.....
Hi. So after getting the printer name, how do I use it for the connection? After running lpstat -v
I'm getting:
device for EPSON_TM_T20III: usb://EPSON/TM-T20III?serial=583741542995820000
I've tried doing:
$connector = new FilePrintConnector("usb://EPSON/TM-T20III?serial=583741542995820000");
$printer = new Printer($connector);
$printer->text("Hello World!\n");
$printer->cut();
$printer->close();
and also
$connector = new FilePrintConnector("EPSON_TM_T20III");
$printer = new Printer($connector);
$printer->text("Hello World!\n");
$printer->cut();
$printer->close();
but none of them work.
I'm on MacOS 14 and using a Epson TM-T20iii connected via USB.
Hi. So after getting the printer name, how do I use it for the connection? After running
lpstat -v
I'm getting:device for EPSON_TM_T20III: usb://EPSON/TM-T20III?serial=583741542995820000
I've tried doing:
$connector = new FilePrintConnector("usb://EPSON/TM-T20III?serial=583741542995820000"); $printer = new Printer($connector); $printer->text("Hello World!\n"); $printer->cut(); $printer->close();
and also
$connector = new FilePrintConnector("EPSON_TM_T20III"); $printer = new Printer($connector); $printer->text("Hello World!\n"); $printer->cut(); $printer->close();
but none of them work.
I'm on MacOS 14 and using a Epson TM-T20iii connected via USB
Hi, as far I know on Mac only CUPS connector works since it uses CUPS. CUPS connector example:
<?php
/* Change to the correct path if you copy this example! */
require __DIR__ . '/../../vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
try {
$connector = new CupsPrintConnector("EPSON_TM-T20");
/* 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";
}
I don't know exactly about Mac, in Linux (other alike Unix OS, with cups server) escpos not need to be configured at cups server. When I want to print into a escpos printer I wrote directly to /dev/lp0 or /dev/USB/lp0
On Tue, Feb 27, 2024, 8:15 PM Ernestas V. @.***> wrote:
Hi. So after getting the printer name, how do I use it for the connection? After running lpstat -v I'm getting:
device for EPSON_TM_T20III: usb://EPSON/TM-T20III?serial=583741542995820000
I've tried doing:
$connector = new FilePrintConnector("usb://EPSON/TM-T20III?serial=583741542995820000"); $printer = new Printer($connector); $printer->text("Hello World!\n"); $printer->cut(); $printer->close();
and also
$connector = new FilePrintConnector("EPSON_TM_T20III"); $printer = new Printer($connector); $printer->text("Hello World!\n"); $printer->cut(); $printer->close();
but none of them work.
I'm on MacOS 14 and using a Epson TM-T20iii connected via USB
Hi, as far I know on Mac only CUPS connector works since it uses CUPS. CUPS connector example: https://github.com/mike42/escpos-php/blob/development/example/interface/cups.php
<?php/ Change to the correct path if you copy this example! /require DIR . '/../../vendor/autoload.php';use Mike42\Escpos\Printer;use Mike42\Escpos\PrintConnectors\CupsPrintConnector; try { $connector = new CupsPrintConnector("EPSON_TM-T20");
/* 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"; }
— Reply to this email directly, view it on GitHub https://github.com/mike42/escpos-php/issues/1209#issuecomment-1967426159, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECF5AFAVJDYFV7T5VQRQ6TYVYWFBAVCNFSM6AAAAAAQUOTCGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRXGQZDMMJVHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I updated my code to use $connector = new CupsPrintConnector("EPSON_TM-T20");
but now it's throwing the following error:
Command lpstat -a failed: sh: 1: lpstat: not found
what's weird is that if I run un my terminal lp -d EPSON_TM_T20III tmp.txt
the printer works and outputs the contents of the file.
lpstat -a
works as well in the terminal:
lpstat -a ✔
EPSON_TM_T20III accepting requests since Tue Feb 27 13:20:53 2024
any suggestions?
Never mind, I know what the issue is. The problem is that I'm running my app in a Docker container, I'm not running it directly on MacOs, so lpstat
does work when I run it in the MacOS terminal, but once I access the docker container and I run it then I'm getting the error:
bash: lpstat: command not found
which makes sense. Any idea how to get around this?
Thanks
If you are in docker you can work via ssh to fiscal machine just like you need to generate keys for authenticate without asking passwords and connect manually on time for confirm that connection function ticket_print_command($filename){ //production mode? $tipo_arxiu = shell_exec("ssh rphysichost \"udevadm info -a -n /dev/usb/lp0 | grep product\""); if (preg_match('/Receipt Printer/', $tipo_arxiu)) exec ("ssh physichost \"cat {$_SERVER['DOCUMENT_ROOT']}/scale/$filename
/dev/usb/lp0\""); else { //debugtelegram("No he pugut imprimir a $tipo_arxiu"); $tipo_arxiu = shell_exec("ssh physichost \"udevadm info -a -n /dev/usb/lp1 | grep product\""); if (preg_match('/Receipt Printer/', $tipo_arxiu)) exec ("ssh physichost "cat {$_SERVER['DOCUMENT_ROOT']}/scale/$filename /dev/usb/lp1\""); //else debugtelegram("No he pugut imprimir a $tipo_arxiu"); }
Missatge de Ongo Gablogian @.***> del dia dc., 28 de febr. 2024 a les 3:30:
Never mind, I know what the issue is. The problem is that I'm running my app in a Docker container, I'm not running it directly on MacOs, so lpstat does work when I run it in the MacOS terminal, but once I access the docker container and I run it then I'm getting the error: bash: lpstat: command not found
which makes sense. Any idea how to get around this?
Thanks
— Reply to this email directly, view it on GitHub https://github.com/mike42/escpos-php/issues/1209#issuecomment-1968076292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECF5AETNXJQNAXVXSTONDTYV2JDBAVCNFSM6AAAAAAQUOTCGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGA3TMMRZGI . You are receiving this because you commented.Message ID: @.***>
I want to use ESCpos on localhost on my mac. Only which file should I use ( cups.php , linux-usb.php ... )
The error I get in cups.php Couldn't print to this printer: 'USB_Receipt_Printer' is not a printer on this system. Printers are: [USB_Receipt_Printer,]
What do I need to do to use it on Macos device?