【问题标题】:Image Transmit to Intermec PM4i printer and then Print图像传输到 Intermec PM4i 打印机,然后打印
【发布时间】:2014-01-13 01:36:32
【问题描述】:

我正在使用指纹上传并打印 pcx 格式的图像。

Step1 使用 TCP 端口将图像上传到打印机,我使用命令:

IMAGE LOAD "bigfoot.1",1746,""\r\n

打印机返回消息“OK”。 然后我使用套接字将 bigfoot.1 的字节数据发送到打印机。

第 2 步打印图像“bigfoot.1”:

PRPOS 200,200
DIR 3
ALIGN 5
PRIMAGE "bigfoot.1"
PRINTFEED
RUN

问题来了,打印机返回消息“找不到图像”。所以我想出了上传失败的可能性。于是我打开软件PrintSet4查看图像,图像已经存在于TMP.Odd中!!! 最后,我用 PrintSet4 代替我的套接字应用程序上传图像,添加文件并应用后,我使用 step2 打印命令打印图像,它工作正常! 这是上传图片的C#代码:

public void SendFile(string filePath, string CR_LF)
{
    FileInfo fi = new FileInfo(filePath);
    using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
    {
        byte[] byteFile = new byte[fs.Length];
        string cmd = "IMAGE LOAD \"" + fi.Name + "\"," + byteFile.Length.ToString() + ",\" \"" + CR_LF;
        ClientSocket.Send(encode.GetBytes(cmd));
        fs.Read(byteFile, 0, byteFile.Length);
        Thread.Sleep(1000);
        ClientSocket.Send(byteFile);
    }
}

【问题讨论】:

    标签: image fingerprint intermec


    【解决方案1】:

    我已经修改了你的代码并使用了串口。

    public void SendFile(string filePath)
    {
        SerialPort port = new SerialPort("COM3", 38400, Parity.None, 8, StopBits.One);
        port.Open();
        FileInfo fi = new FileInfo(filePath);
        using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            byte[] byteFile = new byte[fs.Length];
            // string cmd = "IMAGE LOAD \"" + fi.Name + "\"," + teFile.Length.ToString()+                     ",\"\"" + CR_LF;
            string cmd = "IMAGE LOAD " + "\"" + fi.Name + "\"" + "," + byteFile.Length.ToString() + "," + "\"S\"";
    
            port.WriteLine(cmd);
            fs.Read(byteFile, 0, byteFile.Length);
            port.Write(byteFile,0,byteFile.Count());
            int count = byteFile.Count();
            int length = byteFile.Length;
        }
    }
    

    所以我注意到问题在于使用CR_LF。相反,我使用了port.WriteLine(cmd),其作用与添加行分隔符相同。它工作得很好。

    【讨论】:

    • TCP端口怎么样?在我的应用中,PC和打印​​机之间的距离很远,所以我需要使用TCP而不是串口。
    • 您找到了如何通过 TCP 网络上传 PCX(单色黑白)自定义图像的答案吗?我有完全相同的问题。我提交 IMAGE LOAD 命令、换行符(LF)、写入数据字节、其余 DirectProtocol 命令。图像未存储在打印机中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 2012-03-17
    相关资源
    最近更新 更多