node-escpos / driver

🖨️ ESC/POS Printer driver for Node.js.
Other
317 stars 32 forks source link

Error: Port is opening (Linux and Windows) #13

Closed Kaplas85 closed 2 years ago

Kaplas85 commented 2 years ago

Hi! I'm trying to use a thermal printer Dascom DT-230 with the serialport adapter. Now the printer is connected to my PC using usb but the pc detects that as a serial port

In Windows as COM4 In Linux as /dev/ttyACM0

In both cases that return Error: Port is opening image

It's the code that I was testing

import { Printer } from "@node-escpos/core";
import Serial from "@node-escpos/serialport-adapter";

const device = new Serial("/dev/ttyACM0", { // In Windows I was put "COM4"
  baudRate: 115200,
  stopBit: 1,
});

const options = {
  encoding: "utf-8",
};

const printer = new Printer(device, options);

device.open((error) => {
  if (error) {
    console.error(error);
    return;
  }

  let printer = new Printer(device, {});

  printer
    .font("a")
    .align("ct")
    .style("bu")
    .size(1, 1)
    .text("The quick brown fox jumps over the lazy dog");

  printer.cut().close();
});

Someone can help me with that? I have been trying different packages to use escpos printers for months and I have not found any that give me results

dohooo commented 2 years ago

This problem is related to this issue.

dohooo commented 2 years ago

Try this. Waiting for your feedback. 🍻

Kaplas85 commented 2 years ago

I was update the serial port package and that solve the bug but still the printer don't print any.

I also don't get any output in the console

dohooo commented 2 years ago

I was update the serial port package and that solve the bug but still the printer don't print any.

I also don't get any output in the console

Okay, let me check again.

Kaplas85 commented 2 years ago

Hello! I will close this issue because the problem was not the package, was the printer.

I was try with a new printer and works fine.