QLn320 can receive print data but does not print

I am developing iOS app with QLn320 printer. The app could print in the last two months, but from yesterday the printer stops printing. The sample app (Signature Capture) in the SDK cannot print either. So I think it should not be related with my code.

The symptom is: the Data icon on the printer flashes for multiple times and then stops flashing, but paper is not fed and nothing is printed.

When my iOS app sends print command, the printer screen becomes bright while the data icon is flashing.

Is there something wrong with the printer?

Anonymous (not verified)
Try a factory reset on the

Try a factory reset on the printer to see if it corrects the situation. Please note the default formatting language on QLn320 is "hybrid_xml_zpl". After a factory reset, you may need to change the language setting on the printer accordingly depending on the formatting language used in your app.

## Factory default configuration

^XA

^JUF

^XZ

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I should have mentioned that

I should have mentioned that the SDK demo Connectivity can print "TEST".

I ran the command "^XA^JUF^XZ" to reset the printer, but the SDK demo "Signature Capture" still cannot print. My app cannot print either.

Also, I tried to calibrate with "^XA~JC^XZ" for 3"x4" labels. The printer feeds about 5 labels, then stops with message "MEDIA OUT LOAD MEDIA", although there is still a roll of labels inside.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
I am able to print from the

I am able to print from the Signature Capture demo after a factory default reset. If you can print from Connectivity demo, this means the printer is in good condition. If you cannot print from Signature Capture, this might be something related to the media configuration. You can use the following command to dump media related settings through the Printer Setup Utilities.

! U1 getvar "media"

In my case, the output is below after a factory reset.

media.

media.status : ok

media.sense_mode : bar , Choices: bar,gap

media.tof : 0 , Choices: -400.0-400.0

media.type : label , Choices: label,journal

media.width_sense.

media.width_sense.enable : off , Choices: off

media.width_sense.in_mm : 72.1

media.width_sense.in_cm : 7.21

media.width_sense.in_dots : 576

media.width_sense.in_inches : 2.837

media.printmode : rewind , Choices: tear off,peel off,rewind,cutter,delayed cut,linerless peel,linerless rewind,linerless tear

media.speed : 3.6 , Choices: 1.0-5.0

media.feed_length : 2030 , Choices: 0-20000

media.feed_skip : 5 , Choices: 0-50

If you want to configure a 3" x 4" label, then use the following command to set the length of the label. The the media.feed_length in the above output would be 800.

! U1 setvar "zpl.label_length" "800"

The Printer Setup Utilities also has a built-in tool to configure the media. Hope this helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I installed Designer QLn320

I installed Designer QLn320 and ran the command: ! U1 getvar "media".

media.

media.status : ok

media.sense_mode : bar , Choices: bar,gap

media.tof : 0 , Choices: -400.0-400.0

media.type : label , Choices: label,journal

media.bar_location : back , Choices: back

media.width_sense.

media.width_sense.enable : off , Choices: off

media.width_sense.in_mm : 72.1

media.width_sense.in_cm : 7.21

media.width_sense.in_dots : 576

media.width_sense.in_inches : 2.837

media.printmode : rewind , Choices: tear off,peel off,rewind,cutter,delayed cut,linerless peel,linerless rewind,linerless tear,applicator

media.speed : 3.6 , Choices: 1.0-5.0

Notice that the last two lines are missing compared with yours. Is that related with malfunction of the printer?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
What's the firmware version

What's the firmware version you have on QLn320? The latest firmware is V68.20.10Z, which is published at QLn320 Mobile Printer Support. The firmware on the printer can be updated by the ZDownloader, which is next to the firmware on QLn320 Mobile Printer Support. Try to update the firmware to see if it solves the issue.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I updated the firmware to the

I updated the firmware to the latest version: V68.20.10Z, but nothing is changed -- still cannot print.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
The output for command: ! U1

The output for command: ! U1 getvar "media"

media.status : ok

