I'm using the epson ePOS sdk to print to a TM-P60II from iOS. I can connect and print, but only once or twice. I get a timeout error after a try or two, then have to restart the app in order to print again. I've duplicated the error with their example in the sdk, and in the example on p37 in their manual. Looks like some kind of bug when closing/releasing the printer. I've asked their tech support for help but 1 month and 4 emails later and no reply. (Actually the front line support is good. 2nd tier is the problem.)
My question is, has anyone experienced this and developed a work-around? I'm considering trying the Zebra iMZ220 instead (comments on that move appreciated), but I'm 90% of the way there and would prefer not to start from scratch.
Thanks!
Here's what the p37 sample looks like:
UPDATE: Was contacted by Epson, turns out this is a known bug with iOS 7.1. No word yet on a fix.
UPDATE2: New sdk out... still doesn't work. However, if you launch it in a separate queue that seems to take care of the problem. When the queue is auto released the non-released printer item goes with it. Better practice anyway providing I haven't just created a memory leak.
UPDATE3: See below for code. Yes it's not polished. Note that PrinterUtils is just my wrapper around the epson print functions. Any comments welcome and HTH.
id builder2 = [[EposBuilder alloc] initWithPrinterModel: @"TM-P60II" Lang: EPOS_OC_MODEL_ANK];
if (builder2 != nil) {
errorStatus = EPOS_OC_SUCCESS;
//Create a print document
errorStatus = [builder2 addText: @"Hello,\t"];
errorStatus = [builder2 addText: @"World!\n"];
errorStatus = [builder2 addCut: EPOS_OC_CUT_FEED];
//Initialize an EposBuilder class instance for confirmation
id conBuilder2 = [[EposBuilder alloc] initWithPrinterModel: @"TM-P60II" Lang: EPOS_OC_MODEL_ANK];
//Initialize an EposPrint class instance
id printer2 = [[EposPrint alloc] init];
unsigned long status;
int connectionType = EPOS_OC_DEVTYPE_BLUETOOTH;
if (printer2 != nil) {
//<Start communication with the printer>
errorStatus = [printer2 openPrinter:connectionType DeviceName:macAddress Enabled:EPOS_OC_FALSE Interval:EPOS_OC_PARAM_DEFAULT];
//Send Data for confirmation
errorStatus = [printer2 sendData:conBuilder2 Timeout:10000 Status:&status];
if ((errorStatus = EPOS_OC_SUCCESS && (status & EPOS_OC_ST_OFF_LINE ) != EPOS_OC_ST_OFF_LINE) ) {
//<Send print data>
errorStatus = [printer2 sendData:builder2 Timeout:10000 Status:&status]; }
//<End communication with the printer>
errorStatus = [printer2 closePrinter];
}
}
//------- Workaround --------
// Busy Spinner
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.center = CGPointMake (self.view.bounds.size.width * 0.5F, self.view.bounds.size.height * 0.5F);
spinner.hidesWhenStopped = YES;
[self.view addSubview:spinner];
[spinner startAnimating];
spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
// Launch new queue
dispatch_queue_t myQueue = dispatch_queue_create("My Sync Queue",NULL);
dispatch_async(myQueue, ^{
PrinterUtils *pu = [[PrinterUtils alloc] init];
EposBuilder *builder = [pu getNewEposBuilder];
EposPrint *printer = [pu getNewEposPrinter];
[pu setPrintStyle:PRINTSTYLE_BODY2 eposBuilder:builder];
[pu loadTextLine:@"bm print to tm-p60II" eposBuilder:builder];
[pu print:builder eposPrint:printer ];
[pu closePrinterConnection];
dispatch_async(dispatch_get_main_queue(), ^{
// Update the UI
[spinner stopAnimating];
});
});