我正在使用爱普生公司的ePOS2 SDK与收据打印机TM-M30通信.
我能够成功地连接到打印机并打印一些数据。
完成打印后,我将保持与打印机的连接,所以下次我需要打印一些不连接到它的东西。
但是,连接只运行90秒。在90秒的不活动连接打印机被删除后,Epos2Printer通知委托电源关闭:
func onPtrStatusChange(_ printerObj: Epos2Printer, eventType: Int32) {
let eventStatus = Epos2StatusEvent(rawValue: eventType)
// Event status is EPOS2_EVENT_POWER_OFF here
}我没有看到任何参数可以使Epos2Printer保持连接正常。
有人知道如何迫使打印机保持连接超过90秒吗?
发布于 2017-08-31 22:59:22
结果显示,Epos2Printer使用TCP连接与打印机通信,TCP本身在90秒内删除连接。
为了避免这种情况,我在85秒钟不活动后向空打印机端口发送现金抽屉信号:
printer.addPulse(EPOS2_DRAWER_5PIN.rawValue, time: EPOS2_PULSE_100.rawValue)
printer.beginTransaction()
printer.sendData(Int(EPOS2_PARAM_DEFAULT))
printer.endTransaction()
printer.clearCommandBuffer()https://stackoverflow.com/questions/45990355
复制相似问题