【发布时间】:2012-06-22 20:11:28
【问题描述】:
我必须通过蓝牙将字体文件发送到我的打印机 Zebra RW420。我使用 Zebra Windows Mobile SDK,但找不到任何方法将其发送并存储在打印机上。我可以通过 Label Vista 手动完成,但必须在 200 多台打印机上完成。
任何人有任何建议或知道我可以使用 SDK 中的哪种方法?
提前致谢。
【问题讨论】:
标签: c# bluetooth zebra-printers
我必须通过蓝牙将字体文件发送到我的打印机 Zebra RW420。我使用 Zebra Windows Mobile SDK,但找不到任何方法将其发送并存储在打印机上。我可以通过 Label Vista 手动完成,但必须在 200 多台打印机上完成。
任何人有任何建议或知道我可以使用 SDK 中的哪种方法?
提前致谢。
【问题讨论】:
标签: c# bluetooth zebra-printers
CISDF 是正确答案,它可能是您计算的校验和值不正确。我在连接到 USB 端口的 RW420 上放了一个端口嗅探器,发现它可以工作。我实际上将一些 PCX 图像发送到打印机,然后在标签中使用它们。
! CISDF
<filename>
<size>
<cksum>
<data>
在第一四行的末尾有一个 CRLF。使用 0000 作为校验和会导致打印机忽略任何校验和验证(我在一些 ZPL 手册中发现了一些非常晦涩的引用,尝试了它并成功了)。
这是我用来将示例图像发送到打印机的实际 C# 代码:
// calculate the checksum for the file
// get the sum of all the bytes in the data stream
UInt16 sum = 0;
for (int i = 0; i < Properties.Resources.cmlogo.Length; i++)
{
sum += Convert.ToUInt16(Properties.Resources.cmlogo[ i]);
}
// compute the two's complement of the checksum
sum = (Uint16)~sum;
sum += 1;
// create a new printer
MP2Bluetooth bt = new MP2Bluetooth();
// connect to the printer
bt.ConnectPrinter("<MAC ADDRESS>", "<PIN>");
// write the header and data to the printer
bt.Write("! CISDF\r\n");
bt.Write("cmlogo.pcx\r\n");
bt.Write(String.Format("{0:X8}\r\n", Properties.Resources.cmlogo.Length));
bt.Write(String.Format("{0:X4}\r\n", sum)); // checksum, 0000 => ignore checksum
bt.Write(Properties.Resources.cmlogo);
// gracefully close our connection and disconnect
bt.Close();
bt.DisconnectPrinter();
MP2Bluetooth 是我们在内部使用的一个类,用于抽象 BT 连接和通信 - 我敢肯定,您也有自己的!
【讨论】:
您可以使用 SDK 发送任何类型的数据。 Zebra 字体只是一个带有标题的字体文件。因此,如果您从 Label Vista 捕获输出 cpf 文件,您可以从 SDK 发送该文件。只需创建一个连接,然后使用文件内容调用write(byte[])
【讨论】: