从 Zebra 打印机读取状态 [英] Reading status from Zebra Printer

查看:45
本文介绍了从 Zebra 打印机读取状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,我们需要使用 Zebra 打印机来制作条形码标签.我们使用的是 C#,我们在打印方面做得很好,将原始 ZPL 字符串发送到打印机(使用 winspool.drv).

I'm working on a project where we need to use a Zebra Printer for barcode labels. We're using C#, and we're doing OK on the printing side of things, sending raw ZPL strings to the printer (using winspool.drv).

但是,我们还需要从打印机读取数据,但没有运气.

However, we also need to read from the printer, and no luck there.

我们需要从打印机获取状态,这是 ZPL 命令~HS"的输出,因此我们可以知道内存中有多少标签等待打印.winspool.drv 中的 EnumJobs() 仅在 windows spool 上有作业,一旦将它们发送到打印机,它们就会从该列表中消失.但这并不意味着标签已经打印,因为打印机有一个剥离传感器,一次只打印一个标签,而且我们显然有兴趣将成批的标签发送到打印机.

We need to get the status from the printer, which is the output to the ZPL command "~HS", so we can tell how many labels are in memory waiting to be printed. The EnumJobs() from winspool.drv only has jobs on the windows spool, and once they're sent to the printer, they're gone from that list. But that doesn't mean the label has been printed, since the printer has a peel sensor and only prints one label at a time, and we're obviously interested in sending batches of labels to the printer.

我尝试过类似的方法(使用 winspool.drv 调用):

I've tried something like (using the winspool.drv calls):

OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero);
WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); // send the string "~HS"
ReadPrinter(hPrinter, data, buff, out pcRead);

但是我在 ReadPrinter 调用中什么也没得到.我什至不知道这是否是正确的做法.

But I get nothing on the ReadPrinter call. I don't even know if this is the right way of going at it.

以前有人解决过这个问题吗?

Anyone out there tackled this before?

谢谢.

推荐答案

我也面临同样的问题.您是否已经管理过有关此主题的任何事情?

I'm facing the same problem. Did you already manage anything on this subject?

Axe Perez Parra Castro,我就是这样做的:

Ax Perez Parra Castro, this is how I did it:

-从这里获取 RawPrinterHelper 类 http://support.microsoft.com/kb/322091

-get the RawPrinterHelper class from here http://support.microsoft.com/kb/322091

-我的打印机 (zebra 2030) 不支持 ZPL,所以据我所知,唯一的方法是将 unicode 发送给它

-my printer (zebra 2030) doesn't support ZPL, so as far as I know the only way is to send unicode to it

-我列出了我需要的字符,例如

-I made a list of characters I need e.g.

string enq = Convert.ToChar(5).ToString();
string esc = Convert.ToChar(27).ToString();
string nul = Convert.ToChar(0).ToString();
string rs = Convert.ToChar(30).ToString();
string lf = Convert.ToChar(10).ToString();
string cr = Convert.ToChar(13).ToString();

(从 en.wikipedia.org/wiki/ASCII 获取这些 int 值)

(get those int values from en.wikipedia.org/wiki/ASCII)

- 编写命令 - 例如sb.Append(esc + enq + Convert.ToChar(7).ToString());(来自打印机手册,命令 <7> 应该得到固件版本)

-compose the command - e.g. sb.Append(esc + enq + Convert.ToChar(7).ToString()); (from the printer manual, the command < ESC>< ENQ><7> should get the firmware version)

-发送命令 RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString());(在我的例子中,printerName 是Zebra TTP 2030")

-send the command RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString()); (printerName in my case is "Zebra TTP 2030")

这篇关于从 Zebra 打印机读取状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