2017-08-31 138 views
0

我使用Epson的ePOS2 SDK与收据打印机TM-M30进行通信。
我能够成功连接到打印机并打印一些数据。
完成打印后,我保持与打印机的连接,所以下次需要打印一些内容时,我不会再次连接到打印机。ePOS2 SDK:如何保持与打印机的连接活着?

然而,连接只存活了90秒。后闲置连接打印机90秒被丢弃,Epos2Printer通知委托该电源关闭:

func onPtrStatusChange(_ printerObj: Epos2Printer, eventType: Int32) { 
    let eventStatus = Epos2StatusEvent(rawValue: eventType) 
    // Event status is EPOS2_EVENT_POWER_OFF here 
} 

我没有看到任何参数Epos2Printer保持连接活着。

有谁知道如何强制打印机保持连接超过90秒?

回答

0

结果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()