USB Printers - CUPS Printing
Plugged in Star SK1-311 roll tape printer used in Satellite enclosures
From a terminal type dmesg.
card825gen2:~$ dmesg ... [ 7953.117705] usb 1-1.4: new full-speed USB device number 8 using xhci-hcd [ 7953.326192] usblp 1-1.4:1.0: usblp0: USB Bidirectional printer dev 8 if 0 alt 0 proto 2 vid 0x0519 pid 0x004D [ 7953.326307] usbcore: registered new interface driver usblp
Verified it does work to print text to /dev/usb/lp0
825gen2 has CUPS (Common Unix Printing System)
lpinfo does show it
card825gen2:~$ /usr/sbin/lpinfo -v network socket network lpd network ipp network http direct usb://SANEI/SK1-311%20Presenter%20(STR-001) network dnssd://Canon%20TX-3000._ipp._tcp.local/?uuid=00000000-0000-1000-8000-001832104e5a network dnssd://Canon%20iPR%20Svr%20G250%20V2.1%20US(64%3A59%3AA5)._printer._tcp.local/ network dnssd://HP%20Designjet%20T520%2024in%20%5BD50233%5D._ipp._tcp.local/?uuid=abcd9e8e-4886-85c2-2167-b143d1c2344a network dnssd://HP%20LaserJet%20P2055dn%20%5B82FCF4%5D._pdl-datastream._tcp.local/ network dnssd://Lexmark%20C2240._ipp._tcp.local/?uuid=584bdd81-d230-49f3-a210-d39ac56492d0
To just show any usb printers
card825gen2:~$ /usr/sbin/lpinfo --include-schemes usb -v direct usb://SANEI/SK1-311%20Presenter%20(STR-001)
Some research showed that Star printer requires a CUPS driver. 1/5/2024 The Star SK1-311 CUPS driver was compiled for the 825gen2 and will be added to the next OS image.
card825gen2:~$ /usr/sbin/lpadmin -p STARSK1_311 -v usb://SANEI/SK1-311%20Presenter%20\(STR-001\) -m sk1-311_presenter.ppd lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
Found it necessary to run cupsaccept to set the printer up to accept jobs.
card825gen2:~$ /usr/sbin/cupsaccept STARSK1_311
card825gen2:~$ lpstat -W not-completed STARSK1_311-4 admin 115712 Wed Jan 10 16:30:21 2024
card825gen2:~$ lpstat -t scheduler is running no system default destination device for STARSK1_311: usb://SANEI/SK1-311%20Presenter%20(STR-001) device for STARSK311: usb://SANEI/SK1-311%20Presenter%20(STR-001) STARSK1_311 accepting requests since Wed Jan 10 16:29:32 2024 STARSK311 accepting requests since Wed Jan 10 16:06:30 2024 printer STARSK1_311 disabled since Wed Jan 10 16:29:32 2024 - reason unknown printer STARSK311 disabled since Wed Jan 10 16:06:30 2024 - reason unknown STARSK311-1 admin 1024 Wed Jan 10 16:25:01 2024 STARSK311-2 admin 3072 Wed Jan 10 16:25:55 2024 STARSK311-3 admin 115712 Wed Jan 10 16:27:30 2024 STARSK1_311-4 admin 115712 Wed Jan 10 16:30:21 2024 card825gen2:~$ /usr/sbin/lpadmin -p STARSK1_311 -E
card825gen2:~$ lpstat -t scheduler is running no system default destination device for STARSK1_311: usb://SANEI/SK1-311%20Presenter%20(STR-001) device for STARSK311: usb://SANEI/SK1-311%20Presenter%20(STR-001) STARSK1_311 accepting requests since Wed Jan 10 16:34:59 2024 STARSK311 accepting requests since Wed Jan 10 16:06:30 2024 printer STARSK1_311 is idle. enabled since Wed Jan 10 16:34:59 2024 Sending data to printer. printer STARSK311 disabled since Wed Jan 10 16:06:30 2024 - reason unknown STARSK311-1 admin 1024 Wed Jan 10 16:25:01 2024 STARSK311-2 admin 3072 Wed Jan 10 16:25:55 2024 STARSK311-3 admin 115712 Wed Jan 10 16:27:30 2024 STARSK1_311-4 admin 115712 Wed Jan 10 16:30:21 2024
card825gen2:~$ lp -d STARSK1_311 /home/admin/test.txt request id is STARSK1_311-5 (1 file(s))
Printed successfully - "test 123"
card825gen2:~$ lp -d STARSK1_311 /usr/images/icon_keyboard.bmp request id is STARSK1_311-6 (1 file(s))
Printed successfully but rotated and enlarged
card825gen2:~$ lp -d STARSK1_311 /usr/images/cardinal_logo.bmp request id is STARSK1_311-9 (1 file(s))
cardinal_logo.bmp
Printed successfully but rotated and enlarged
The Star printer driver seems to only work for BMP files. Tried other graphics formats such as PNG and JPEG but only black tickets printed.
There is some example code of cups printing on stackoverflow.com. This can be compiled for the 825. Some changes were needed to get it to work.
#include <stdio.h> #include <cairo.h> #include <cairo-ps.h> #include <cups/cups.h> #include "cairobmp.h" #define WIDTH 320 #define HEIGHT 500 int main(int argc, char** argv) { int n; char tmpFilepath[] = "/tmp/tktprtXXXXXX"; mkstemp(tmpFilepath); printf("tmpFilename [%s]\n", tmpFilepath); cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A1, WIDTH, HEIGHT); cairo_t *context = cairo_create(surface); LoadBMPToSurface("/usr/images/card_logo_bw.bmp", surface, 0, 0); // draw some text cairo_select_font_face(context, "Arial Black", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(context, 30); int x = 20; int y = 140; cairo_move_to(context, x, y); cairo_show_text(context, "Item 1"); y += 30; cairo_move_to(context, x, y); cairo_show_text(context, "Item 2"); y += 30; cairo_move_to(context, x, y); cairo_show_text(context, "Item 3"); // draw a dotted box const double pattern[] = {15.0, 10.0}; cairo_set_dash(context, pattern, 2, 0); cairo_set_line_width(context, 5); cairo_rectangle(context, 5, 105, 280, 300); cairo_stroke(context); // finish up cairo_show_page(context); cairo_destroy(context); cairo_surface_flush(surface); CairoSurfaceToBMP(surface, /*"/tmp/tkt9.bmp"*/ tmpFilepath); // n = cairo_surface_write_to_png (surface, "/tmp/tkt.png"); // printf("write_to_png result %d\n", n); cairo_surface_destroy(surface); const char* printerName = cupsGetDefault(); printf("printer [%s]\n", printerName); // cupsGetDefault is returning NULL printerName = "STARSK1_311"; n = cupsPrintFile(printerName, tmpFilepath, "cairo PS", 0, NULL); // return value is job ID printf("cupsPrintFile result %d\n", n); //unlink(tmpFilepath); return 0; }
Ticket produced by above example:
The CUPS web interface may also be used for monitoring of USB printers. Refer to Network Printing
Attachments (1)
- tkt.bmp (29.4 KB ) - added by 10 months ago.
Download all attachments as: .zip