[英]ePOS2 SDK: How to keep connection to printer alive?
I am using ePOS2
SDK from Epson to communicate with receipt printer TM-M30. 我正在使用Epson的
ePOS2
SDK与收据打印机TM-M30通信。
I am able to successfully connect to printer and print some data. 我能够成功连接到打印机并打印一些数据。
After finishing printing I am keeping connection to printer, so next time I need to print something I don't connect to it again. 完成打印后,我将保持与打印机的连接,因此下一次我需要打印某些内容时,不再连接它。
However connection is alive for only 90 seconds. 但是,连接仅存活90秒。 After 90 seconds of inactivity connection printer is dropped and
Epos2Printer
notifies delegate that power is off: 闲置90秒后,打印机断开连接,
Epos2Printer
通知代表电源已关闭:
func onPtrStatusChange(_ printerObj: Epos2Printer, eventType: Int32) {
let eventStatus = Epos2StatusEvent(rawValue: eventType)
// Event status is EPOS2_EVENT_POWER_OFF here
}
I don't see any parameters for Epos2Printer
to keep connection alive. 我看不到
Epos2Printer
任何参数来保持连接有效。
Does anybody know how force printer to keep connection beyond 90 seconds? 有人知道如何迫使打印机保持连接90秒以上吗?
Turned out Epos2Printer
uses TCP connection to communicate with printer and TCP itself drops connection in 90 seconds. Epos2Printer
证明, Epos2Printer
使用TCP连接与打印机进行通信,TCP本身在90秒内断开了连接。
To avoid this I am sending signal to empty printer port for cash drawer after 85 seconds of inactivity: 为避免这种情况,我在闲置85秒后将信号发送到用于钱箱的空打印机端口:
printer.addPulse(EPOS2_DRAWER_5PIN.rawValue, time: EPOS2_PULSE_100.rawValue)
printer.beginTransaction()
printer.sendData(Int(EPOS2_PARAM_DEFAULT))
printer.endTransaction()
printer.clearCommandBuffer()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.