【问题标题】:ePOS2 SDK: How to keep connection to printer alive?ePOS2 SDK:如何保持与打印机的连接?
【发布时间】:2018-02-09 22:26:58
【问题描述】:

我正在使用 Epson 的 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 秒吗?

【问题讨论】:

    标签: ios epson epos


    【解决方案1】:

    原来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()
    

    【讨论】:

      猜你喜欢
      • 2012-05-31
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      相关资源
      最近更新 更多