- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 TM-T20II 热敏打印机打印收据。这是我的代码:
from escpos import printer
from escpos import *
import escpos
from escpos import config
import usb.core
import usb.util
import usb.backend.libusb1
from ctypes import c_void_p, c_int
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "libusb-1.0.dll")
backend.lib.libusb_set_option.argtypes = [c_void_p, c_int]
backend.lib.libusb_set_option(backend.ctx, 1)
p = printer.Usb(0x04b8,0x0e15,0,0x82,0x01, backend=backend)
p.text('test')
我正在使用 usbdk 后端,如果没有它,我会收到“NotImplementedError: Operation not supported or unimplemented on this platform”。我这样做是因为为了让我的程序正常工作,我需要使用默认的 Epson 驱动程序。当我运行此代码时,我得到的错误是:
<File "C:\Users\maxsl\anaconda3\lib\site-packages\usb\core.py", line234, in get_interface_and_endpointreturn self._ep_info[endpoint_address]
KeyError: 1
During handling of the above exception, another exception occurred:
File"C:\Users\maxsl\anaconda3\lib\site-packages\usb\backend\libusb1.py",line 604, in _checkraise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno None] Other error>
p.text()
时才会出现此错误在。找到打印机和其他一切都没有问题。我也想说
write()
在 PyUSB 模块中工作,但对我来说不必将程序中的输出翻译成令人困惑的 ESC/P 语言会更方便。
最佳答案
是不是打印机的USB模式设置有问题?
TM-T20II打印机有USB厂商定义类(COM Port)和USB打印机类两种模式。
VID/PID 分别为 USB 供应商定义的 class=0x04b8:0x0202 和 USB 打印机 class=0x04b8:0x0e15。
TM-T20II Technical Reference Guide第 89 页
您应该可以使用打印机的设置实用程序对其进行更改。
或者,尝试将 PID 指定按原样更改为 0x0202,或尝试作为 COM 端口而不是原始 USB 设备进行通信。
或者,高级打印机驱动程序或 Windows 打印后台处理程序可能已在使用该设备,而其他程序无法使用。
如果已安装设备驱动程序,请尝试将其卸载。
关于python - 将 text() 与 python-escpos 一起使用时,我得到 [Errno None] 和 key error = 1 (windows 10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62852884/
嗨,我正在实现一个 python 脚本,该脚本应该在小型 58mm POS 热敏打印机上“实时”打印一些文本。为此,我使用 python-escpos 库。一切运行正常,但我发现打印机在脚本完成后开始
我正在开发一个项目,该项目从通用源读取数据,使用 swing 形成图像,然后将图像(一行图像)转换为 escpos 命令并将其发送到打印机。 为了将图像传输到 escpos 代码,我使用了 java-
我必须打印原始文本打印机,我必须在其中设置代码页字符集。我发现最适合我的应用程序的字符集是 IBM858。现在的问题是将字符串编码为该代码页。 我试过这个: test = new String("#$
我正在尝试使用热敏打印机进行打印,我正在使用 node-escpos 模块进行打印,它在 linux 上运行良好,但在 Windows 中出现错误。node escpos LIBUSB_ERROR_N
使用 Debian,安装 escpos,以便能够在 Epson TM-T20II 打印机上打印,我在 python3 上有一个应用程序。我遇到的问题是当我发送打印时它会生成以下错误: File "/m
我想将土耳其语打印参数从 react-native 应用程序发送到 bixolon spp-r310 打印机。 我的代码是: async print(BBcolumn, txtObj, isBold,
我正在尝试在 Windows 7(64 位)上使用 Epson POS TM-82 打印机。我已经安装了打印机的驱动程序。我安装了 python 2.7.15(64 位)。为了使用 python,我使
我正在使用 Java 构建一个 POS 桌面应用程序,该应用程序使用热敏打印机打印交易收据。我发现我可以使用 escpos 和 JSerialComm Java API 来实现这一点。我从 GitHu
我想通过 Python 控制 Epson 打印机。该打印机相当新(最近 2 年),因此规范说明其语言是 ESC/P R。这与 ESC/P 兼容吗?维基百科文章称 ESC/P R 是打印机语言的较新变体
我正在尝试使用 TM-T20II 热敏打印机打印收据。这是我的代码: from escpos import printer from escpos import * import escpos fro
我是一名优秀的程序员,十分优秀!