Sunteți pe pagina 1din 9

Communication protocol for ECR operation mode fiscal

printer
General description
The fiscal printer operation mode is communication with Personal Computer. The sales are
requested by PC and the cash register makes the sale. The Cash Register keeps its functionality
in reporting modes. The only mode that needs PC to start some operation instead of operator is
the sales mode. The Cash Register database is not used in this operation mode. All sales details
are received from the connected PC. To operate in fiscal printer mode the cash register should
have the following parameter setting: P9 = 1, P12 = 1.

Protocol Description
Connection parameters:
Baud rate 9600 bps, 8 bits, no parity

Message format:
<marker><ECR No><command><data><crc><LF>

The exact data fields, enclosed by < and > are described in the following table:
Field Bytes Value
marker 1 Start of message 0x
ECR No 6 ASCII ('nnnnnn') manufacture number of the cash regsiter
command 1 'a'..'z' command
data ? variable character length in range 0x20 .. 0x8F
XOR over all bytes, including marker, formed in the following
crc 2 manner: XOR over all bytes - the result is byte of type 0xHL,
which is converted to 0x3H, 0x3L.
LF 1 End of message - always - 0x0A
Acknowledgment format:
<type><ECR No><crc><LF>

The exact data fields, enclosed by < and > are described in the following table:
Acknowledgement type 0x06 = ACK (possitve), 0x15 = NACK
(negative), 0x0 = RETRY (request re-sending of the command)
ECRNo 6 ASCII ('nnnnnn') ECR manufacture number
crc 2 XOR over all bytes, including marker, formed in the following manner:
type 1

XOR over all bytes - the result is byte of type 0xHL, which is converted
to 0x3H, 0x3L.
LF 1 End of message - always - 0x0A
Communication sequence:
PC: ECR:
command "start" ->
<-ACK
command "sale" ->
<-ACK
command "sale" ->
<-ACK
.......
<-ACK
command "TOTAL" ->
<-ACK
command "end" ->
<-ACK
<-command "receipt number"
ACK ->
The PC is the active side in the communication. The timeout for ACK receivement should be
circa 2sec. The communication process is receipt based. The cash register starts the printing after
the "end" command is received and "receipt number" is sent. If by any reason the communication
fails (invalid command or data, data loss) the ECR doesn't accumulate or print anything.
Warranty for successful receiving of data is the ACK and the "receipt number" command after
this the ECR prints the receipt. The ECR prints the header and footer of the receipt according to
the Romanian legislation and it is not necessary to send this text from PC.

Description of the PC commands


command "start":
<a>

data fields:
a 1 byte command- 'a'
ECR response: ACK or NACK
notes: This command should precede all other commands.
Command "parameters" (not obligatory)

<d><type>

data fields:
d 1 byte command - 'd'
type 1 byte command type ASCII number '0' to '9':
'0' - print invoice receipt including detailed VAT
'1' - print invoice receipt including detailed VAT plus receipt copy
'2' - print receipt copy (no invoice, no detailed VAT)
'3' - print detailed VAT in the receipt (not invoice)
'4' - print detailed VAT in the receipt (not invoice) + plus receipt copy
'5' - print receipt according to the ECR settings
'6' - detailed receipt with detailed VAT
'7' - detailed receipt with detailed VAT + plus receipt copy
'8' - detailed receipt without detailed VAT
'9' - detailed receipt without detailed VAT + plus receipt copy
ECR response: ACK or NACK
notes: This command should be right next the "start" command.
Command "free text":
<t><text>

data fields:
t 1 byte command - 't'
text 22 bytes ASCII text to be printed

ECR response: ACK or NACK


Command "Free text with long lenght":
<><text>

data fields:
1 byte command - ''
text 34 bytes text for printing
If the ECR support shorter text, the unecessary characters will be cutted.
ECR response: ACK or NACK

Command "sale-sum":
<s><sum><decimal point><VAT Group><department><group>

data fields:
s 1 byte command- 's'
sum 8 bytes sum (no decimal point) ASCII format
decimal point 1 byte decimal point position - ASCII number '0' or '2'
'0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
VAT Group 1 byte VAT Group - ASCII number '0' '5'
'0',5 no tax; '1' - group 'A'; '2' - group 'B'; '3' - group 'C';
'4' - group 'D'
department 1 byte department number of the sell. ASCII number '0' to '9'
group 1 byte group number of the sell. ASCII number '0' to '9'
ECR response: ACK or NACK
Command "sell-article" :
<p><name><sum><decimal point><quantity><VAT Group><department><group>

data fields:
p 1 byte command - 'p'
name 24 ASCII characters, including digits, capital Latin and Cyrillic letters,
that will be printed on the first 16 (!) positions of one line of the
receipt , as article description.
sum 8 bytes sum (no decimal point) ASCII format
decimal 1 byte decimal point position - ASCII number '0' or '2'
point '0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
quantity 9 ASCII digits , equal to quantity sold .
VAT Group 1 byte VAT Group - ASCII number '0' '5'
'0',5 no tax; '1' - group 'A'; '2' - group 'B'; '3' - group 'C';
'4' - group 'D'
department 1 byte department number of the sell. ASCII number '0' to '9'
group 1 byte group number of the sell. ASCII number '0' to '9'

ECR response: ACK or NACK


Command "discount/addition":
<m><+/-><sum><decimal point><VAT Group>