media.sense_mode : gap , Choices: bar,gap

media.tof : 0 , Choices: -400.0-400.0

media.type : label , Choices: label,journal

media.bar_location : back , Choices: back

media.width_sense.

media.width_sense.enable : off , Choices: off

media.width_sense.in_mm : 72.1

media.width_sense.in_cm : 7.21

media.width_sense.in_dots : 576

media.width_sense.in_inches : 2.837

media.printmode : tear off , Choices: tear off,peel off,rewind,cutter,delayed cut,linerless peel,linerless rewind,linerless tear,applicator,linerless cut,linrless dly cut

media.speed : 3.6 , Choices: 1.0-5.0

I cannot see the last two lines for media.feed_length.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Priest
Right. The comm is open for

Right. The comm is open for only 5 seconds by default. Clear the command window so there's nothing in it and then hit F5 to reopen the comm and receive more from the printer if it's there.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Priest
Hi Jun. I see that you reset

Hi Jun. I see that you reset your printer to factory default. That's a good idea considering the problem you described however you now need to reconfigure it correctly for the labels. Try the following:

! U1 setvar "media.type" "label"

! U1 setvar "media.printmode" "tear off"

! U1 setvar "media.sense_mode" "gap"

! U1 do "zpl.calibrate" "now"

Please let us know...

jp

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I tried those commands but

I tried those commands but the printer is still like before: data icon flashes for multiple times, screen lights up, but labels are not fed and nothing is printed.

The version number of the printer firmware is V68.20.01Z. I will try to update to the latest version.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Priest
You described the media out

You described the media out error in a previous message. Is that resolved? Are you able to print from the sample app now?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I updated firmware to the

I updated firmware to the latest version. Now when I tried to calibrate, the printer only feed a little bit of label paper, like about 2cm.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Priest
Hmm. Let's get this back to a

Hmm. Let's get this back to a known base state:

! U1 do "device.restore_defaults" "all"

! U1 setvar "media.type" "label"

! U1 setvar "media.printmode" "tear off"

! U1 setvar "media.sense_mode" "gap"

! U1 do "zpl.calibrate" "now"

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
After I re-run these commands

After I re-run these commands, I can calibrate the labels:

! U1 do "device.restore_defaults" "all"

! U1 setvar "media.type" "label"

! U1 setvar "media.printmode" "tear off"

! U1 setvar "media.sense_mode" "gap"

! U1 do "zpl.calibrate" "now"

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Priest
Let's see what the printer is

Let's see what the printer is receiving.

! U1 setvar "input.capture" "on"

print

! U1 do "file.dir" "e:*.dmp"

! U1 do "file.type" "e:in???.dmp"

Export all received data to a file.

! U1 setvar "input.capture" "off"

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
Below is the output:""- DIR E

Below is the output:

""
- DIR E:*.*
* E:2KEY.TXT      3052         
* E:IN001.DMP        25         
* E:IN002.DMP        25         
* E:IN003.DMP       121         
* E:IN004.DMP        25         
* E:IN005.DMP        25         
* E:IN006.DMP       121         
* E:TT0003M_.TTF    169188         

-  66933248 bytes free E: ONBOARD FLASH
"

! U1 getvar "appl.name"

^XA^LL0153^PW600^BY2,2,51^FT42,109^B3N,N,,N,N^FDUSPIS0111105^FS^FO,34^FS^FT75,41^A0N,28,28^FDUSPIS0111105^FS^PQ1,0,1,Y^XZ

! U1 getvar "appl.name"

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Jun,Could you confirm if

Hi Jun,

Could you confirm if you can print from the Printer Setup Utilities, by sending the following ZPL to the printer?

^XA^FO20,20^BY3^B3N,N,150,Y,N^FDHello World!^FS^XZ\r\n

