Category Archives: automation

Zebra ZD411 PDF Direct and CUPS/lpr Setup on Linux

PDF Direct

There is a lot of marketing about PDF Direct, but more difficult to find How to Guides or specifics, especially if you want to print a label from a Linux distribution. This post tries to bring the information together.

We purchased a ZD411T Thermal Transfer printer for demonstration purposes and decided PDF Direct might be a good choice as it would allow for labels to be stored for record as well as be printed.

In 2023 the ZD411T came with LinkOS 6.3 so the PDF Direct feature was already available, and no firmware update was required.

If you have a printer with a touch display, you can set up PDF Direct using its menu. If not you need to send the ZPL command to the printer.

At location 10:50 in the video below (of a Zebra webinar) it discusses how to do it from a developer Toolbox, but if you don’t have that installed you can also do it from the Zebra Setup Utilities application on a Windows PC .

ARVE

The following are resources from Zebra to set this “alternate application” apl setting to “pdf” for PDF Direct.

Once moving to PDF Direct, your printer will only handle PDF Direct, so don’t chop and change. That question was raised in this video above at the end.

The video also mentions the PDF file being sent should be the same dimensions as the label.

After we enabled PDF Direct, from Windows, at first printing did not work at all, even after confirming the setup was sent and rebooting the printer. A reboot of the PC was required for it to print the PDF from Adobe Reader, via Ctrl-P.

Disable Boot Label Scroll

By default it seems the printer is setup to do some auto calibration or similar on power up and it will print out additional blank labels on each boot. This can be adjusted in the printer settings. We found the following settings to work if you want to avoid scrolling out blank labels.

  • Media Type: Non Continuous / Web sensing
  • Media Handling: Tear Off
  • Media Feed Option: No feed (avoids label feed due to calibration at power on)
  • Back Feed: Before Printing

CUPS (Linux or Mac)

There is mention that you can print using CUPS in Linux and Mac, but Zebra’s documentation shy’s away from directly saying they support it for Linux. So, we recommend you set your printer up first with a Windows PC and its tools, and once you have proven it move to Linux/Mac.

We were able to add the ZD411 as a ZPL printer to a Ubuntu 20.04 distribution, using these instructions,

Adding-a-Zebra-Printer-in-a-CUPS-Printing-System

which basically involves walking through adding a printer via the CUPS web interface at localhost:631. The printer did not work before having done this.

We setup the print settings on Windows previously, so we left the printer settings to “Printer default” in most settings.

Attempting to print a PDF via the Ubuntu default Document Viewer resulted in an empty label being scrolled out and the print head did not make any noise, so no attempt was made to print.

However sending the PDF file directly to the printer using the lpr command printed the label. The following are the commands to list the printers (to get the printer name) and then send the file (of the same dimensions as the label) directly to the printer to print the label.

lpstat -p -d
lpr -P Zebra_Technologies_ZTC_ZD411-203dpi_ZPL  2022-123456_label.pdf

Hope that will save you some setup time if you choose to go Zebra on Linux.

Setting up LabJack U3 On Linux for Python

Here’s a collation of steps to setup a U3 LabJack device on Linux, in this case Ubuntu 20.04.

Download tar ball

Downloaded the Linux x86_64 Release Linux 64-bit Installer Package from:

https://labjack.com/pages/support/?doc=/software-driver/installer-downloads/ljm-software-installers-t4-t7-digit/#header-three-3r1sj

Extract and Install

Extract

$ tar -xzf labjack_ljm_software_2019_07_16_x86_64tar.gz

$ ls -al
labjack_ljm_software_2019_07_16_x86_64 
labjack_ljm_software_2019_07_16_x86_64tar.gz

Install

$ cd labjack_ljm_software_2019_07_16_x86_64
$ sudo ./labjack_ljm_installer.run 
[sudo] password for user: 
Creating directory labjack_ljm_software
Verifying archive integrity... All good.
Uncompressing LabJack software for T4s, T7s, and Digits for Linux x86_64.......................................................................................................................................................................................................................................................................
Installing libLabJackM.so.1.20.1 to /usr/local/lib... done.
Installing LabJackM.h to /usr/local/include... done.
Installing constants files to /usr/local/share... done.
Installing labjack_kipling to /opt... done.
Installing command line shortcut labjack_kipling to /usr/local/bin... done.
Registering with application launcher... done.
/usr/local/lib >> /etc/ld.so.conf
Adding LabJack device rules... done.
Restarting the device rules... done.