data fields:
m 1 byte command - 'm'
+/- 1 byte command type - '+' = addition, '-' = discount
sum 8 byte sum (no decimal point) ASCII format
decimal point 1 byte decimal point position - ASCII number '0' or '2'
'0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
VAT Group 1 byte VAT Group - ASCII number '0' '5'
'0',5 no tax; '1' - group 'A'; '2' - group 'B'; '3' - group 'C';
'4' - group 'D'
ECR response: ACK or NACK

Command "discount/addition":
<M><+/-><%/$><s/t><><decimal point>
m 1 byte command - 'm'
+/- 1 byte command type - '+' = addition, '-' = discount
%/$ 1 byte command type - '%' = percent, '$' = amount
s/t 1 byte command type - 's' = subtotal, 't' = transaction
sum 8 byte sum (no decimal point) ASCII format
decimal point 1 byte decimal point position - ASCII number '0' or '2'
'0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
ECR response: ACK or NACK

Command "payment":
<Q><number><name><sum><decimal point>

data fields:

Q 1 byte command- 'Q'


number 1 ASCII digit payment number '0' to '4' corresponding to the cash
register records
name 10 ASCII ( "IN CASH ")
sum 8 bytes sum (no decimal point) ASCII format
decimal 1 byte decimal point position - ASCII number '0' or '2'
point '0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
ECR response: ACK or NACK
Command "total":
<q><rate><number><name>

data fields:
q 1 byte command - 'q'
rate 9 bytes ASCII digits, corresponding to XXXX.XXXXX
number 1 ASCII digit payment number '0' to '4' corresponding to the cash register
records
name 6 ASCII characters payment name (example: " CASH")
ECR response: ACK or NACK
notes: to pay IN CASH the rate should be 000001000, the payment number '0' and the name "
"
The command is mandatory neverthless its unnecessery. Such case is Paid Out/Received on
Account sums (command 'I') and payment (command 'Q').
Command "Received on Account/ Paid Out sums":
<I><sign><sum><decimal point><name><payment type>

data fields:
I 1 byte command - 'I'
sign 1 character - + - Received on Account and -- Paid Out
sum 8 bytes sum (without decimal point) ASCII format
decimal point 1 byte decimal point position - ASCII number '0' or '2'
'0' = no decimal point, sum =
'2' = decimal point position 2, sum = .
name 6 ASCII characters payment name (example: " CASH")
payment type 1 ASCII digit payment type number

ECR response: ACK or NACK

Command "end":
<z>

data fields:
z 1 byte command - 'z'
ECR response: ACK or NACK
note: this must be the last command from PC to ECR

Description of the ECR commands

Command "receipt number":


<c><receipt number>

data fields:
c 1 byte command - 'c'
receipt 5 ASCII digits - number of the issued from the ECR receipt. "01234"
number for example
PC response: ACK

CRC calculation
The CRC is calculated by XOR over all bytes, including marker, formed in the following
manner: XOR over all bytes - the result is byte of type 0xHL, which is converted to 0x3H, 0x3L.
C/C++ Example:
// AddCRC: Adds CRC & END marker to a command
void AddCRC(unsigned char* cmd, unsigned int len)
{
unsigned int i;
unsigned char xor = 0;

for (i = 0; i < len; i++)


xor ^= cmd[i];
cmd[i++]
cmd[i++]
cmd[i++]
cmd[i] =

= (xor >> 4) | 0x30; // Calculate HIGH byte of CRC


= (xor & 0x0F) | 0x30; // Calculate LOW byte of CRC
= 0x0A; // Add end marker
0;
// Add zero to make it zero terminated

Auxiliary commands:
Command '?' - information about the serial number
<0x><'?'><crc><LF>

The exact data fields, enclosed by < and > are described in the following table:
Field Bytes Value
marker 1 start of message 0x
command 1 '?'
XOR over all bytes, including marker, formed in the following
crc 2 manner: XOR over all bytes - the result is byte of type 0xHL,
which is converted to 0x3H, 0x3L.
LF 1 End of message - always - 0x0A
These five bytes are used to find out the presence of Tremol communication protocol, as well as
finding out the serial number of the attached device.
Notice that the message format is differs from the standard format by missing ECR serial
number.
ECR response:
Field Bytes Value
type 1 Response type 0x0E = RETRY
ECR
6 ASCII ('nnnnnn') ECR serial number
Number
XOR over all bytes, including marker, formed in the following
crc 2 manner: XOR over all bytes - the result is byte of type 0xHL,
which is converted to 0x3H, 0x3L.
LF 1 End of message - always - 0x0A
This is the way for the application software to find out is there Tremol cash register attached to
the PC and what is it its manufacturing number.

Notes:

The sale can be described as sale-article, where name, price and quantity are send to the
cash register and the ECR calculates, prints and records the sum in its registers. In this
situation is possible to lose some accuracy in case the price is with more then 2 digits after
the decimal point. In such case is better to use the command free text to describe the sale
with name, price and quantity - as much lines as needed, 16 characters per line will be
printed - and the sum that will be recorder by the cash register to be sent by the sale-sum
command.
To print service receipt the commands start, free text, payment and end should be used.
All texts and names in Cyrillic are with MIK encoding (DOS Cyrillic). '' = 0x80 ... '' =
0x9F. For each cash register with start marker 0xAA is necessary to convert all small
letters in Cyrillic to capitals.

S-ar putea să vă placă și