iOS 9.0 Xcode 8.3.3 MfiBtPrinterConnection.h 传输蓝牙 maxLength Zebra ZQ520

标签 ios xcode bluetooth zebra-printers

我正在使用 Zebra 打印机 sdk,特别是我有一台 Zebra ZQ520。 我正在尝试从 Xcode (Object-C) 中的项目向打印机发送一个字符串(采用名为“zpl”的专有语言)。

在此阶段之前,我将 * .pdf 转换为 * .grf 图像,我获取整个字符串并启动打印机。到目前为止,它一直有效,但如果我使用更复杂的 pdf,我会收到此错误。

ERROR - /BuildRoot/Library/Caches/com.apple.xbs/Sources/ExternalAccessory/ExternalAccessory-353.50.4/EAOutputStream.m:-[EAOutputStream write: maxLength:] - 283 failed to write because stream does not have space available

我检查了我创建的连接来自 MfiBtPrinterConnection.h 类,并且通过该实例,我创建的连接只能使用 setTimeToWaitAfterWriteInMilliseconds 和 setTimeToWaitAfterReadInMilliseconds 方法触摸两个值。 SDK手册告诉你尽量增加时间,以防写入出现问题。我尝试了 30 秒,但没有任何效果。不幸的是我无法访问源代码。

最佳答案

我今天遇到了这个错误,尽管我的内容有所不同,希望它会对您有所帮助。我必须将 .write 命令放在后台线程上。

             var error:NSError?
             DispatchQueue.global(qos: .background).async {
                MfiBtPrinterConnection?.write(data, withOffset: 0, andWithLength: data.count - 1, error: &error)
                if error != nil {
                print("Error executing data writing \(String(describing: error))")
             }

现在我的数据可以正常打印了。

关于iOS 9.0 Xcode 8.3.3 MfiBtPrinterConnection.h 传输蓝牙 maxLength Zebra ZQ520,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46285568/

相关文章:

ios - 为什么 [[UIScale mainScreen] scale] 1 在带有 Xcode 4.2 的 iPad 3 上?

iphone - 多次按下按钮会导致 ios cocoa 中的单一操作

ios - 未返回十进制值的成就的百分比完成

ios - UIView 中嵌入的动态 UITableView - 计算高度

ios7:如何跟踪通知等系统内部信息

ios - 为 Apple Mail 创建一个插件

android - 在Android中通过蓝牙接收音频

windows-8 - Windows 8 低功耗蓝牙 API 示例

java - 蓝牙在Java中同时充当客户端/服务器

ios - Swift 中 NSUserDefaults 的安全性