【问题标题】:Send command to customer pole display COM2 using Serialport nodejs module使用 Serialport nodejs 模块向客户极显示 COM2 发送命令
【发布时间】:2019-12-29 05:19:17
【问题描述】:

我尝试将清屏命令发送到客户杆显示器,其型号 LCD210 其波特率 9600、8、n、1(V.1) 和 20 个字符 2 行显示,命令类型:CD5220,字体:美国/PC437。我有手册,但是当我尝试发送命令时。它没有捡起它,它只是像字符串一样打印。

下面是我的代码。

  onDisplayTextOnPole(msg: any) {

    //Check if we are in electron env
    if (this.isElectron()) {

      //Start
      const port =  new this.serialPort('COM2', { baudRate: 9600 }, function (err) {
        if (err) {
          return console.log('Error: ', err.message);
        }
      });



      port.write('\0x0C');//Command to clear screen
      port.write(Buffer.from(msg), function(err: { message: any; }) {
        if (err) {
          return console.log('Error on write: ', err.message)
        }
        console.log('message written')
      });
      port.close();
      //End 

    }


  }

我其实是想先清屏再写信息。我遇到的问题是,每当我发送新消息时,它都会附加到上一条消息。所以我需要在写新消息之前清除之前的消息。

【问题讨论】:

  • 您的问题解决了吗?如果是这样,请给我一个提示。

标签: javascript angular serial-port electron


【解决方案1】:

我用下面的代码解决了这个问题:

this.myserialportinstance.write(Buffer.from('CLR', 'hex'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-17
    • 1970-01-01
    相关资源
    最近更新 更多