Install finished. Please check out the README for usage help.

If you have any LabJack devices connected, please disconnect and
reconnect them now for device rule changes to take effect.

Verify

Plug in your device (U3 JabJack) to USB port and list /var/log/syslog looking for LabJack U3 to ensure it is found, as below.

$ tail /var/log/syslog
May  3 11:33:50 laptop systemd[5916]: tracker-extract.service: Succeeded.
May  3 11:33:51 laptop kernel: [15761.633639] usb 3-3: new full-speed USB device number 6 using xhci_hcd
May  3 11:33:51 laptop kernel: [15761.782937] usb 3-3: New USB device found, idVendor=0cd5, idProduct=0003, bcdDevice= 0.00
May  3 11:33:51 laptop-01-ub kernel: [15761.782942] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
May  3 11:33:51 laptop kernel: [15761.782944] usb 3-3: Product: LabJack U3
May  3 11:33:51 laptop kernel: [15761.782947] usb 3-3: Manufacturer: LabJack

Install ExoDriver

The above software install does not install all requirements. The exodriver is also required for usb control from Python, and is detailed here:

https://labjack.com/pages/support?doc=/software-driver/installer-downloads/exodriver/#section-header-two-25lef

$ sudo apt-get install build-essential
... output removed
$ sudo apt-get install libusb-1.0-0-dev
... output removed
$ sudo apt-get install git-core 
... output removed
$ git clone https://github.com/labjack/exodriver.git
Cloning into 'exodriver'...
remote: Enumerating objects: 1044, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 1044 (delta 23), reused 19 (delta 10), pack-reused 996
Receiving objects: 100% (1044/1044), 378.59 KiB | 3.08 MiB/s, done.
Resolving deltas: 100% (615/615), done.
$ cd exodriver/
$ sudo ./install.sh 
Making..
rm -f liblabjackusb.so.2.7.0 *.o *~
cc -fPIC -g -Wall  -c labjackusb.c
cc -shared -Wl,-soname,liblabjackusb.so -o liblabjackusb.so.2.7.0 labjackusb.o -lusb-1.0 -lc
Installing..
test -z /usr/local/lib || mkdir -p /usr/local/lib
install liblabjackusb.so.2.7.0 /usr/local/lib
test -z /usr/local/include || mkdir -p /usr/local/include
install labjackusb.h /usr/local/include
ldconfig
Adding 90-labjack.rules to /lib/udev/rules.d..
Restarting the rules..
Install finished. Thank you for choosing LabJack.
If you have any LabJack devices connected, please disconnect and reconnect them now for device rule changes to take effect.

If you do not install or build it, you end up with this error if you try to open a device in Python

~$ python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import u3
<class 'LabJackPython.LabJackException'>: Could not load the Exodriver driver. Ethernet connectivity only.

Check that the Exodriver is installed, and the permissions are set correctly.
The error message was: liblabjackusb.so: cannot open shared object file: No such file or directory
>>> quit()

Install Python Library

Install the python library as per:

https://labjack.com/pages/support?doc=/software-driver/example-codewrappers/labjackpython-for-ud-exodriver-u12-windows-mac-linux/#header-three-qhnmb

$ python3 -m pip install LabJackPython
Collecting LabJackPython
  Downloading LabJackPython-2.1.0-py2.py3-none-any.whl (115 kB)
     |████████████████████████████████| 115 kB 2.2 MB/s 
Installing collected packages: LabJackPython
Successfully installed LabJackPython-2.1.0

If you installed without sudo, you’re library will be in your .local folder.

Find the u3.py file like this

$ find ~ | grep u3.py
/home/user/.local/lib/python3.8/site-packages/u3.py

Open it to have a look, or see it on the github repo

https://github.com/labjack/LabJackPython/blob/master/src/u3.py

Run python3 interpreter and verify you can communicate with your device by instantiating a U3() class, reading an analog input (default state of pins, so we can avoid configuring them at this point) and printing the temperature.

$ python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import u3
>>> d = u3.U3()
>>> print (d.getAIN(4))
0.305592048
>>> print(d.getTemperature())
303.5464268177748
>>> d.close()