Skip to content

Commit b7dd9f3

Browse files
committed
Bump version
1 parent 80c9676 commit b7dd9f3

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
class EscposCommands {
2+
constructor(configs) {
3+
this.getStatusCommand = "\u0010\u0004\x01";
4+
this.getOfflineCauseCommand = "\u0010\u0004\x02";
5+
this.getErrorCauseCommand = "\u0010\u0004\x03";
6+
this.getRollPaperStatusCommand = "\u0010\u0004\x04";
7+
this.configs = configs;
8+
}
9+
10+
/**
11+
* @returns {number[]} - The status byte for the escpos printer
12+
*/
13+
getEscposStatus() {
14+
let returnBytes = [0x00];
15+
if (![1, "1", true, "true"].includes(this.configs.escposOnline)) {
16+
// Bit 3 set indicates that the printer is offline
17+
returnBytes[0] |= 0b00001000;
18+
}
19+
if ([1, "1", true, "true"].includes(this.configs.escposPaperFeedPressed)) {
20+
// Bit 6 set indicates that the paper feed button is pressed
21+
returnBytes[0] |= 0b01000000;
22+
}
23+
24+
return returnBytes;
25+
}
26+
27+
getOfflineCause() {
28+
let returnBytes = [0x00];
29+
30+
if ([1, "1", true, "true"].includes(this.configs.escposCoverOpen)) {
31+
// Bit 2 set indicates that the cover is open
32+
returnBytes[0] |= 0b00000100;
33+
}
34+
35+
if ([1, "1", true, "true"].includes(this.configs.escposPaperBeingFed)) {
36+
// Bit 3 set indicates that the paper is being fed by the paper feed button
37+
returnBytes[0] |= 0b00001000;
38+
}
39+
40+
if ([1, "1", true, "true"].includes(this.configs.escposPaperEnd)) {
41+
// Bit 5 set indicates that the paper is being fed by the paper feed button
42+
returnBytes[0] |= 0b00100000;
43+
}
44+
45+
if ([1, "1", true, "true"].includes(this.configs.escposErrorOccurred)) {
46+
// Bit 6 set indicates that an error has occurred
47+
returnBytes[0] |= 0b01000000;
48+
}
49+
50+
return returnBytes;
51+
}
52+
53+
getErrorCause() {
54+
let returnBytes = [0x00];
55+
56+
if ([1, "1", true, "true"].includes(this.configs.escposRecoverableError)) {
57+
// Bit 2 set indicates that a recoverable error has occurred
58+
returnBytes[0] |= 0b00000100;
59+
}
60+
61+
if ([1, "1", true, "true"].includes(this.configs.escposCutterError)) {
62+
// Bit 3 set indicates that an auto cutter error has occurred
63+
returnBytes[0] |= 0b00001000;
64+
}
65+
66+
if ([1, "1", true, "true"].includes(this.configs.escposUnrecoverableError)) {
67+
// Bit 5 set indicates that an unrecoverable error has occurred
68+
returnBytes[0] |= 0b00100000;
69+
}
70+
71+
if ([1, "1", true, "true"].includes(this.configs.escposAutoRecoverableError)) {
72+
// Bit 6 set indicates that an auto recoverable error has occurred
73+
returnBytes[0] |= 0b01000000;
74+
}
75+
76+
return returnBytes;
77+
}
78+
79+
getRollPaperStatus() {
80+
let returnBytes = [0x00];
81+
82+
if ([1, "1", true, "true"].includes(this.configs.escposPaperLow)) {
83+
// Bit 6 set indicates that the paper is low
84+
returnBytes[0] |= 0b00001100;
85+
}
86+
87+
return returnBytes;
88+
}
89+
}
90+
91+
module.exports = EscposCommands;

new 2.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/u001B@/u001B!/u0000/u001BM/u0000/u001D!/u0000/u001BE/u0001NUM: -- /u001BE/u0000
2+
/u001BE/u0001MESA:/u001BE/u0000 Mesa 2
3+
/u001BE/u0001RESP:/u001BE/u0000 Administrador/u001BE/u0001
4+
CANT. DETALLE/u001BE/u0000
5+
------------------------------------------------
6+
7+
/u001BE/u0001-> 1/u001BE/u0000 Formula 1
8+
9+
/u001BE/u0001-> 1/u001BE/u0000 Formula 1
10+
/u001BE/u0001 - /u001B/u002D1SIN/u001B/u002D0/u001BE/u0000 Materia Prima 2
11+
/u001BE/u0001 - /u001B/u002D1SIN/u001B/u002D0/u001BE/u0000 Materia Prima 3
12+
/u001BE/u0001 *PARA LLEVAR - Esta es una nota/u001BE/u0000
13+
/u001BE/u0001 + 1/u001BE/u0000 Formula 2
14+
/u001BE/u0001 Mas salsas/u001BE/u0000
15+
16+
17+
/u001D!/u0000/u001DVA/u0003

new1.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
\u001B@\u001B!\u0000\u001BM\u0001\u001Ba\u0001\u001BE\u0001EMPRESA CIA LTDA
2+
\u001BE\u0000EMPRESA
3+
RUC: 9999999999001
4+
\u001Ba\u0000AV. ARENILLAS Y JOSE MENDOZA
5+
TELF.: 1234567890 - 1234567890
6+
OBLIGADO A LLEVAR CONTABILIDAD
7+
8+
\u001Ba\u0001F A C T U R A
9+
\u001Ba\u0000No.: \u001BE\u0001001-001-000001911\u001BE\u0000 FECHA: \u001BE\u000108/02/2018\u001BE\u0000
10+
CLAVE DE ACCESO/AUTORIZACION:
11+
\u001BE\u00010802201801079173379000120010010000019111234567819\u001BE\u0000
12+
CLIENTE: 0799999999 - MARIA DE LA ROSA
13+
DIRECC.: PEAJE\u001Bd\u0001\u001B-\u0001DETALLE CANT. P.U. IMPORTE
14+
\u001B-\u0000DIZOLE 250 X LT
15+
10.00 20.000000 200.00
16+
----------------------------------------
17+
SUBTOTAL IVA 0.00
18+
SUBTOTAL 0% 200.00
19+
SUBTOT. NO SUJE 0.00
20+
SUBTOT. SIN IMP 200.00
21+
DESCUENTO 0.00
22+
IVA 0.00
23+
\u001BE\u0001\u001B!V TOTAL 200.00
24+
\u001B@\u001B!\u0000\u001BM\u0001\u001BE\u0001
25+
\u001BE\u0000\u001Bd\u0001Tipo Pago:
26+
20 - OTROS CON UTILIZACION D 200.00
27+
\u001Bd\u0001Descargar su Comprobante en:
28+
http://pagina.com/pdf.php?clave=0802201801079173379000120010010000019111234567819
29+
\u001B!\u0000\u001BM\u0000\u001BE\u0000\u001B-\u0000\u001BVA\u0003

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zpl-escpos-printer",
33
"productName": "Zpl/EscPos Printer",
4-
"version": "3.0.5",
4+
"version": "3.0.6",
55
"description": "Printer emulator for Zpl/EscPos rendering engine.",
66
"main": "main.js",
77
"scripts": {

0 commit comments

Comments
 (0)