gpt4 book ai didi

javascript - 使用 Serialport nodejs 模块向客户极显示 COM2 发送命令

转载 作者:行者123 更新时间:2023-12-03 12:28:21 25 4
gpt4 key购买 nike

我尝试将清屏命令发送到客户极点显示器,其型号 LCD210 其波特率 9600、8、n、1(V.1) 和 20 个字符 2 行显示,命令类型:CD5220,字体:U.S.A/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

}


}

我实际上想先清除屏幕然后写一条消息。我遇到的问题是,每当我发送新消息时,它都会附加到上一条消息。所以我需要一种方法在写新消息之前清除以前的消息。

最佳答案

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

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

关于javascript - 使用 Serialport nodejs 模块向客户极显示 COM2 发送命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57633794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com