在Linux上通过USB发送原始数据
我正在 Zebra TLP-2844 打印机上打印一些标签,并且通过将 EPL 指令发送到共享 USB 打印机,在 Windows 上做得很好,如下所示:
输入 Label.prn > \my-pc\斑马
似乎也可以使用串行端口,
输入 Label.prn > COM1
现在我尝试在 Linux 上做同样的事情,但它变得非常困难!我的第一个猜测是:
猫标签.prn | /dev/bus/usb/005/002
因为我的打印机位于总线 005、设备 002 上(使用 lsusb 命令检查),但它根本不起作用,因为我得到以下信息:
bash:/dev/bus/usb/005/002:权限被拒绝
任何猜测吗?
I'm printing some labels on a Zebra TLP-2844 printer, and have been doing it fine on Windows by sending the EPL instructions to the shared USB printer as follows:
type Label.prn > \my-pc\zebra
and it seems to work with serial ports too, with
type Label.prn > COM1
Now I'm trying to to the same on Linux, but it's getting really hard! My first guess was:
cat Label.prn | /dev/bus/usb/005/002
since my printer is on bus 005, device 002 (checked it with lsusb
command) but it doesn't work at all, as I get the following:
bash: /dev/bus/usb/005/002: Permission denied
Any guesses?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您执行的命令
将尝试运行
/dev/bus/usb/005/002
,该命令不可执行,因此“权限被拒绝”。正确的命令是,类似于 Windows
但是,不确定您是否真的可以像 Linux 中那样向打印机写入任何内容。如果打印机设置正确,您还可以尝试:
The command you did
will try to run
/dev/bus/usb/005/002
, which is not executable, hence "permission denied".The correct command would be, similar to windows
However, not sure if you actually can write anything to a printer like that in linux. If the printer is set up properly, you might also try:
以防其他人尝试访问原始 USB 打印机端口;通过将您的用户添加到“lp”组可以避免“权限被拒绝”问题,如下所示:
其中 USERNAME 是您的用户名。
In case anyone else is trying to access raw USB printer ports; The "permission denied" problem is circumvented by adding your user to group "lp", like so:
where USERNAME is your username.
对不起,我的英语。
我在这里进行了测试,我的打印机 TLP2844 连接在 USB 上,在我的带有 linux 的嵌入式 arm9 板上。
我在命令提示符下输入:
printf "OD\r\nN\r\nD5\r\nS2\r\nZT\r\nQ128, 24\r\nq400\r\nA15,10,0,2,1,1, N,\"测试\"\r\nP1\r\nFE\r\n" > /dev/lp0
和...打印的TEST
Sorry by My english.
I tested here, my printer TLP2844 connect on USB, in my embedded arm9 board with linux.
I typed in command prompt:
printf "OD\r\nN\r\nD5\r\nS2\r\nZT\r\nQ128, 24\r\nq400\r\nA15,10,0,2,1,1,N,\"TESTE\"\r\nP1\r\nFE\r\n" > /dev/lp0
and... the TEST printed
您还可以在 Sublime Text 中创建自己的构建系统,例如:
并在完成标签编辑后立即按 Ctrl+B 键将文件发送到打印机。
或者您可以尝试我的工具通过 TCP/IP 将 zpl 标签发送到打印机:
https://github.com/kashamalasha/AutoIt_ZebraTester
它是用 AutoIt Script 语言编写的,所以你需要安装 AutoIt 来构建它。不幸的是,没有英语描述,只有俄语,但如果你需要的话,我很快就能写出来。
sudo chmod a+w /dev/usb/lp0
cp test.zpl /dev/usb/lp0
Also you can create your own build system in Sublime Text for example:
and send files to the printer by pressing Ctrl+B keys immediately after finishing edit the label.
Or you can try my tool to send zpl labels to the printer via TCP/IP:
https://github.com/kashamalasha/AutoIt_ZebraTester
It was written on AutoIt Script language, so you need to install AutoIt to build it. Unfortunately there is no description on English, only Russian, but I can write it very soon, if you will need it.