【问题标题】:How to write and send a command to Brother QL serie label printer?如何向 Brother QL 系列标签打印机编写和发送命令?
【发布时间】:2013-04-22 05:53:48
【问题描述】:

我现在正在尝试用 C# 编写一个简单的程序,该程序向打印机发送命令以打印纯文本,但不知道如何操作。我现在面临两个主要问题:

1.如何与打印机通信?

在谷歌搜索但没有得到满意的结果后,我去了 Brothers 的主页,发现那里有一个所谓的 b-PAC3 SDK。

The b-PAC* Software Development Kit is a software tool for Microsoft® Windows® that allows customized labels to be printed from within your own applications.

下载并安装后,在安装目录中,我找到了一个名为“Samples”的文件夹——里面有用不同语言(VB、VS、VSC……)编写的示例代码,我希望这些示例代码可以工作,因为这个 SDK 和打印机来自同一家公司。但他们没有。让我在这里向您展示其中一个示例:(C# 中的代码)

/*************************************************************************
    
    b-PAC 3.0 Component Sample (RfidRW)

    (C)Copyright Brother Industries, Ltd. 2009

*************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleSampleCSharp
{
    class Program
    {
        private const int NOERROR = 0;
        private const string ANTENNA_READER_WRITER = "Reader/Writer side";
        static void Main(string[] args)
        {
            // Create Rfid Instance
            bpac.RfidClass rfid = new bpac.RfidClass();     // Rfid Instance
            string selectedDevice;                          // selected device

            /* GetInstalledDevices */

            Console.WriteLine("==GetInstalledDevices()==");
            object[] arrDevices = (object[])rfid.GetInstalledDevices();
            if (rfid.ErrorCode == NOERROR)
            {
                Console.WriteLine("Succeed to GetInstalledDevices()");
                int index = 0;
                foreach (string device in arrDevices)
                {
                    Console.WriteLine(String.Format("[{0}] {1}", index, device));
                    index++;
                }

                // select device
                Console.WriteLine("Please Select Device");
                int selectedDeviceIndex = int.Parse(Console.ReadLine());
                selectedDevice = arrDevices[selectedDeviceIndex].ToString();
            }
            else
            {
                Console.WriteLine("Failed to GetInstalledDevices()");
                goto CleanUp;
            }
            // .... 
        }
    }
}

当我运行这段代码时,第一个问题出现了:(它的显示与下面的引用完全相同,抱歉,由于声誉低,我无法发布图片):

==GetInstalledDevices()==

成功GetInstalledDevices()

请选择设备

没有任何错误,但似乎程序找不到我的设备,我不知道为什么会发生这种情况。

2.如何编写 QL 风格的命令?

我知道每种打印机都有自己的命令语言,所以在兄弟的网站上搜索后,我找到了一个参考:

Brother QL Series Command Reference (QL-500/550/560/570/580N/ 650TD/700/1050/1060N)

我自己没有使用热敏打印机的经验,不幸的是,此命令参考中没有任何示例,这让我很难弄清楚应该如何编写命令。

以前有人用过 Brother QL 系列打印机吗?

P.S:我使用的打印机是 Brother QL 560。

【问题讨论】:

    标签: c# thermal-printer


    【解决方案1】:

    要与打印机通信,您需要做一些事情:

    1. 获取 USB 库,例如 libusb (http://libusb.info/)
    2. 安装允许您通过 libusb 访问打印机的驱动程序,例如 Zadig (http://zadig.akeo.ie/)
    3. 从 Internet 下载打印机的命令参考(“Brother QL 系列命令参考”)

    使用命令参考第 7 章中提供的信息和 libusb 附带的示例,制作一个小例程,将通过 USB 检测并打开与打印机的通信通道。

    然后,使用手册中提供的其余信息,向打印机发送一系列 ESC 命令以对其进行配置或打印标签。

    PS:如果您需要提高 USB 通信方面的背景知识,我推荐一个名为“USB in a Nutshell”的优秀参考资料,可在 Beyondlogic dot org 上找到(我不能发布超过两个链接)。

    【讨论】:

      【解决方案2】:

      我认为OPOS (from Microsoft) 应该是适合您情况的解决方案之一,Brother QL 560 提供了自己的 opos 驱动程序。一旦获得驱动程序(在 dll 中),您就可以像使用一般 Web 控件一样轻松地开始开发。

      【讨论】:

        猜你喜欢
        • 2019-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-10
        • 2019-01-27
        • 2014-03-01
        • 1970-01-01
        相关资源
        最近更新 更多