If the printer can print, then we can be sure that the printer is in correct state and correct settings. Then we can focus on the app part. According to the description that the data icon was flashing but no print when printing from the app, this indicates to me that the ZPL sent from the app might be incomplete or cropped. This might be something related to the code. We need either to debug the code or restart from fresh. Probably the easiest way is to start from fresh by downloading the demo app again from the Link-OS SDK and rebuild the app in Xcode. Hope this helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
Printing from Printer Setup

Printing from Printer Setup Utilities through USB port works fine, but it seems there is problem to print through Bluetooth in iOS app...

I re-installed SDK and the "Signature Capture" demo began to print. I don't know why...

My iOS app still cannot print the ZPL string as below, but Printer Setup Utilities can print this ZPL string through USB without problem:

^XA^MMT^MNY^JUS^XZ^XA^BY2,2,60^FO50,50^B3N,N,,N,N^FD1236474^FS^CI27^FO40,120^A0,26,22^FD Barcode No: ^FS^FO200,120^A0,22,20^FD 1236474^FS^FO40,160^A0,26,22^FD Case ID: ^FS^FO200,160^A0,22,20^FD 1627535 ^FS^FO40,200^A0,26,22^FD Date Recovered: ^FS^FO200,200^A0,22,20^FD 2018-05-01^FS^FO40,240^A0,26,22^FD Recovered By: ^FS^FO200,240^A0,22,20^FD USPIS\BZ4G00^FS^FO40,280^A0,26,22^FD Recovered Addr.: ^FS^FO200,280^A0,22,20^FD 12 Main Street ^FS^FO40,320^A0,26,22^FD Recovered Loc.: ^FS^FO200,320^A0,22,20^FD room 1^FS^FO40,360^A0,26,22^FD Resp. Party: ^FS^FO200,360^A0,22,20^FH^FD USPIS\NMAbdulAzeez^FS^FO40,400^A0,26,22^FD Description: ^FS^FO200,400^A0,22,20^FB350,5,,^FD Kevin Maxwell is stepping down as the chief executive officer of the Prince George’s County Public Schools. The move comes in the wake of a number of scandals, including the discovery of una ...^FS^FO40,550^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,575^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^FO40,645^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,670^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^FO40,740^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,765^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^PQ1,0,1,Y^XZ

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
Could you please try the ZPL

Could you please try the ZPL string in your environment? It works fine for me with USB port, but not Bluetooth... I am using iOS 11.3.

Did I write the ZIP string in the wrong way? Does Bluetooth of iOS 11.3 have problem? Or the Bluetooth communication of Zebra printer has problem?

If you can give me a hint soon, that would be highly appreciated! My USPIS customer is waiting for deploying my iOS app, but currently the printing issue is the biggest impediment. I cannot give customer an answer of when this can be solved.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
The ZPL looks good. I've

The ZPL looks good. I've tried through the Printer Setup Utilities without problem. The only thing I would suggest is to split the ZPL into chunks, as the ZPL seems long. Can you try to divide the ZPL into small chunks, with 100 bytes in each chunck, and send the divided ZPL to the printer in the order sequently? Hope this helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I divided the ZPL string into


I divided the ZPL string into small chunks, but still the printer cannot print.

I found error message in Xcode output window that should be related to Zebra printer:

2018-05-07 14:33:08.024003-0400 PEAP++ DEV[430:65183] CoreAccessories accessoryInfo for arrival = {

    ACCExternalAccessoryPrimaryUUID = "B16FB9EC-18DE-4A70-B666-17FE65DB7A43";

    IAPAppAccessoryCapabilitiesKey = 1;

    IAPAppAccessoryCertDataKey = "908 bytes";

    IAPAppAccessoryCertSerialNumberKey = "15 bytes";

    IAPAppAccessoryDockTypeKey = "";

    IAPAppAccessoryFirmwareRevisionKey = 001;

    IAPAppAccessoryFirmwareRevisionPendingKey = "<null>";

    IAPAppAccessoryHardwareRevisionKey = 001;

    IAPAppAccessoryMacAddressKey = "AC:3F:A4:CB:A2:49";

    IAPAppAccessoryManufacturerKey = "Zebra Technologies";

    IAPAppAccessoryModelNumberKey = QLn320;

    IAPAppAccessoryNameKey = XXQLJ174802119;

    IAPAppAccessoryProtocolsKey =    {

        "com.zebra.rawport" = 90;

    };

    IAPAppAccessorySerialNumberKey = XXQLJ174802119;

    IAPAppAccessoryVehicleInfoInitialDataKey =    {

    };

    IAPAppConnectionIDKey = 39940355;

}

