@bobfrankston/brother-label 1.1.6 → 1.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/brother-label",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "API and CLI for printing labels on Brother P-touch printers",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=probe-ql820.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-ql820.d.ts","sourceRoot":"","sources":["probe-ql820.ts"],"names":[],"mappings":""}
package/probe-ql820.js ADDED
@@ -0,0 +1,94 @@
1
+ // Probe a QL-820 over TCP 9100. Sends:
2
+ // 200x NUL flush command buffer
3
+ // ESC @ initialize
4
+ // ESC i a 01 switch to raster mode
5
+ // ESC i S status request -> returns 32-byte status block
6
+ // Documents what's loaded (media width, error state, model).
7
+ import * as net from "net";
8
+ const HOST = process.argv[2];
9
+ const PORT = 9100;
10
+ if (!HOST) {
11
+ console.error("usage: probe-ql820 <host-or-ip>");
12
+ process.exit(1);
13
+ }
14
+ const FLUSH = Buffer.alloc(200, 0);
15
+ const INIT = Buffer.from([0x1b, 0x40]); // ESC @
16
+ const MODE_RASTER = Buffer.from([0x1b, 0x69, 0x61, 0x01]); // ESC i a 01
17
+ const STATUS_REQUEST = Buffer.from([0x1b, 0x69, 0x53]); // ESC i S
18
+ const sock = net.createConnection({ host: HOST, port: PORT, timeout: 15000 });
19
+ const chunks = [];
20
+ sock.on("connect", () => {
21
+ console.log(`connected to ${HOST}:${PORT}`);
22
+ sock.write(FLUSH);
23
+ sock.write(INIT);
24
+ sock.write(MODE_RASTER);
25
+ sock.write(STATUS_REQUEST);
26
+ console.log("sent: 200xNUL, ESC @, ESC i a 01, ESC i S — waiting for 32-byte reply...");
27
+ });
28
+ sock.on("data", (buf) => {
29
+ chunks.push(buf);
30
+ const total = Buffer.concat(chunks);
31
+ console.log(`received ${buf.length} bytes (total ${total.length})`);
32
+ if (total.length >= 32) {
33
+ decode(total.subarray(0, 32));
34
+ sock.end();
35
+ }
36
+ });
37
+ sock.on("timeout", () => {
38
+ console.error("timeout — no 32-byte status reply");
39
+ if (chunks.length > 0) {
40
+ const t = Buffer.concat(chunks);
41
+ console.error(`partial: ${t.length} bytes: ${t.toString("hex")}`);
42
+ }
43
+ sock.destroy();
44
+ process.exit(2);
45
+ });
46
+ sock.on("error", (e) => {
47
+ console.error("socket error:", e.message);
48
+ process.exit(1);
49
+ });
50
+ sock.on("close", () => {
51
+ if (chunks.length === 0)
52
+ console.error("closed with no data");
53
+ });
54
+ function decode(b) {
55
+ const modelMap = {
56
+ 0x4f: "QL-500/550", 0x31: "QL-560", 0x32: "QL-570", 0x33: "QL-580N",
57
+ 0x51: "QL-650TD", 0x35: "QL-700", 0x34: "QL-1050", 0x36: "QL-1060N",
58
+ 0x37: "QL-720NW", 0x38: "QL-710W", 0x39: "QL-810W", 0x41: "QL-820NWB",
59
+ 0x43: "QL-1100", 0x44: "QL-1110NWB", 0x45: "QL-1115NWB",
60
+ };
61
+ const mediaTypeMap = {
62
+ 0x00: "no media", 0x0a: "continuous tape", 0x0b: "die-cut labels",
63
+ };
64
+ console.log("\n--- 32-byte status block ---");
65
+ console.log("hex:", (b.toString("hex").match(/../g) || []).join(" "));
66
+ console.log(` print head mark: 0x${b[0].toString(16)} (expect 0x80)`);
67
+ console.log(` size (32): ${b[1]}`);
68
+ console.log(` brother code 'B': 0x${b[2].toString(16)}`);
69
+ console.log(` series code: 0x${b[3].toString(16)}`);
70
+ console.log(` model code: 0x${b[4].toString(16)} -> ${modelMap[b[4]] ?? "unknown"}`);
71
+ console.log(` country code: 0x${b[5].toString(16)}`);
72
+ console.log(` battery (820): 0x${b[6].toString(16)}`);
73
+ console.log(` extended err: 0x${b[7].toString(16)}`);
74
+ console.log(` error info 1: 0x${b[8].toString(16)}`);
75
+ console.log(` error info 2: 0x${b[9].toString(16)}`);
76
+ console.log(` media width: ${b[10]} mm`);
77
+ console.log(` media type: 0x${b[11].toString(16)} -> ${mediaTypeMap[b[11]] ?? "?"}`);
78
+ console.log(` number of colors: 0x${b[12].toString(16)}`);
79
+ console.log(` fonts: 0x${b[13].toString(16)}`);
80
+ console.log(` jp font: 0x${b[14].toString(16)}`);
81
+ console.log(` mode: 0x${b[15].toString(16)}`);
82
+ console.log(` density: 0x${b[16].toString(16)}`);
83
+ console.log(` media length: ${b[17]} mm`);
84
+ console.log(` status type: 0x${b[18].toString(16)}`);
85
+ console.log(` phase type: 0x${b[19].toString(16)}`);
86
+ console.log(` phase number: ${(b[20] << 8) | b[21]}`);
87
+ console.log(` notification: 0x${b[22].toString(16)}`);
88
+ console.log(` expansion area: 0x${b[23].toString(16)}`);
89
+ console.log(` tape color info: 0x${b[24].toString(16)}`);
90
+ console.log(` text color info: 0x${b[25].toString(16)}`);
91
+ console.log(` hw setting: ${b.subarray(26, 30).toString("hex")}`);
92
+ console.log(` reserved: ${b.subarray(30, 32).toString("hex")}`);
93
+ }
94
+ //# sourceMappingURL=probe-ql820.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-ql820.js","sourceRoot":"","sources":["probe-ql820.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,2CAA2C;AAC3C,iCAAiC;AACjC,4CAA4C;AAC5C,qEAAqE;AACrE,6DAA6D;AAE7D,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,IAAI,CAAC,IAAI,EAAE,CAAC;IACR,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,KAAK,GAAY,MAAM,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AAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// Probe a QL-820 over TCP 9100. Sends:\n// 200x NUL flush command buffer\n// ESC @ initialize\n// ESC i a 01 switch to raster mode\n// ESC i S status request -> returns 32-byte status block\n// Documents what's loaded (media width, error state, model).\n\nimport * as net from \"net\";\n\nconst HOST = process.argv[2];\nconst PORT = 9100;\nif (!HOST) {\n console.error(\"usage: probe-ql820 <host-or-ip>\");\n process.exit(1);\n}\n\nconst FLUSH = Buffer.alloc(200, 0);\nconst INIT = Buffer.from([0x1b, 0x40]); // ESC @\nconst MODE_RASTER = Buffer.from([0x1b, 0x69, 0x61, 0x01]); // ESC i a 01\nconst STATUS_REQUEST = Buffer.from([0x1b, 0x69, 0x53]); // ESC i S\n\nconst sock = net.createConnection({ host: HOST, port: PORT, timeout: 15000 });\nconst chunks: Buffer[] = [];\n\nsock.on(\"connect\", () => {\n console.log(`connected to ${HOST}:${PORT}`);\n sock.write(FLUSH);\n sock.write(INIT);\n sock.write(MODE_RASTER);\n sock.write(STATUS_REQUEST);\n console.log(\"sent: 200xNUL, ESC @, ESC i a 01, ESC i S — waiting for 32-byte reply...\");\n});\n\nsock.on(\"data\", (buf: Buffer) => {\n chunks.push(buf);\n const total = Buffer.concat(chunks);\n console.log(`received ${buf.length} bytes (total ${total.length})`);\n if (total.length >= 32) {\n decode(total.subarray(0, 32));\n sock.end();\n }\n});\n\nsock.on(\"timeout\", () => {\n console.error(\"timeout — no 32-byte status reply\");\n if (chunks.length > 0) {\n const t = Buffer.concat(chunks);\n console.error(`partial: ${t.length} bytes: ${t.toString(\"hex\")}`);\n }\n sock.destroy();\n process.exit(2);\n});\n\nsock.on(\"error\", (e) => {\n console.error(\"socket error:\", (e as Error).message);\n process.exit(1);\n});\n\nsock.on(\"close\", () => {\n if (chunks.length === 0) console.error(\"closed with no data\");\n});\n\nfunction decode(b: Buffer): void {\n const modelMap: Record<number, string> = {\n 0x4f: \"QL-500/550\", 0x31: \"QL-560\", 0x32: \"QL-570\", 0x33: \"QL-580N\",\n 0x51: \"QL-650TD\", 0x35: \"QL-700\", 0x34: \"QL-1050\", 0x36: \"QL-1060N\",\n 0x37: \"QL-720NW\", 0x38: \"QL-710W\", 0x39: \"QL-810W\", 0x41: \"QL-820NWB\",\n 0x43: \"QL-1100\", 0x44: \"QL-1110NWB\", 0x45: \"QL-1115NWB\",\n };\n const mediaTypeMap: Record<number, string> = {\n 0x00: \"no media\", 0x0a: \"continuous tape\", 0x0b: \"die-cut labels\",\n };\n console.log(\"\\n--- 32-byte status block ---\");\n console.log(\"hex:\", (b.toString(\"hex\").match(/../g) || []).join(\" \"));\n console.log(` print head mark: 0x${b[0].toString(16)} (expect 0x80)`);\n console.log(` size (32): ${b[1]}`);\n console.log(` brother code 'B': 0x${b[2].toString(16)}`);\n console.log(` series code: 0x${b[3].toString(16)}`);\n console.log(` model code: 0x${b[4].toString(16)} -> ${modelMap[b[4]] ?? \"unknown\"}`);\n console.log(` country code: 0x${b[5].toString(16)}`);\n console.log(` battery (820): 0x${b[6].toString(16)}`);\n console.log(` extended err: 0x${b[7].toString(16)}`);\n console.log(` error info 1: 0x${b[8].toString(16)}`);\n console.log(` error info 2: 0x${b[9].toString(16)}`);\n console.log(` media width: ${b[10]} mm`);\n console.log(` media type: 0x${b[11].toString(16)} -> ${mediaTypeMap[b[11]] ?? \"?\"}`);\n console.log(` number of colors: 0x${b[12].toString(16)}`);\n console.log(` fonts: 0x${b[13].toString(16)}`);\n console.log(` jp font: 0x${b[14].toString(16)}`);\n console.log(` mode: 0x${b[15].toString(16)}`);\n console.log(` density: 0x${b[16].toString(16)}`);\n console.log(` media length: ${b[17]} mm`);\n console.log(` status type: 0x${b[18].toString(16)}`);\n console.log(` phase type: 0x${b[19].toString(16)}`);\n console.log(` phase number: ${(b[20] << 8) | b[21]}`);\n console.log(` notification: 0x${b[22].toString(16)}`);\n console.log(` expansion area: 0x${b[23].toString(16)}`);\n console.log(` tape color info: 0x${b[24].toString(16)}`);\n console.log(` text color info: 0x${b[25].toString(16)}`);\n console.log(` hw setting: ${b.subarray(26, 30).toString(\"hex\")}`);\n console.log(` reserved: ${b.subarray(30, 32).toString(\"hex\")}`);\n}\n"]}
package/probe-ql820.ts ADDED
@@ -0,0 +1,102 @@
1
+ // Probe a QL-820 over TCP 9100. Sends:
2
+ // 200x NUL flush command buffer
3
+ // ESC @ initialize
4
+ // ESC i a 01 switch to raster mode
5
+ // ESC i S status request -> returns 32-byte status block
6
+ // Documents what's loaded (media width, error state, model).
7
+
8
+ import * as net from "net";
9
+
10
+ const HOST = process.argv[2];
11
+ const PORT = 9100;
12
+ if (!HOST) {
13
+ console.error("usage: probe-ql820 <host-or-ip>");
14
+ process.exit(1);
15
+ }
16
+
17
+ const FLUSH = Buffer.alloc(200, 0);
18
+ const INIT = Buffer.from([0x1b, 0x40]); // ESC @
19
+ const MODE_RASTER = Buffer.from([0x1b, 0x69, 0x61, 0x01]); // ESC i a 01
20
+ const STATUS_REQUEST = Buffer.from([0x1b, 0x69, 0x53]); // ESC i S
21
+
22
+ const sock = net.createConnection({ host: HOST, port: PORT, timeout: 15000 });
23
+ const chunks: Buffer[] = [];
24
+
25
+ sock.on("connect", () => {
26
+ console.log(`connected to ${HOST}:${PORT}`);
27
+ sock.write(FLUSH);
28
+ sock.write(INIT);
29
+ sock.write(MODE_RASTER);
30
+ sock.write(STATUS_REQUEST);
31
+ console.log("sent: 200xNUL, ESC @, ESC i a 01, ESC i S — waiting for 32-byte reply...");
32
+ });
33
+
34
+ sock.on("data", (buf: Buffer) => {
35
+ chunks.push(buf);
36
+ const total = Buffer.concat(chunks);
37
+ console.log(`received ${buf.length} bytes (total ${total.length})`);
38
+ if (total.length >= 32) {
39
+ decode(total.subarray(0, 32));
40
+ sock.end();
41
+ }
42
+ });
43
+
44
+ sock.on("timeout", () => {
45
+ console.error("timeout — no 32-byte status reply");
46
+ if (chunks.length > 0) {
47
+ const t = Buffer.concat(chunks);
48
+ console.error(`partial: ${t.length} bytes: ${t.toString("hex")}`);
49
+ }
50
+ sock.destroy();
51
+ process.exit(2);
52
+ });
53
+
54
+ sock.on("error", (e) => {
55
+ console.error("socket error:", (e as Error).message);
56
+ process.exit(1);
57
+ });
58
+
59
+ sock.on("close", () => {
60
+ if (chunks.length === 0) console.error("closed with no data");
61
+ });
62
+
63
+ function decode(b: Buffer): void {
64
+ const modelMap: Record<number, string> = {
65
+ 0x4f: "QL-500/550", 0x31: "QL-560", 0x32: "QL-570", 0x33: "QL-580N",
66
+ 0x51: "QL-650TD", 0x35: "QL-700", 0x34: "QL-1050", 0x36: "QL-1060N",
67
+ 0x37: "QL-720NW", 0x38: "QL-710W", 0x39: "QL-810W", 0x41: "QL-820NWB",
68
+ 0x43: "QL-1100", 0x44: "QL-1110NWB", 0x45: "QL-1115NWB",
69
+ };
70
+ const mediaTypeMap: Record<number, string> = {
71
+ 0x00: "no media", 0x0a: "continuous tape", 0x0b: "die-cut labels",
72
+ };
73
+ console.log("\n--- 32-byte status block ---");
74
+ console.log("hex:", (b.toString("hex").match(/../g) || []).join(" "));
75
+ console.log(` print head mark: 0x${b[0].toString(16)} (expect 0x80)`);
76
+ console.log(` size (32): ${b[1]}`);
77
+ console.log(` brother code 'B': 0x${b[2].toString(16)}`);
78
+ console.log(` series code: 0x${b[3].toString(16)}`);
79
+ console.log(` model code: 0x${b[4].toString(16)} -> ${modelMap[b[4]] ?? "unknown"}`);
80
+ console.log(` country code: 0x${b[5].toString(16)}`);
81
+ console.log(` battery (820): 0x${b[6].toString(16)}`);
82
+ console.log(` extended err: 0x${b[7].toString(16)}`);
83
+ console.log(` error info 1: 0x${b[8].toString(16)}`);
84
+ console.log(` error info 2: 0x${b[9].toString(16)}`);
85
+ console.log(` media width: ${b[10]} mm`);
86
+ console.log(` media type: 0x${b[11].toString(16)} -> ${mediaTypeMap[b[11]] ?? "?"}`);
87
+ console.log(` number of colors: 0x${b[12].toString(16)}`);
88
+ console.log(` fonts: 0x${b[13].toString(16)}`);
89
+ console.log(` jp font: 0x${b[14].toString(16)}`);
90
+ console.log(` mode: 0x${b[15].toString(16)}`);
91
+ console.log(` density: 0x${b[16].toString(16)}`);
92
+ console.log(` media length: ${b[17]} mm`);
93
+ console.log(` status type: 0x${b[18].toString(16)}`);
94
+ console.log(` phase type: 0x${b[19].toString(16)}`);
95
+ console.log(` phase number: ${(b[20] << 8) | b[21]}`);
96
+ console.log(` notification: 0x${b[22].toString(16)}`);
97
+ console.log(` expansion area: 0x${b[23].toString(16)}`);
98
+ console.log(` tape color info: 0x${b[24].toString(16)}`);
99
+ console.log(` text color info: 0x${b[25].toString(16)}`);
100
+ console.log(` hw setting: ${b.subarray(26, 30).toString("hex")}`);
101
+ console.log(` reserved: ${b.subarray(30, 32).toString("hex")}`);
102
+ }