简体   繁体   English

错误:打开(GetCommState):未知错误代码 1 - Nodejs、express、SerialPort

[英]Error: Open (GetCommState) : Unknown error code 1 - Nodejs, express, SerialPort

I am trying to connect a fiscal printer that has serial input to nodejs.我正在尝试将具有串行输入的财务打印机连接到 nodejs。 I'm using the SerialPort module, but I can't make the connection, since the console gives me the following error: "Error: Open (GetCommState): Unknow error code 1".我正在使用 SerialPort 模块,但我无法建立连接,因为控制台给了我以下错误:“错误:打开(GetCommState):未知错误代码 1”。 I would like to know if you could help me with this error, or tell me where I can find the meaning of each of the errors, since I do not know what the error code 1 means我想知道您是否可以帮助我解决此错误,或者告诉我在哪里可以找到每个错误的含义,因为我不知道错误代码 1 的含义

  const SerialPort = require("serialport")
  const Readline = SerialPort.parsers.Readline
  const parser = new Readline
  const mySerial = new SerialPort('COM2', {
     baudRate: 9600
   })
   mySerial.on('open', () => {
     console.log("Port COM2")
   })

The error:错误:

ERROR: OPEN (GETCOMMSTATE: UNKNOWN ERROR CODE 1错误:打开(GETCOMMSTATE:未知错误代码 1

Make sure there is no printer installed in Windows on the same port.确保 Windows 中没有在同一端口上安装打印机。 Had the same problem, I just uninstalled the printer and it solved.有同样的问题,我刚刚卸载了打印机,它解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM