V
V
Vitaly2019-04-10 16:48:01
JavaScript
Vitaly, 2019-04-10 16:48:01

How to work with native cctalk parser in node serial?

I'm trying to use node serial and the native cctalk parser to start a kyupurnik that works on cctalk.
I'm trying to send a command from an example via cctalk TX data = 2 0 1 245 8

const SerialPort = require("serialport");
const CCTalk = require('@serialport/parser-cctalk')

let port = new SerialPort("/dev/ttyUSB0", {
    autoOpen: false
});

const parser = port.pipe(new CCTalk())
parser.on('data', console.log)

port.open((err) => {
    if (err) {
        return console.log("Error opening port: ", err.message);
    } else {
        console.log('port has ben opened')
        port.write(Buffer.from("2012458", "hex"), function(err){
        	if(err) console.log('writing error: ', err)
        })
    }
});

port.on("data", (data) => {
  console.log('data => ', data)
})

port.on("error", function(err) {
  console.log('Error: ', err.message)
})

But nothing happens, that is, in response, nothing, after connecting via the serial port, the diode on the device lights up red, it can be seen that the connection has taken place.
Maybe there is some example somewhere, or who will tell you how to use this parser correctly?
Thanks for the help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question