Answer the question
In order to leave comments, you need to log in
How to sequentially send commands to a COM port in Node.js?
I interact with Node.js with Arduino via COM port. I send the data to the MK, read from the file. There are 3 types of commands: on, off and delay. The first 2 work correctly, but on a delay, the Arduino stops responding to commands. Command processing goes through the readline package.
rl.on('line', (line) => {
console.log('Line from file:', line);
if(line.indexOf('P') > -1)
{
parseInt(line.slice(0, -1));
sleep.usleep(parseInt(line.slice(0, -1))*1000);
serialPort.write(data);
}
else
serialPort.write(data);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question