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

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

问题描述

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

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

我目前正在开发收银机软件,但在使用收据打印机时遇到了问题.我需要能够通过 DOS 向打印机发送十六进制命令.

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.

打开 CMD输入复制con:com1输入一个十六进制数按 Ctrl + Z按回车

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.

有关打印机即时使用的一些信息:TPG A794 收据打印机.可以在此处找到有关打印机的手册:http://www.cognitivetpg.com/downloads/A794%20Spec%20Sheet.pdf

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.

推荐答案

不要输入Hex-Code.您需要十进制的 ASCII 码.例如:要写0xF,必须转成十进制(15)在 copy con: com1 输入三位数的十进制值 ( 015 ) 时按ALT"(按住它),然后释放ALT".如果它是具有多个 HexNumber 的命令,则继续下一个值.完成后,按 Ctrl-Z.

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.

它可能更容易使用,如果您将命令"写入文本文件,那么您可以将它们复制到 com1:例如:

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)

我试过了

copy con bell.txt

然后我输入007(= 0x07,这是一个铃铛),Ctrl-Z.这给出了一个长度为 1 字节的文本文件

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

Type bell.txt

然后会发出哔哔声.

编辑1B"是所谓的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 描述了您与哪个抽屉交谈.

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每个命令创建一个文件.例如.open1.bin"close1.bin"等.按照我的第一个答案中的描述创建它们.您应该首先尝试使用简单"命令(单字节命令)来验证是否可以正常工作.要执行这些命令,请使用 copy open1.bin com1: 将它们发送到 com 1.对于多字节命令,使用 copy con: file.txt 创建它们,同时按住alt"输入第一个值,释放alt",再次按下并按住第二个值,依此类推.

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天全站免登陆