SAM*_*SOL 5 node.js node-serialport
你好,我正在使用 Arduino 和 Node js 发送和接收数据,但从 arduino 传入的数据如下所示:
<Buffer 00 00 00 e0 e0 e0 00 e0 e0 e0>
<Buffer e0 e0 e0 e0 00 e0 e0 00 e0 00 e0 e0 e0>
Run Code Online (Sandbox Code Playgroud)
我怎样才能将其解码为UTF8
阿尔杜伊诺
int incomingByte = 0;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read(); // read the incoming byte:
Serial.print(incomingByte);
}
}
Run Code Online (Sandbox Code Playgroud)
在node.js中你可以使用toString:
console.log(incomeBuffer.toString('utf8'))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6194 次 |
| 最近记录: |