通过Zebra RZ400打印机验证编码标签
本文关键字:编码 标签 验证 打印机 Zebra RZ400 通过 | 更新日期: 2023-09-27 18:15:38
下面是一个通过串口发送ZPL命令的c#函数。ZPL命令以~RVE开头(它告诉打印机发送RFID编码成功或失败的结果)。
如何在我的代码上下文中接收编码结果并检查编码过程是否成功?
private void Print()
{
// Command to be sent to the printer
string command = "~RVE^XA^RFw,H^FD033B2E3C9FD0803CE8000001^FS ^XZ";
// Create a buffer with the command
Byte[] buffer = new byte[command.Length];
buffer = System.Text.Encoding.ASCII.GetBytes(command);
// Use the CreateFile external func to connect to the LPT1 port
SafeFileHandle printer = CreateFile("LPT1:", FileAccess.ReadWrite,
0, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
// Aqui verifico se a impressora é válida
if (printer.IsInvalid == true)
{
return;
}
// Open the filestream to the lpt1 port and send the command
FileStream lpt1 = new FileStream(printer, FileAccess.ReadWrite);
Byte[] ResultBuffer = new byte[255];
lpt1.Write(buffer, 0, buffer.Length);
// Close the FileStream connection
lpt1.Close();
}
您可能无法使用LPT和CreateFile检索结果。您需要使用双向通信,使用套接字。
更新:有一个inpout32库可用,它允许双向lpt端口通信。
使用Inpout32.dll从并口读取
使用inpout32.dll将Visual Basic并口应用程序转换为Delphi
下载inpout32二进制文件和源代码