Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write and send a command to Brother QL serie label printer?

I'm now trying to write a simple program in C# that sends command to the printer to print a plain text but don't know how to. There are 2 main problems that I'm facing now:

1. How to communicate with the printer?

After doing some google search but not getting a satisfying result I went to Brothers' main page and found there a so-called 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.

After having downloaded and installed it, in the directory where it's installed, I found a folder named "Samples"- there are sample codes written in some different language (VB, VS, VSC, ...) I hoped that these sample codes would work since this SDK and the printer come from the same company. But they didn't. Let me show you one of these samples here: (code in 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;
            }
            // .... 
        }
    }
}

When I run this code, the first problem comes out: (it displayed exactly as in quote bellow, sorry, I can't post image due to low reputation):

==GetInstalledDevices()==

Succeed to GetInstalledDevices()

Please Select Device

There wasn't any error but seems like program can't find my device, I don't have any idea why this happens.

2. How to write a QL-style command?

I know that each kind of printer has its own command language so after searching on Brother's site I found a reference:

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

I myself have no experience in working with thermal printer and unfortunately there isn't any sample in this command reference which makes it really difficult for me to figure out how the command should be written.

Has anyone worked with Brother QL serie printers before?

P.S: The printer that I'm using is Brother QL 560.

like image 272
tc07 Avatar asked Apr 28 '13 14:04

tc07


People also ask

How do I use Brother printer labels?

highlight the text you want inserted into your label. click the text you want inserted into your label (click on the button with the letter "P" on the toolbar to pull highlighted information into the label creation software) print the text you want inserted into your label.

How do I print address labels on my Brother printer?

Step 1: Make sure that the paper you use is suitable for your Brother machine. Step 2: Load labels or envelops in the MP tray of your Brother machine. Step 3: Print on labels or envelopes from your computer.


1 Answers

To communicate with the printer, you need a few things:

  1. Get a USB library, like libusb (http://libusb.info/)
  2. Install a driver that will allow you to access the printer via libusb, like Zadig for example (http://zadig.akeo.ie/)
  3. Download the printer's Command Reference from the Internet ("Brother QL Series Command Reference")

Using the information provided in chapter 7 of the command reference and the samples that come with libusb, make a small routine that will detect and open a communication channel with the printer via USB.

Then, using the rest of the information available in the manual, send a series of ESC commands to the printer to either configure it or print labels.

PS: If you need to improve your background on USB communication, I recommend an excellent reference called "USB in a Nutshell", available at beyondlogic dot org (I can't post more than two links).

like image 74
Miguel Dutra Avatar answered Oct 16 '22 07:10

Miguel Dutra