escpos-mc 1.0.2 → 1.0.4-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +45 -0
- package/package.json +1 -1
- package/statuses.js +32 -32
package/index.js
CHANGED
|
@@ -107,6 +107,7 @@ Printer.prototype.marginRight = function (size) {
|
|
|
107
107
|
* @return {[Printer]} printer [the escpos printer instance]
|
|
108
108
|
*/
|
|
109
109
|
Printer.prototype.print = function (content) {
|
|
110
|
+
console.log("PRINT_DEBUG", "PRINT_TO_BUFFER", content);
|
|
110
111
|
this.buffer.write(content);
|
|
111
112
|
return this;
|
|
112
113
|
};
|
|
@@ -959,6 +960,50 @@ Printer.prototype.getStatuses = function(callback) {
|
|
|
959
960
|
return this;
|
|
960
961
|
}
|
|
961
962
|
|
|
963
|
+
/**
|
|
964
|
+
* get custom statuses from the printer
|
|
965
|
+
* @param {Function} callback
|
|
966
|
+
* @return {Printer}
|
|
967
|
+
*/
|
|
968
|
+
Printer.prototype.getCustomStatuses = function(callback) {
|
|
969
|
+
let buffer = [];
|
|
970
|
+
|
|
971
|
+
this.adapter.read(data => {
|
|
972
|
+
for (let i = 0; i < data.byteLength; i++) {
|
|
973
|
+
buffer.push(data.readInt8(i));
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (buffer.length < 2) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
let statuses = [];
|
|
981
|
+
|
|
982
|
+
for (let i = 0; i <= buffer.length; i++) {
|
|
983
|
+
let byte = buffer[i];
|
|
984
|
+
switch (i) {
|
|
985
|
+
case 0:
|
|
986
|
+
statuses.push(new RollPaperSensorStatus(byte));
|
|
987
|
+
break;
|
|
988
|
+
case 1:
|
|
989
|
+
statuses.push(new ExternalSensorStatus(byte));
|
|
990
|
+
break;
|
|
991
|
+
}}
|
|
992
|
+
|
|
993
|
+
buffer = [];
|
|
994
|
+
callback(statuses);
|
|
995
|
+
})
|
|
996
|
+
|
|
997
|
+
RollPaperSensorStatus.commands().forEach((c) => {
|
|
998
|
+
this.adapter.write(c);
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
ExternalSensorStatus.commands().forEach((c) => {
|
|
1002
|
+
this.adapter.write(c);
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
962
1007
|
|
|
963
1008
|
/**
|
|
964
1009
|
* Printer Supports
|
package/package.json
CHANGED
package/statuses.js
CHANGED
|
@@ -339,14 +339,14 @@ class ExternalSensorStatus extends DeviceStatus {
|
|
|
339
339
|
// label = 'No operation';
|
|
340
340
|
// }
|
|
341
341
|
// break;
|
|
342
|
-
case 2:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
342
|
+
// case 2:
|
|
343
|
+
// if (this.bitsAsc[i] === 1) {
|
|
344
|
+
// status = 'error';
|
|
345
|
+
// label = 'Ticket held on printer bezel';
|
|
346
|
+
// } else {
|
|
347
|
+
// label = 'No ticket held on printer bezel or this function invalid';
|
|
348
|
+
// }
|
|
349
|
+
// break;
|
|
350
350
|
case 3:
|
|
351
351
|
if (this.bitsAsc[i] === 1) {
|
|
352
352
|
status = 'error';
|
|
@@ -363,30 +363,30 @@ class ExternalSensorStatus extends DeviceStatus {
|
|
|
363
363
|
// label = 'No error';
|
|
364
364
|
// }
|
|
365
365
|
// break;
|
|
366
|
-
case 5:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
case 6:
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
366
|
+
// case 5:
|
|
367
|
+
// if (this.bitsAsc[i] === 1) {
|
|
368
|
+
// status = 'error';
|
|
369
|
+
// label = 'Blackmark sensor error';
|
|
370
|
+
// } else {
|
|
371
|
+
// label = 'Blackmark sensor is normal';
|
|
372
|
+
// }
|
|
373
|
+
// break;
|
|
374
|
+
// case 6:
|
|
375
|
+
// if (this.bitsAsc[i] === 1) {
|
|
376
|
+
// status = 'error';
|
|
377
|
+
// label = 'Paper error 6';
|
|
378
|
+
// } else {
|
|
379
|
+
// label = 'No error';
|
|
380
|
+
// }
|
|
381
|
+
// break;
|
|
382
|
+
// case 7:
|
|
383
|
+
// if (this.bitsAsc[i] === 1) {
|
|
384
|
+
// status = 'error';
|
|
385
|
+
// label = 'No used. Fixed to Off';
|
|
386
|
+
// } else {
|
|
387
|
+
// label = 'No error';
|
|
388
|
+
// }
|
|
389
|
+
// break;
|
|
390
390
|
default:
|
|
391
391
|
label = 'Fixed';
|
|
392
392
|
break;
|