gpt4 book ai didi

c# - 如何通过蓝牙将字体发送到 Zebra 打印机

转载 作者:行者123 更新时间:2023-11-30 15:03:52 27 4
gpt4 key购买 nike

我必须通过蓝牙将字体文件发送到我的打印机 Zebra RW420。我正在使用 Zebra Windows Mobile SDK,但无法找到任何方式将其发送和存储在打印机上。我可以通过 Label Vista 手动完成,但必须在 200 多台打印机上完成。

有人有任何建议或知道我可以使用 SDK 中的什么方法吗?

提前致谢。

最佳答案

CISDF 是正确答案,可能是您计算的校验和值不正确。我在连接到 USB 端口的 RW420 上放置了一个端口嗅探器,发现它可以工作。我实际上将一些 PCX 图像发送到打印机,然后在标签中使用它们。

! CISDF
<filename>
<size>
<cksum>
<data>

第一四行末尾有一个CRLF。使用 0000 作为校验和会导致打印机忽略任何校验和验证(我在一些 ZPL 手册中发现了一些非常模糊的引用,试过了并且有效)。 是文件的 8.3 名称,因为它将存储在打印机的文件系统中, 是文件的大小,8 个字符长,格式为十六进制数。 是作为校验和的数据字节之和的二进制补码。 当然是要存储在打印机上的文件的内容。

这是我用来将示例图像发送到打印机的实际 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 连接和通信的类 - 我敢肯定,您也有自己的类!

关于c# - 如何通过蓝牙将字体发送到 Zebra 打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11163425/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com