如何通过COM1将DOS命令发送到收据打印机? [英] How do i send DOS commands to my Receipt printer via COM1?

查看:272
本文介绍了如何通过COM1将DOS命令发送到收据打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过COM1向我的收据打印机发送DOS命令?



当前使用收银机软件,我遇到了问题。我需要能够通过DOS发送十六进制命令到打印机。



到目前为止我已经尝试做以下操作。



打开CMD
输入复制con:com1
输入十六进制数字
按Ctrl + Z
按Enter键



这根据我已经读取应该发送十六进制数字作为命令到打印机。



打印机im上的一些信息使用:
TPG A794收据打印机。
a打印机上的手册可以在这里找到:
http: //www.cognitivetpg.com/downloads/A794%20Spec%20Sheet.pdf



希望有人能帮助我,因为我已经尝试过一切,没有什么似乎工作。

解决方案

不要输入十六进制代码。您需要十进制中的ASCII码。
例如:要写入0xF,必须在 copy con:com1 之后将它转成十进制(15)
>按'ALT' ),同时输入三位数(015)的十进制值,然后释放'ALT'。
如果是带有多个HexNumber的命令,继续下一个值。
完成后,按Ctrl-Z。



这可能很容易使用,如果您将命令写入文本文件, to com1:
例如:

 复制换行com1:

(我没有要测试的串行设备,但它应该工作)



  copy con bell.txt 

然后,我输入了 007 (= 0x07,这是一个贝尔), Ctrl-Z 。这给出一个lenght = 1字节的文本文件

 输入bell.txt 

是所谓的Escape-Sequence(多字节命令)的代码。70是命令本身,并且它需要三个参数(n,p1,p2)。所以完整的序列是5个字节长。您必须用适当的数字替换n,p1和p2。你将在你的串行设备手册中找到那些(1B是所谓的Escape-Sequence的代码(一个多字节命令)70是命令本身,如你所描述的,它需要三个参数(n,p1,p2),所以完整的序列是5个字节长,你必须用适当的数字替换n,p1和p2设备( http://www.cognitivetpg.com/downloads/189) -9200250C.pdf ),第69页。P1和P2似乎描述了时间,抽屉需要打开/关闭)N描述您要与哪个抽屉交谈。



EDIT2
为每个命令创建一个文件。例如。 open1.binclose1.bin等。按我的第一个答案中所述创建它们。你应该首先尝试用简单命令(一个字节命令)来验证,这是正常的。要执行命令,使用 copy open1.bin com1:将它们发送到com 1。对于多字节命令,用 copy con:file.txt创建它们。在保持alt的同时输入第一个值,释放alt,再次按下,第二个值等。


How do i send DOS commands to my Receipt printer via COM1?

Im currently devoloping a Cash register software, and i ran into an issue using the receipt printer. i need to be able to send hexidecimal commands to the printer via DOS.

so far i've tried to do the following.

Open CMD input Copy con: com1 input a hexidecimal number press Ctrl + Z press Enter

this according to what i've read should send the hexidecimal number as a command to he printer. but instead it just sends the number as a string and prints out the text.

some info on the printer im using: TPG A794 receipt printer. a manual on the printer can be found here: http://www.cognitivetpg.com/downloads/A794%20Spec%20Sheet.pdf

hope someone can help me out, as i've tried everything, and nothing seems to work.

解决方案

Do not enter the Hex-Code. You need the ASCII-Code in Decimal. For example: to write 0xF, you must turn it into decimal (15) after copy con: com1press 'ALT' (keep it pressed) while you enter the decimal value with three digits ( 015 ), then release 'ALT'. Continue with the next value, if it is a command with more than one HexNumber. When finished, press Ctrl-Z.

It may be easyer to use, if you write your "commands" to a textfile, then you can copy them to com1: for example:

copy linefeed com1:

(I have no serial device to test, but it should work)

I tried it with

copy con bell.txt

Then I entered 007 (= 0x07, which is a Bell), Ctrl-Z. This gives a textfile with lenght = 1 byte

Type bell.txt

will then beep.

EDIT "1B" is the Code for a so-called "Escape-Sequence" (a multi-byte-command) "70" is the command itself and it needs three parameters (n, p1, p2). So the complete Sequence is 5 bytes long. You will have to replace "n", "p1" and "p2" with proper numbers. You will find those in the manual of your serial device ("1B" is the Code for a so-called "Escape-Sequence" (a multi-byte-command) "70" is the command itself and as you describe it, it needs three parameters (n, p1, p2). So the complete Sequence is 5 bytes long. You will have to replace "n", "p1" and "p2" with proper numbers. You will find those in the manual of your serial device (http://www.cognitivetpg.com/downloads/189-9200250C.pdf), Page 69. P1 and P2 seem to describe the time, the drawer needs to open/cose) N describes which drawer you talk to.

EDIT2 create one file per command. eg. "open1.bin" "close1.bin" etc. Create them as described in my first answer. You should first try with "simple" commands (one-byte-commands) to verify, that this works ok. To execute the commands, send them to com 1 using copy open1.bin com1:. For multibyte commmands create them with copy con: file.txt Enter first value while you keep "alt" pressed, release "alt", press it again and keep it pressed for the second value and so on.

这篇关于如何通过COM1将DOS命令发送到收据打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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