Skip to content

Send bytes from arduino and convert to numbers #2598

Answered by dj-fiorex
dj-fiorex asked this question in Q&A
Discussion options

You must be logged in to vote

I will answer to my self! I didn't read the docs well (https://nodejs.org/api/buffer.html#bufreaddoublebeoffset)!
i need to pass the number of bytes to skip to readDoubleLE, so the code must be:

...
parser.on("data", (d) => {
  const double = d.readDoubleLE(0);
  const double1 = d.readDoubleLE(8);
  const double2 = d.readDoubleLE(16);

  console.log({
    double,
    double1,
    double2,
  });
});
...
now it works as expected! 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dj-fiorex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant