Zebra 打印机 return 短 TID 且未满 24 章 TCP/IP

Zebra printer return short TID and not full 24 charters over TCP/IP

我正在使用 python 通过 TCP/IP 与 zebra R600(最新固件)打印机通信以发送 ZPL,它将从标签读取 TID 并使用 ZPL 存储在文件中^HV.

我的问题是每 80 个标签左右(随机)我从打印机得到一个较短的 TID(下面的例子)

我曾尝试更改打印机缓存,但似乎没有任何效果,而且问题很随机,短输出来自普通标签。 有什么建议吗?

我的代码:

#!/usr/bin/env python

import socket
import os.path
from os import rename

global data
global count

count = 0


def writeTID(tid):  
    f = open("UID_list.txt",'a')
    f.write(str(tid) + "\n")
    f.close()


def Read_TID(quantity):
    global count
    f = open("UID_list.txt",'a')
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((TCP_IP, TCP_PORT))
    for x in range(0,int(quantity)):
        zpl = """
        ^XA
        ^RSB,B30,236,3,N
        ^RR10
        ^XZ
        ^XA
        ^SZ2^JMA
        ^MCY^PMN
        ^PW1215^MTT
        ^MNW
        ~JSN
        ~SD18^MD0
        ^PR8,8,8
        ^JZY
        ^LH0,0^LRN
        ^FN4^FS
        ^FN4^RFR,H,0,12,2^FS
        ^FH_^HV4,24,,,L^FS
        ^PQ1,0,1,Y^XZ
        """
        print "Tag number:"+str(x+1)
        s.send(str(zpl))
        data = s.recv(BUFFER_SIZE)

        print "Received data:", data
        f.write(str(data) + "\n")
        if (len(data)<24):
            count+=1
    print "\nnumber of errors: "+str(count)
    s.close()
    f.close()

#printer settings
TCP_IP = '192.168.7.220'
TCP_PORT = 9100
BUFFER_SIZE = 1024



print ("\t\t\t ##############################################################")
print ("\t\t\t ##############################################################")
print ("\t\t\t #######                                              #########")
print ("\t\t\t #######          TID file maker v1.0.0               #########")
print ("\t\t\t #######                                              #########")
print ("\t\t\t ##############################################################")
print ("\t\t\t ##############################################################")
print ("\t\t\t\nM A I N    M E N U")
print ("\t\t\t\n------------------\n")

while True :
    if os.path.isfile("UID_list.txt"):
        num_lines = sum(1 for line in open("UID_list.txt"))
        print("\nYou have "+str(num_lines)+" labels in corrent roll")
    print("\n1:Start or continue roll\n2:Finish roll\n")
    selected = raw_input("\tPlease select an option: ")

    if selected =="1":
        add_number = raw_input("How many labels to manufacture?\n ")
        Read_TID(add_number)

    elif selected =="2":
        roll_number = raw_input("What is the roll number?\n ")
        rename("UID_list.txt","UID_list_Roll_"+str(roll_number)+".txt") 

输出文件:

E280116020006537E1EA08F1
E280116020007527E1EA08F1
E280116020007517E1EA08F1
E280116020006507E1EA08F1
E280116020006357E1E608F1
E280116020007347E1E608F1
E280116020006337E1E608F1
E280116020007327E1E608F1
E280116020007317E1E608F1
E280116
E2801160200061F7E1E408F1
E2801160200071E7E1E408F1
E280116020006157E1E408F1
E280116020007147E1E408F1
E2801160200071F7E1D608F1
E2801160200061E7E1D608F1
E2801160200061D7E1D608F1
E2801160200071C7E1D608F1
E2801160200061B7E1D608F1
E2801160200071A7E1D608F1
E280116020007197E1D608F1
E
E280116020007167E1D608F1
E280116020007157E1D608F1
E280116020006147E1D608F1
E280116020007137E1D608F1
E280116020006127E1D608F1
E280116020006117E1D608F1
E280116020006507E1EA08F1
E2801160200063F7E1E608F1

BR, 伊丹.

在 s.send(str(zpl)) 和 s.recv(BUFFER_SIZE) 之间添加了一个延迟,该延迟等于打印机弹出标签的时间 ( time.sleep(1.5))