9 Replies Latest reply on Feb 22, 2017 4:14 AM by jofin george

    Printing stability

    Dmitrij Burakov,30g78uf68ae0aa4wrzb4rc6em1jumq6q

      Hi,

       

      I have a problem with printing stability using QLn 320 Zebra with firmware V68.19.7Z from iOS application.

      I use Zebra SDK and print code is:

       

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {

              // Instantiate connection to Zebra Bluetooth accessory

              NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

              NSString *serialNumber = [defaults valueForKey:@"selectedPrinterSN"];

              id<ZebraPrinterConnection, NSObject> thePrinterConn = [[MfiBtPrinterConnectionalloc] initWithSerialNumber:serialNumber];

             

              BOOL success = [thePrinterConn open];

             

              NSString *zplData = [NSString stringWithFormat:

                                   @"^XA" \

                                   @"^LH20,20^POI" \

                                   @"^FT5,5^FH^A0N,30,30^FD%@^FS" \

                                   @"^FT5,45^FH^A0N,30,30^FD%@^FS" \

                                   @"^XZ" \

                                   , @“Line1”, @“Line2”];

             

              NSError *error = nil;

              NSMutableData *data = [[zplData dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];       

             

              long blockSize = 1024;

              long totalSize = data.length;

              long bytesRemaining = totalSize;

              while (bytesRemaining > 0) {

                  long bytesToSend = MIN(blockSize, bytesRemaining);

                  NSRange range = NSMakeRange(0, bytesToSend);

                 

                  NSData *partialLabel = [data subdataWithRange:range];

                  [thePrinterConn write:partialLabel error:&error];

                 

                  bytesRemaining -= bytesToSend;

                 

                  [data replaceBytesInRange:range withBytes:NULL length:0];

                  if (error) {

                      break;

                  }

              }

       

              [thePrinterConn close];

             

              dispatch_async(dispatch_get_main_queue(), ^{

                    //Update UI on the main queue!

              });

          });

       

      There is a button “Print Label” on UI that triggers label printing.

      Sometimes label is not printed (about 1 label of 10 attempts) without any errors from MfiBtPrinterConnection.

      I tried to change timeout but this didn’t help.

      [((MfiBtPrinterConnection*)thePrinterConn) setTimeToWaitAfterWriteInMilliseconds:30];

       

      Could you advice how to find the reason of that (get logs from printer or something different)?