首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >验证斑马打印机RZ400对标签进行编码

验证斑马打印机RZ400对标签进行编码
EN

Stack Overflow用户
提问于 2013-05-27 22:52:19
回答 1查看 1.3K关注 0票数 0

下面是一个通过串口发送ZPL命令的C#函数。ZPL命令以~RVE开头(它告诉打印机发送RFID编码成功或失败的结果)。

如何在代码上下文中接收编码结果并检查编码过程是否成功?

代码语言:javascript
复制
    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();

    }
EN

回答 1

Stack Overflow用户

发布于 2013-05-27 23:07:11

您可能无法使用LPT和CreateFile检索结果。您需要使用bi-directional communication, using sockets.

更新:有一个inpout32库可用,它允许双向lpt端口通信。

Reading from Parallel Port using Inpout32.dll

Converting Visual Basic parallel port app using inpout32.dll in to Delphi

Download inpout32 binaries and sources

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16775701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档