idan357 idan357 - 6 months ago 47
Python Question

How to capture the ZPL ^HV ouotput

I need help implementing the ^HV ZPL command and to capture it as the host.

I want to read the TID and encode it to the EPC using Python, i can send print and encode command to the printer but how do i read back from it ?

If I'm using the "Direct Communication" program in the Zebra Setup Utilities tool i can get the TID back in the "Data received" window.

Ive tried using TCP/IP but i dont know how to pull the info just to print

But how can i capture it using python ?

Thanks !


Communicating with a Zebra printer over TCP is the same as any other TCP connection. If the question is how to use the ^HV command, it is usually put into a stored format. The response happens when you use the format to print. Here's a snippet I modified from

#!/usr/bin/env python

import socket

TCP_IP = ''
TCP_PORT = 9100
FORMAT = "^XA^DFE:TEST.ZPL^FO30,30^A0N,50,50^FN1^FS^HV1,15,[,],^FS^XZ"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
data = s.recv(BUFFER_SIZE)

print "received data:", data