2018-05-07 14:33:08.026482-0400 PEAP++ DEV[430:65183] eaAccessory CoreAccessoryPrimaryUUID = B16FB9EC-18DE-4A70-B666-17FE65DB7A43

2018-05-07 14:33:16.066328-0400 PEAP++ DEV[430:65183] accessoryd sessionResult = 1, useSocketInterace = 1, sessionID = 0x1

2018-05-07 14:33:21.648940-0400 PEAP++ DEV[430:65183] [Common] _BSMachError: port 1351b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"

2018-05-07 14:33:26.767855-0400 PEAP++ DEV[430:65597] Removing EASession 635F52A2-A64C-47D5-BFC0-6565C2367B8F from list of sessionUUIDs

Any idea?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
When writing data to the

When writing data to the Bluetooth, the API would return but the data could still be buffered at iOS Bluetooth driver level. This means we need to make sure the Bluetooth connection remains open even after the write API returns. The easiest way is to add some delay after the write statement, for example 5sec delay after the write. Then check the printer status before closing the connection. We can experiment the behaviors by writing a short ZPL vs. a long ZPL, and with delay vs. without delay.

Here is the code snippet that helped me to divide the long ZPL. It worked for me to print out the exact label on QLn320. Let's know if it helps.

    NSString *testLabel = @"^XA^BY2,2,60^FO50,50^B3N,N,,N,N^FD1236474^FS^CI27^FO40,120^A0,26,22^FD Barcode No: ^FS^FO200,120^A0,22,20^FD 1236474^FS^FO40,160^A0,26,22^FD Case ID: ^FS^FO200,160^A0,22,20^FD 1627535 ^FS^FO40,200^A0,26,22^FD Date Recovered: ^FS^FO200,200^A0,22,20^FD 2018-05-01^FS^FO40,240^A0,26,22^FD Recovered By: ^FS^FO200,240^A0,22,20^FD USPIS\\BZ4G00^FS^FO40,280^A0,26,22^FD Recovered Addr.: ^FS^FO200,280^A0,22,20^FD 12 Main Street ^FS^FO40,320^A0,26,22^FD Recovered Loc.: ^FS^FO200,320^A0,22,20^FD room 1^FS^FO40,360^A0,26,22^FD Resp. Party: ^FS^FO200,360^A0,22,20^FH^FD USPIS\\NMAbdulAzeez^FS^FO40,400^A0,26,22^FD Description: ^FS^FO200,400^A0,22,20^FB350,5,,^FD Kevin Maxwell is stepping down as the chief executive officer of the Prince George’s County Public Schools. The move comes in the wake of a number of scandals, including the discovery of una ...^FS^FO40,550^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,575^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^FO40,645^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,670^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^FO40,740^A0,26,22^FD Rec'd: ______________________________________ ^FS^A0,22,20^FO40,765^FB460,1,0,C,0^FD(Printed Name/Signature/Date)^FS^PQ1,0,1,Y^XZ";

    int maxChunk = 500;

   

    if (testLabel.length <= maxChunk) {

        NSData *data = [NSData dataWithBytes:[testLabel UTF8String] length:[testLabel length]];

        [connection write:data error:&error];

    } else {

       

        for (int i = 0; i < testLabel.length; i  += maxChunk) {

            NSRange range;

            if (i + maxChunk <= testLabel.length) {

                range = NSMakeRange(i, maxChunk);

            } else {

                range = NSMakeRange(i, (testLabel.length - i));

            }

            NSString *subStr = [testLabel substringWithRange:range];

            NSData *data = [NSData dataWithBytes:[subStr UTF8String] length:[subStr length]];

            [connection write:data error:&error];

        }

    }

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
No luck on my side... I tried


