Skip to content

How to combine splitted buffer #2676

Closed Answered by techducks
techducks asked this question in Q&A
Discussion options

You must be logged in to vote

I found my solution. You need to add an delimiter to the arduino code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.write("index:write;name:Lichtsensor-Balkon;lux:777\n");
  delay(1000);
}

And then use the delimiter parser:

const { SerialPort } = require('serialport')
const { DelimiterParser } = require('@serialport/parser-delimiter')

const port = new SerialPort({
    path: '/dev/ttyUSB0',
    baudRate: 115200,
})

const parser = port.pipe(new DelimiterParser({ delimiter: '\n' }))

port.on("open", function() {
    console.log("-- Connection opened --");

    parser.on("data", function(data) {
        console.log(".")
        console.log(data.toString(('utf-8')))
    })…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by techducks
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