2

I am trying to use SGD commands on Zebra 420 USB printer.

printf "! U1 getvar \"device.languages\"\r\n" | lpr -P myprinter -o raw 

I expect this will print current lang value, but getting empty string. How to properly send command and receive response?

UPDATE: some dmesg related info

[    2.912815] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
[    3.048399] usb 1-1.3: New USB device found, idVendor=0a5f, idProduct=0065
[    3.057429] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.066719] usb 1-1.3: Product: ZTC ZM400-200dpi ZPL
[    3.073649] usb 1-1.3: Manufacturer: Zebra Technologies
[    3.080757] usb 1-1.3: SerialNumber: XXX999999
[    3.931237] udevd[156]: starting version 175
[    6.294509] bcm2835-rng 20104000.rng: hwrng registered
[    8.580407] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    8.934595] random: lpinfo urandom read with 87 bits of entropy available
[    9.215446] usblp 1-1.3:1.0: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x0A5F pid 0x0065
[    9.235924] usbcore: registered new interface driver usblp

[   31.371525] usblp0: removed
[   31.441360] usblp 1-1.3:1.0: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x0A5F pid 0x0065
[   31.835757] warning: process `colord-sane' used the deprecated sysctl system call with 8.1.2.

UPDATE 2: print to usb device

root@raspberrypi:/home/pi# printf “! U1 getvar \“device.languages\“\r\n” > /dev/usb/lp0
Pablo
  • 245
  • 3
  • 15
  • 1
    `lpr` sends a job to the printing system. It doesn't communicate directly with the printer. If you want a response from the printer, you need to communicate the printer directly, not through the printing system. – Gilles 'SO- stop being evil' Aug 03 '17 at 23:14
  • I would be more than happy to know how to communicate directly. There is Windows utility which has "send to printer" function, but Windows is not option for me. – Pablo Aug 04 '17 at 05:59
  • How to communicate with the printer depends on which driver is used (and it's not fun, and may not be easily possible). What additional lines appear in the output of `dmesg` after you plug in the USB cable of the printer? – dirkt Aug 08 '17 at 08:11
  • @dirkt: I've updated my answer with some `dmesg` lines. I don't specifically install any driver. If you tell me how to find out, then I can tell. CUPS is installing it as raw socket printer. Do you think `usblp0` is the driver name? – Pablo Aug 08 '17 at 13:44
  • Ok, the driver is `usblp`. I have no personal experience with it, but I assume you should see a `usblp0` file (actually a device node) somewhere under `/dev`, and if you redirect output to this device node (together with `cat`, `echo`, `printf` etc.), you should be able to talk directly to the printer. You may still have to escape the SGD commands somehow, or first send some command sequence to make the printer accept SGD commands. – dirkt Aug 08 '17 at 13:54
  • @dirkt: I've updated question with an attempt, which unfortunately returned nothing... Not sure what command will help him accept SGD. – Pablo Aug 08 '17 at 14:08
  • Best idea I can think of at the moment is to get (borrow etc.) a Windows machine, install the utility with "send to printer" function, and capture USB traffic ([USBsnoop](http://lindi.iki.fi/lindi/usb/usbsnoop.txt), [USBcap](http://desowin.org/usbpcap/) etc.) to find out how the utility encodes it. Anything else requires lucky guesses. :-) – dirkt Aug 08 '17 at 14:25
  • Hi, did you get this working yet? – sulaiman sudirman Oct 11 '17 at 11:31
  • @sulaiman: nope, still looking for solution – Pablo Oct 11 '17 at 12:24
  • Okay nevermind. I'm just sending it using cordova library. I just need to run sgd command to update some settings in the printer. Thanks anyway – sulaiman sudirman Oct 12 '17 at 01:45

0 Answers0