0

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.

1 Answer 1

2

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.

11
  • Thank you so much for this! cant tell you how much i appritiate it! you just saved me like 500$ if not more! :D Commented Jun 6, 2013 at 23:24
  • I got 1 more issue that i simply cant understand. im hoping maybe you know what to do with it for an Example i need to enter the following code to the printer to make it open my cash register. 1B 70 n p1 p2. my problem is, i dont understand what n p1 and p2 is.. n seems to be used alot and it seems to be binary, but im not able to figuer out how to put it into the command. Commented Jun 7, 2013 at 1:50
  • edited my answer, as it is too long for a comment.
    – Stephan
    Commented Jun 7, 2013 at 5:49
  • Thanks alot for this. im still struggeling to understand how i should input this into CMD, is there any chance you could give me an Example on what to put into CMD? i really appritiate your help here, wouldnt have come this far without it. Commented Jun 7, 2013 at 10:07
  • create one file per command. eg. "open1.bin" "close1.bin" etc.
    – Stephan
    Commented Jun 7, 2013 at 12:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.