gpt4 book ai didi

c# - 如何向Brother QL 系列标签打印机写入和发送命令?

转载 作者:太空狗 更新时间:2023-10-29 20:39:45 29 4
gpt4 key购买 nike

我现在正在尝试用 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()==

Succeed to GetInstalledDevices()

Please Select Device

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

2。如何写一个QL风格的命令?

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

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

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

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

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

最佳答案

要与打印机通信,您需要一些东西:

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

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

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

PS:如果您需要提高 USB 通信的背景知识,我推荐一本名为“USB in a Nutshell”的优秀引用资料,可在 beyondlogic dot org 获取(我不能发布超过两个链接)。

关于c# - 如何向Brother QL 系列标签打印机写入和发送命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16263847/

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