How to capture the ZPL ^HV ouotput
<p>I need help implementing the ^HV ZPL command and to capture it as the host.</p>

<p>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 ?</p>

<p>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.</p>

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

<p>But how can i capture it using python ?</p>

<p>Thanks !</p>

<p>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 <a href="https://wiki.python.org/moin/TcpCommunication" rel="nofollow">wiki.python.org</a>.</p>

<pre><code>#!/usr/bin/env python

import socket

TCP_IP = '127.0.0.1'
TCP_PORT = 9100
BUFFER_SIZE = 1024
FORMAT = "^XA^DFE:TEST.ZPL^FO30,30^A0N,50,50^FN1^FS^HV1,15,[,],^FS^XZ"
PRINT = "^XA^XFE:TEST.ZPL^FN1^FDHELLO WORLD^FS^XZ"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(FORMAT)
s.send(PRINT)
data = s.recv(BUFFER_SIZE)
s.close()

print "received data:", data
</code></pre>

python rfid zebra-printers zpl zpl-ii