使用JAVA或批处理文件打开现金抽屉 [英] Opening a Cash Drawer using JAVA or Batch File

查看:195
本文介绍了使用JAVA或批处理文件打开现金抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台合作伙伴RP-300收据打印机,附有一个现金抽屉用于实验目的。它通过LPT1连接到PC。

I have a Partner RP-300 receipt printer with a cash drawer connected to it for experimental purposes.It connects to the PC via LPT1.

我想要通过java应用程序或批处理文件打开现金抽屉。

I would like to open the cash drawer by means of a java application or a batch file.

任何想法?

编辑
我发现打开抽屉的命令是ESC p,十六进制值\ x1b \ x70 \ x00,

EDIT I have found out that the command to open the drawer is ESC p, hex value \x1b\x70\x00,

但我该怎么发送使用cmd?命令打印机,我尝试将后者放在文本文件中,然后使用copy \b文件名lpt1,但它只打印打印机上文本文件的内容。

but how do I send that command to the printer using cmd?, I tried putting latter in a text file, then using copy \b file name lpt1, but it just prints the contents of the text file on the printer.

推荐答案

我查看了手册,该命令还包含两个参数,脉冲开启和脉冲关闭。这里也有很好的解释:如何设置现金抽屉打开
因此命令是 ESC p m t1 t2 ,其中m与连接器引脚有关,t1,t2为高/低时间。
你只发送 ESC p 0(\ x1b \ x70 \ x00),你应该这样做。 ESC p 0 25 250(\ x1b \ x70 \ x00 \ x19 \ xfa)

I have looked into the manual and the command includes two more parameters, pulse on and pulse off. It's also well explained here: How to program cash drawer to open. So the command is ESC p m t1 t2, where m is relating to connector pin, and t1, t2 are high/low times. You send only ESC p 0 (\x1b\x70\x00), while you should do eg. ESC p 0 25 250 (\x1b\x70\x00\x19\xfa)

copy / b是将控制命令发送到打印机的完全有效的方式,它应该工作。

copy /b is perfectly valid way of sending your control commands to the printer and it should work.

使用任何十六进制编辑器确保您的文件包含正确的十六进制序列。

Just make sure that your file does include proper hex sequence using any hex editor.

希望这会有所帮助

编辑:技术手册链接

编辑:获取在文件中编码的命令序列(长而简单):

1。获取Notepad ++

2。检查你是否在插件下安装了Converter。如果没有,找到并安装它

3。在Notepad ++

4中创建新文件。在编码

5下选择ANSI。输入1b700019fa


6。选择(突出显示)您输入的字符串(或使用Ctl-A选择所有字符串)

7。转到插件 - >转换器 - > HEX - > ASCII

8。你应该看到乱码输出(里面有字母p)。节省

9。将文件发送到打印机。

To get command sequence encoded in file (long but easy):
1. Get Notepad++
2. Check you have Converter installed under plugins. If not, find and install it
3. Create new file in Notepad++
4. Select ANSI under encoding
5. Enter 1b700019fa

6. Select(highlight) string you entered (or select all with Ctl-A)
7. Go to plugins->Converter-> HEX --> ASCII
8. You should see garbled output (with letter p inside). Save
9. Send your file to printer.

这篇关于使用JAVA或批处理文件打开现金抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