LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared USB printer TCP/IP communication

Hi,

 

I am a student currently doing an internship. The objective is that after testing products with labview, if any error occured , to be able to print said errors on a label to stick on the product.

The label printer is a Zebra model ZD420. Regarding the ZPL command I have read this previous thread: Zebra-printer-Printing-from-LabVIEW-using-ZPL-commands  and used labelary online viewer to help so it should be fine.

 

The printer, from what I've seen, currently only has a USB port to send print jobs. This printer is connected via USB to another computer on the network that is already using it. The printer is shared to the network from this computer.

 

I am using the attached VI and subVI to try to send ZPL code to the printer. When doing so, it seems that the address I give to TCP Connection Open vi is wrong (its the printer name as installed on my computer) because I get error 54.

Andeagon_0-1654709481478.png

 

I have tried communicating with the printer using Print Report vi. The printer receives the task but is unable to make sense of it and therefore doesn't print anything. It means that I can talk with the printer using other ways but I am probably not giving the right info for TCP communication.

 

Remote port used is 9100.

 

Should I use another port or address?

 

Any lead or solution is appreciated 🙂

 

Andeagon - LabVIEW 2015

 

 

 

Andeagon - LabVIEW 2015
0 Kudos
Message 1 of 7
(3,938 Views)

Update: Apparently the computer need to have the port open for the communication to work. For example, I succeeded in establishing communication with the computer at the port 49xxx. Thing is, I should probably try to communicate to it at port 9100 to send a print job?

Andeagon - LabVIEW 2015
0 Kudos
Message 2 of 7
(3,865 Views)

First, you stated that your printer only has a USB connection. You will not be able to connect to it using TCP unless you have either the wired or wireless network connection. Attached is a USB library I use to communicate with Zebra printers. This library is provided as-is. There is a known issue with this library if you try to communicate with multiple printers at the same time. There is some cross talk in the data. You can have multiple printers connected, just make sure you only communicate with a single printer at a time. Other than thta this should allow you to communicate with your printer.

 

The PID for the ZD420-200 dpi is 0x120 and for the ZD420-300 dpi it is 0x11E.

 

I have never tried to print using a printer share. Zebra printers expect to receive ZPL commands which define the label. Can you please post the exact content that you are sending to the printer.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 7
(3,914 Views)

^XA

^FX Font is set
^CF0,25
^FO20,20^FB366,6,2,L
^FD
"%s"
^FS

^XZ

 

I change the %s to the desired string. When I want to change line I write \&.

 

From what I understand, the string: Test label\&for error codes

 

Would roughly appear as:

 

Test label

for error codes

 

Andeagon - LabVIEW 2015

Andeagon - LabVIEW 2015
0 Kudos
Message 4 of 7
(3,888 Views)

Your format is correct so I think the issue is with your communication. I have not tried to communicate with a shared printer in the manner that you are doing. I doubt raw TCP would work. The printer shares are handled via Windows. For one thing you should have the printer shared using the generic text printer driver in Windows (https://www.foldermill.com/kb/install-generic-text-driver-in-windows)

I am not sure how you would actually connect to the shared printer to send it the data. I'll poke around to see If I can find a way.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 7
(3,883 Views)

I think you are almost there and the method should be correct.

 

In the setup

 

 

 

 

Printer --(USB)--> Host --(Windows Share over TCP)--> Client

 

 

 

 

Can you print by setting up the Zebra printer on the Client PC using the Zebra software to connect to the shared resource on the host? This should give you a method to troubleshoot the network communication.

 

You can then try to install the shared printer on the Client as a "Generic Text-Only" printer and then send the Zebra commands as a text document to that generic printer. If everything works out, Windows on the Client should then just send the raw text over to the printer share on the Host, where the Zebra driver forwards them as text over USB.

 

I don't remember if the Windows printer share will respond if you talk to it directly. Maybe you can mount it as a network share using net use and then talk to the mount point.

 

This kind of setup is a fun learning experience, trying this using regular office printers. The protocols are mostly published and you can have nice and polite conversations with your network printer, even shared across multiple hosts.

0 Kudos
Message 6 of 7
(3,853 Views)

I ended up getting my own printer directly connected to the PC that I use. It is now a Zebra GX430t but it probably doesn't make much of a difference for the way I intend to use it.

 

I also think it makes more sense, for the usage that I've explained previously, to directly have a printer on the station that does the test. At the end of the test, the label can be printed and directly affixed to the faulty product.

 

I did follow the tutorial at the provided link to add an additional Generic/Text Only driver. Only thing that I'd mention on it is the provided ZPL code to use for testing. It goes like this:

 

^XZ
^FO50,50
^FDThis is a test
^XZ 

 

and should probably start with an ^XA instead of ^XZ.

 

I used the Easy Text Report vi to send the ZPL code.

 

Not sure how to handle the thread from now on. I don't have to communicate to a shared printer anymore and thus the solution is unrelated to the title.

Andeagon - LabVIEW 2015
0 Kudos
Message 7 of 7
(3,793 Views)