No luck on my side... I tried both connection.write() and printer.getToolsUtil().sendCommand().

    // Send ZPL command to Bluetooth printer

    func sendZplOverBluetooth(fullLabel: String) {

        DispatchQueue.global(qos: .background).async {

            if let serialNumber = UserDefaults.standard.value(forKey: "lastSelectedPrinter") as? String {

                do {

                    let connection = MfiBtPrinterConnection(serialNumber: serialNumber)

                    if connection?.open() == true {

                        let printer = ZebraPrinterFactory.getInstance(connection, with: PRINTER_LANGUAGE_ZPL)

                       

                        // Sending large amounts of data in a single write command can overflow

                        // the NSStream buffers which are the underlying mechanism used by the SDK

                        // to communicate with the printers. One way is to break up large strings

                        // into smaller chunks to send to the printer

                        let blockSize = 500;

                        let totalSize = fullLabel.lengthOfBytes(using: String.Encoding.utf8);

                        var bytesRemaining = totalSize;

                        var fullLabelCopy = fullLabel

                       

                        while bytesRemaining > 0 {

                            let bytesToSend = min(blockSize, bytesRemaining)

                            let partialLabel = fullLabelCopy.subString(startIndex: 0, length: bytesToSend)

                            //let data = partialLabel.data(using: .utf8)

                            //var writeError: NSError?

                            //connection?.write(data!, error: &writeError)

                            try printer?.getToolsUtil().sendCommand(partialLabel)

                            bytesRemaining -= bytesToSend

                           

                            if (bytesRemaining > 0) {

                                fullLabelCopy = fullLabelCopy.subString(startIndex: bytesToSend, length: bytesRemaining)

                            }

                        }

                    }

                   

                    sleep(5)

                    connection?.close()

                    //connection = nil

                } catch {

                    DispatchQueue.main.sync {

                        // Display alert

                    }

                }

            } else {

                DispatchQueue.main.sync {

                    // Display alert

                }

            }

        }

    }

2018-05-07 21:04:23.500089-0400 PEAP++ DEV[601:176711] eaAccessory CoreAccessoryPrimaryUUID = FB559495-521E-42B5-A84E-571B1FEA978E

2018-05-07 21:04:23.503892-0400 PEAP++ DEV[601:176711] accessoryd sessionResult = 1, useSocketInterace = 1, sessionID = 0xC

2018-05-07 21:04:33.828033-0400 PEAP++ DEV[601:176804] Removing EASession 4A9BC75C-F87F-43D5-86D4-5AA42E56258A from list of sessionUUIDs

The same code worked for me two weeks ago for some time. Suddenly the printer stopped working.

Can we have a WebEx meeting so that I can show you what happened on my printer? I can set up a WebEx for you.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Jun,Could you double check

Hi Jun,

Could you double check the implementation of subString routine? I used the implementation from your Signature project you posted early. It looks like the routine returns nothing on the 2nd iteration. Please double check to make sure.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
Thank you for what you found

Thank you for what you found in my code! It seems iOS changed the way to count characters in string. After I changed "lengthOfBytes" to "count", the printer begins to print!

Question: How can I print ^ character in string?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
For special characters, we

For special characters, we can use ^HF command to specify the ascii code of special character in hex to print. Below is an example to print carrot (^, 0x5E) character.

^XA

^ADN, 10, 10

^FH^FDASCII code of carrot is 0x5E: _5E^FS

^XZ

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jun Meng
I can print those special

I can print those special characters now. Thanks a lot!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments