【发布时间】:2014-05-11 06:48:54
【问题描述】:
我正在使用 epson ePOS sdk 从 iOS 打印到 TM-P60II。我可以连接和打印,但只有一两次。一两次尝试后出现超时错误,然后必须重新启动应用程序才能再次打印。我已经用他们在 sdk 中的示例以及他们手册中 p37 的示例中复制了错误。关闭/释放打印机时看起来像某种错误。我已经向他们的技术支持寻求帮助,但 1 个月和 4 封电子邮件后没有回复。 (其实前线支持也不错,2级才是问题。)
我的问题是,有没有人经历过这种情况并开发了解决方法?我正在考虑改用 Zebra iMZ220(对此表示赞赏),但我已经完成了 90% 的工作,我不想从头开始。
谢谢!
p37 示例如下所示:
更新:已与 Epson 联系,结果发现这是 iOS 7.1 的一个已知错误。目前还没有关于修复的消息。
UPDATE2:新的 sdk 出...仍然无法正常工作。但是,如果您在似乎可以解决问题的单独队列中启动它。当队列自动释放时,未释放的打印机项目随之而来。无论如何,如果我不只是造成内存泄漏,那就更好的做法。
UPDATE3:代码见下文。是的,它没有抛光。请注意,PrinterUtils 只是我对 epson 打印功能的包装。欢迎任何 cmets 和 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];
}
}
//------- 解决方法--------
// 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];
});
});
【问题讨论】:
-
天哪,我整天都在用头撞墙。感谢发帖!
-
有人提出解决方案了吗?我们正在与爱普生合作解决此问题,但尚未收到他们的回复。
-
好的,看到发送更新了。我会试试你的建议。
标签: ios printing bluetooth epson