119 lines
4.2 KiB
JavaScript
119 lines
4.2 KiB
JavaScript
import net from "net";
|
|
|
|
/**
|
|
* This uses a kinda fake scanner to mimic the scanning process to a server and creates the bol.
|
|
*/
|
|
const prodIP = "10.204.0.26";
|
|
const prodPort = 50000;
|
|
const scannerID = "98@";
|
|
const scannerCommand = "AlplaPRODcmd00000042#000028547"; // top of the picksheet
|
|
const scannerCommand2 = ""; // bottom of the pick sheet
|
|
|
|
const labels = [
|
|
"1000000000000000000000000000000005566030",
|
|
"1000000000000000000000000000000005544896",
|
|
"1000000000000000000000000000000005544906",
|
|
"1000000000000000000000000000000005544916",
|
|
"1000000000000000000000000000000005544926",
|
|
"1000000000000000000000000000000005544936",
|
|
"1000000000000000000000000000000005544946",
|
|
"1000000000000000000000000000000005544956",
|
|
"1000000000000000000000000000000005544966",
|
|
"1000000000000000000000000000000005544976",
|
|
"1000000000000000000000000000000005544986",
|
|
"1000000000000000000000000000000005544996",
|
|
"1000000000000000000000000000000005545006",
|
|
"1000000000000000000000000000000005545016",
|
|
"1000000000000000000000000000000005545026",
|
|
"1000000000000000000000000000000005545036",
|
|
"1000000000000000000000000000000005545046",
|
|
"1000000000000000000000000000000005545056",
|
|
"1000000000000000000000000000000005545066",
|
|
"1000000000000000000000000000000005545076",
|
|
"1000000000000000000000000000000005545086",
|
|
"1000000000000000000000000000000005545096",
|
|
"1000000000000000000000000000000005545106",
|
|
"1000000000000000000000000000000005545116",
|
|
"1000000000000000000000000000000005545126",
|
|
"1000000000000000000000000000000005545136",
|
|
"1000000000000000000000000000000005545146",
|
|
"1000000000000000000000000000000005545156",
|
|
"1000000000000000000000000000000005545166",
|
|
"1000000000000000000000000000000005545176",
|
|
"1000000000000000000000000000000005545186",
|
|
"1000000000000000000000000000000005544580",
|
|
"1000000000000000000000000000000005544590",
|
|
"1000000000000000000000000000000005544600",
|
|
"1000000000000000000000000000000005544610",
|
|
"1000000000000000000000000000000005544640",
|
|
"1000000000000000000000000000000005544650",
|
|
"1000000000000000000000000000000005544660",
|
|
"1000000000000000000000000000000005544670",
|
|
"1000000000000000000000000000000005544680",
|
|
"1000000000000000000000000000000005544690",
|
|
"1000000000000000000000000000000005544700",
|
|
"1000000000000000000000000000000005544710",
|
|
"1000000000000000000000000000000005544720",
|
|
"1000000000000000000000000000000005544730",
|
|
"1000000000000000000000000000000005544740",
|
|
"1000000000000000000000000000000005544750",
|
|
"1000000000000000000000000000000005544760",
|
|
"1000000000000000000000000000000005544770",
|
|
"1000000000000000000000000000000005544780",
|
|
"1000000000000000000000000000000005544790",
|
|
"1000000000000000000000000000000005544800",
|
|
"1000000000000000000000000000000005544810",
|
|
"1000000000000000000000000000000005544820",
|
|
"1000000000000000000000000000000005544830",
|
|
"1000000000000000000000000000000005544840",
|
|
"1000000000000000000000000000000005544850",
|
|
"1000000000000000000000000000000005544860",
|
|
"1000000000000000000000000000000005544870",
|
|
];
|
|
const STX = "\x02";
|
|
const ETX = "\x03";
|
|
|
|
const scanner = new net.Socket();
|
|
|
|
scanner.connect(prodPort, prodIP, async () => {
|
|
console.log("Connected to scanner");
|
|
|
|
const message = Buffer.from(
|
|
`${STX}${scannerID}${scannerCommand}${ETX}`,
|
|
"ascii",
|
|
);
|
|
console.log("Sending:", message.toString("ascii"));
|
|
scanner.write(message);
|
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
|
|
for (let i = 0; i < labels.length; i++) {
|
|
const l = labels[i];
|
|
|
|
const message = Buffer.from(`${STX}${scannerID}${l}${ETX}`, "ascii");
|
|
console.log("Sending:", message.toString("ascii"));
|
|
scanner.write(message);
|
|
await new Promise((resolve) => setTimeout(resolve, 1200));
|
|
}
|
|
|
|
// //close the incoming
|
|
// await new Promise(resolve => setTimeout(resolve, 1500));
|
|
// const message2 = Buffer.from(`${STX}${scannerID}${scannerCommand2}${ETX}`, "ascii");
|
|
// console.log("Sending:", message2.toString("ascii"));
|
|
// scanner.write(message2);
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
scanner.destroy();
|
|
});
|
|
|
|
scanner.on("data", async (data) => {
|
|
console.log("Response:", data.toString("ascii"));
|
|
});
|
|
|
|
scanner.on("close", () => {
|
|
console.log("Connection closed");
|
|
});
|
|
|
|
scanner.on("error", (err) => {
|
|
console.error("Scanner error:", err);
|
|
});
|