简体   繁体   中英

Why does the Zebra QL 220 printer shut off in the middle of my talking to it?

I've got C# CE CF code that runs on a handheld device (Motorola MC3100) which should cause the Zebra QL220 belt printer to which it is attached to print something (code appended to this post).

I turn on the QL 220 (via the big green button at its base or top, depending on your perspective) as I start my app, but the printer shuts itself off in the middle of my code executing, and so nothing is printed (I'm assuming that's the reason nothing is printed, anyway).

If I'm right about the cause for the silence of the printer, what must I do to make its “On” button “sticky”?

I tried mashing the blue button on the QL 220, also (icon of a roller and sheet of paper being ejected from it), but all that did was spit out some of the tape/printer paper in "real time."

. . .
using (SerialPort serialPort = new SerialPort())
            {
                serialPort.BaudRate = 19200;
                serialPort.Handshake = Handshake.XOnXOff; // Handshake AKA Flowcontrol?
                serialPort.DataBits = 8;
                serialPort.Parity = Parity.None;
                serialPort.StopBits = StopBits.One;
                serialPort.PortName = "COM1:";
                serialPort.ReadTimeout = 500;
                serialPort.WriteTimeout = 500;
                serialPort.StopBits = StopBits.One;

                serialPort.Open(); 

                Thread.Sleep(2500); // I don't know why this is needed, or if it really is...

                // Try this first:
                serialPort.WriteLine("! 0 200 200 210 1");
                serialPort.WriteLine("TEXT 4 0 30 40 Bonjour la Monde"); //Hola el Mundo --- Hallo die Welt
                serialPort.WriteLine("FORM");
                serialPort.WriteLine("PRINT");
                // or (if WriteLine does not include a carriage return and line feed):
                //              serialPort.Write("! 0 200 200 210 1\r\n");
                //              serialPort.Write("TEXT 4 0 30 40 Bonjour la Monde\r\n"); //Hola el Mundo --- Hallo die Welt
                //              serialPort.Write("FORM\r\n");
                //              serialPort.Write("PRINT\r\n");

                serialPort.Close();
            }

Besides appending the colon to "COM1" as ctacke revealed was necessary on another SO post, I also needed to swap the WriteLine lines for Write lines with the "\\r\\n" appended to each line, so that they are now:

serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("TEXT 4 0 30 40 Bonjour la Monde\r\n"); //Hola el Mundo --- Hallo die Welt
serialPort.Write("FORM\r\n");
serialPort.Write("PRINT\r\n");

That successfully printed out "Bonjour la Monde" although with too much wasted paper (about a mile above and below the line was printed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM