Is there a way to monitor and prevent the printer from locking up (LinkOS)?

// Expert user has replied.
T Tanner Semerad 3 years 7 months ago
10 3 0

I have an iOS app using the LinkOS SDK communicating via bluetooth with a ZQ520 printer. I'm using the following code to print labels:

-(NSError*)printReceiptAsOneJobUsingNSString:(id)printer withString:(NSMutableString*)fullLabel {
    /*
     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.
     This method shows one way to break up large strings into smaller chunks to send to the printer
     */
    NSError *error = nil;
   
    long blockSize = 1024;
    long totalSize = fullLabel.length;
    long bytesRemaining = totalSize;
   
    while (bytesRemaining > 0) {
        long bytesToSend = MIN(blockSize, bytesRemaining);
        NSRange range = NSMakeRange(0, bytesToSend);
       
        NSString *partialLabel = [fullLabel substringWithRange:range];
       
        [[printer getToolsUtil] sendCommand:partialLabel error:&error];
       
        bytesRemaining -= bytesToSend;
       
        [fullLabel deleteCharactersInRange:range];
       
    }
    return error;
}

Also, whenever the user connects to the printer, it stores a few images on the printer using the following code:

// Save image to printer
id graphicsUtil = [self.printer getGraphicsUtil];
NSError *error = nil;
BOOL success = [graphicsUtil storeImage:pathOnPrinter withPathOnDevice:pathOnDevice withWidth:width andWithHeight:height error:&error];

It usually works fine, but I have received a bug report describing a locked-up printer. Shortly after printing a label, a user's ZQ520 printer became unresponsive, with a steady "envelope icon" on screen signifying that it is trying to receive data, but no data was being received because it was not blinking. He tried un-pairing and re-pairing the printer with the iPhone, and tried restarting the phone and the printer, but the printer still kept the steady "envelope icon" and wouldn't accept a new connection. Eventually, after re-pairing the printer's bluetooth connection to the phone multiple times, the "envelope icon" went away, and he was able to print again.

I haven't been able to reproduce this issue myself yet. Do you know how the LinkOS SDK could have put the printer in this unresponsive mode? And if so, what's the recommended way to monitor and avoid this situation using the LinkOS SDK?

Please Register or Login to post a reply

3 Replies

J John Priest

Hi Tanner. I'm not an iOS developer but the issue you described is what would occur if the BT connection is lost while data is being sent. As Steven indicated, the printer is waiting for the print job to complete. Next month a new firmware release for the printer will be available that will prevent this particular issue by clearing the printer's parser when the BT connection is lost.

T Tanner Semerad

Thanks for the responses. We were able to somewhat reproduce the error like Steven Si suggested, by not passing a ^XZ to finish the ZPL, but it was a little different. Restarting the iOS app would fix the issue, but the issue my user was seeing wouldn't be fixed by restarting the app, suggesting it's slightly different. So I'm thinking that my issue is probably a lost BT connection like John Priest suggested.

Thank you so much for the info. When the firmware comes out, I'll just follow the firmware upgrade instructions here and see if that does the trick. 

Y Yanis Dalabiras

When we see an envelope icon on the printer's display, it means the printer is waiting for more data. All ZPL starts with ^XA and ends with ^XZ. The printer has not received ^XZ, it will waits for it with the envelope icon. When the printer is in such state with an envelope icon, the printer will wait forever until it receives ^XZ. Once the ^XZ is received, the printer will exit this state. In order for the printer to exit the state of waiting for more data, the application can send the ^XA to the printer, providing the connection to the printer is still valid. If the connection is no longer valid, the application needs to open a new connection so it can send ^XZ to the printer.

If sending the ^XZ doesn't solve the problem, the only alternative is to reset the printer by pressing the reset button on the printer. Please note, the reset command won't work and will be ignored once the printer is in the state of waiting for more data.

CONTACT
Can’t find what you’re looking for?