You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I first connect the ESP8266 to the computer, I run my demo and cannot write messages, but if I press the ESP8266 RST reset button once and run the demo again, I can send messages. I don't know why, and Arduino tools don't have this problem.
this is my demo.
const { SerialPort } = require('serialport')
const portName = 'COM3';
const baudRate = 115200;
const port = new SerialPort({ path: portName, baudRate: baudRate })
setInterval(function () {
port.write('D1_300_500_1\n', function(err) {
if (err) {
return console.log('Error on write: ', err.message)
}
console.log('message written')
// port.close(function (err) {
// console.log(err)
// })
})
},1000)
let receivedData = '';
port.on('data', (data) => {
receivedData += data.toString();
if (receivedData.includes('\n')) {
const cleanedData = receivedData.replace(/[\r\n]/g, "");
receivedData = '';
console.log(cleanedData)
}
});
// Open errors will be emitted as an error event
port.on('error', function(err) {
console.log('Error: ', err.message)
})
I try to use @serialport/parser-ready but it's not work.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I first connect the ESP8266 to the computer, I run my demo and cannot write messages, but if I press the ESP8266 RST reset button once and run the demo again, I can send messages. I don't know why, and Arduino tools don't have this problem.
this is my demo.
I try to use @serialport/parser-ready but it's not work.
Beta Was this translation helpful? Give feedback.
All reactions