Alexandr Fridrik
Alexandr Fridrik

Reputation: 1

serialportjs repeats response several times

With each request there is one more line. Why is the number of rows increasing?

port.write(data.command + "\n");
console.log("command =>", data.command);
const parser = port.pipe(new ReadlineParser({ delimiter: "\r\n" }));
    parser.on("data", (line) => {
      console.log(line);
    });

Command and respons:

command => V

v,4.0.0.0,8f834655363231164c343132

command => V

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

command => V

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

command => V

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

v,4.0.0.0,8f834655363231164c343132

I try to flush port but it doesn't work

 port.flush((error) => {
        console.log("port flushed")       
        const parser = port.pipe(new ReadlineParser({ delimiter: '\r' }))
        parser.on('data', line => {
            console.log(line)
        })
    })

Upvotes: 0

Views: 44

Answers (0)

Related Questions