【发布时间】: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