mirror of
https://github.com/MultiMote/niimbluelib.git
synced 2025-03-16 19:41:01 +03:00
Add printer error codes
This commit is contained in:
parent
3942f34d50
commit
c10de9f96c
src/packets
@ -4,6 +4,7 @@ import {
|
||||
ConnectResult,
|
||||
HeartbeatType,
|
||||
LabelType,
|
||||
PrinterErrorCode,
|
||||
PrinterInfoType,
|
||||
PrintTaskVersion,
|
||||
ResponseCommandId,
|
||||
@ -97,7 +98,10 @@ export class Abstraction {
|
||||
|
||||
if (packet.command === ResponseCommandId.In_PrintError) {
|
||||
Validators.u8ArrayLengthEquals(packet.data, 1);
|
||||
throw new PrintError(`Print error (${ResponseCommandId[packet.command]} packet received)`, packet.data[0]);
|
||||
const errorName = PrinterErrorCode[packet.data[0]] ?? "unknown";
|
||||
throw new PrintError(
|
||||
`Print error (${ResponseCommandId[packet.command]} packet received, code is ${packet.data[0]} - ${errorName})`, packet.data[0]
|
||||
);
|
||||
}
|
||||
|
||||
Validators.u8ArrayLengthAtLeast(packet.data, 4); // can be 8, 10, but ignore it for now
|
||||
|
@ -61,7 +61,8 @@ export enum ResponseCommandId {
|
||||
In_PrinterStatusData = 0xb5,
|
||||
In_PrinterReset = 0x38,
|
||||
In_PrintStatus = 0xb3,
|
||||
In_PrintError = 0xdb, // For example, sent on SetPageSize when page print is not started
|
||||
/** see {@link PrinterErrorCode}. For example, sent on SetPageSize when page print is not started. */
|
||||
In_PrintError = 0xdb,
|
||||
In_PrintQuantity = 0x16,
|
||||
In_PrintStart = 0x02,
|
||||
In_RfidInfo = 0x1b,
|
||||
@ -158,6 +159,48 @@ export enum PrintTaskVersion {
|
||||
V5,
|
||||
}
|
||||
|
||||
/** In_PrintError status codes */
|
||||
export enum PrinterErrorCode {
|
||||
COVER_OPEN = 0x01,
|
||||
LACK_PAPER = 0x02,
|
||||
LOW_BATTERY = 0x03,
|
||||
BATTERY_EXCEPTION = 0x04,
|
||||
USER_CANCEL = 0x05,
|
||||
DATA_ERROR = 0x06,
|
||||
OVERHEAT = 0x07,
|
||||
PAPER_OUT_EXCEPTION = 0x08,
|
||||
PRINTER_BUSY = 0x09,
|
||||
NO_PRINTER_HEAD = 0x0a,
|
||||
TEMPERATURE_LOW = 0x0b,
|
||||
PRINTER_HEAD_LOOSE = 0x0c,
|
||||
NO_RIBBON = 0x0d,
|
||||
WRONG_RIBBON = 0x0e,
|
||||
USED_RIBBON = 0x0f,
|
||||
WRONG_PAPER = 0x10,
|
||||
SET_PAPER_FAIL = 0x11,
|
||||
SET_PRINT_MODE_FAIL = 0x12,
|
||||
SET_PRINT_DENSITY_FAIL = 0x13,
|
||||
WRITE_RFID_FAIL = 0x14,
|
||||
SET_MARGIN_FAIL = 0x15,
|
||||
COMMUNICATION_EXCEPTION = 0x16,
|
||||
DISCONNECT = 0x17,
|
||||
CANVAS_PARAMETER_ERROR = 0x18,
|
||||
ROTATION_PARAMETER_EXCEPTION = 0x19,
|
||||
JSON_PARAMETER_EXCEPTION = 0x1a,
|
||||
B3S_ABNORMAL_PAPER_OUTPUT = 0x1b,
|
||||
E_CHECK_PAPER = 0x1c,
|
||||
RFID_TAG_NOT_WRITTEN = 0x1d,
|
||||
SET_PRINT_DENSITY_NO_SUPPORT = 0x1e,
|
||||
SET_PRINT_MODE_NO_SUPPORT = 0x1f,
|
||||
SET_PRINT_LABEL_MATERIAL_ERROR = 0x20,
|
||||
SET_PRINT_LABEL_MATERIAL_NO_SUPPORT = 0x21,
|
||||
NOT_SUPPORT_WRITTEN_RFID = 0x22,
|
||||
ILLEGAL_PAGE = 0x32,
|
||||
ILLEGAL_RIBBON_PAGE = 0x33,
|
||||
RECEIVE_DATA_TIMEOUT = 0x34,
|
||||
NON_DEDICATED_RIBBON = 0x35,
|
||||
}
|
||||
|
||||
export * from "./packet";
|
||||
export * from "./packet_generator";
|
||||
export * from "./abstraction";
|
||||
|
Loading…
x
Reference in New Issue
Block a user