Skip to main content
syntax highlighting
Source Link
jotadepicas
  • 326
  • 5
  • 13

I'm sending a string from my sketch over Serial port as follows:

Serial.println(F("Found ILI9341 LCD driver"));
Serial.println(F("Found ILI9341 LCD driver"));

On the other side, I have a nodejs app using the serialport npm module, with something like this:

var SerialPort = require('serialport')
var serialPort = new SerialPort('/dev/ttyACM1', {
  baudrate: 9600
})

// it opens the connection and register an event 'data'
serialPort.on('open', function () {
  console.log('Communication is on!')
})

// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function (data) {
  console.log('data received: ' + data)
})
var SerialPort = require('serialport')
var serialPort = new SerialPort('/dev/ttyACM1', {
  baudrate: 9600
})

// it opens the connection and register an event 'data'
serialPort.on('open', function () {
  console.log('Communication is on!')
})

// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function (data) {
  console.log('data received: ' + data)
})

Communication works, but on nodejs side I get the output chunked, as if it had line breaks, like this:

Communication is on!
data received: Pa
data received: int!
data received: 

data received: Fou
data received: nd I
data received: LI93
data received: 41 L
data received: CD d
data received: rive
data received: r

Why does this happen?

I'm sending a string from my sketch over Serial port as follows:

Serial.println(F("Found ILI9341 LCD driver"));

On the other side, I have a nodejs app using the serialport npm module, with something like this:

var SerialPort = require('serialport')
var serialPort = new SerialPort('/dev/ttyACM1', {
  baudrate: 9600
})

// it opens the connection and register an event 'data'
serialPort.on('open', function () {
  console.log('Communication is on!')
})

// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function (data) {
  console.log('data received: ' + data)
})

Communication works, but on nodejs side I get the output chunked, as if it had line breaks, like this:

Communication is on!
data received: Pa
data received: int!
data received: 

data received: Fou
data received: nd I
data received: LI93
data received: 41 L
data received: CD d
data received: rive
data received: r

Why does this happen?

I'm sending a string from my sketch over Serial port as follows:

Serial.println(F("Found ILI9341 LCD driver"));

On the other side, I have a nodejs app using the serialport npm module, with something like this:

var SerialPort = require('serialport')
var serialPort = new SerialPort('/dev/ttyACM1', {
  baudrate: 9600
})

// it opens the connection and register an event 'data'
serialPort.on('open', function () {
  console.log('Communication is on!')
})

// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function (data) {
  console.log('data received: ' + data)
})

Communication works, but on nodejs side I get the output chunked, as if it had line breaks, like this:

Communication is on!
data received: Pa
data received: int!
data received: 

data received: Fou
data received: nd I
data received: LI93
data received: 41 L
data received: CD d
data received: rive
data received: r

Why does this happen?

Source Link
jotadepicas
  • 326
  • 5
  • 13

Sending string over serial to nodejs app. Why does it get chunked?

I'm sending a string from my sketch over Serial port as follows:

Serial.println(F("Found ILI9341 LCD driver"));

On the other side, I have a nodejs app using the serialport npm module, with something like this:

var SerialPort = require('serialport')
var serialPort = new SerialPort('/dev/ttyACM1', {
  baudrate: 9600
})

// it opens the connection and register an event 'data'
serialPort.on('open', function () {
  console.log('Communication is on!')
})

// when your app receives data, this event is fired
// so you can capture the data and do what you need
serialPort.on('data', function (data) {
  console.log('data received: ' + data)
})

Communication works, but on nodejs side I get the output chunked, as if it had line breaks, like this:

Communication is on!
data received: Pa
data received: int!
data received: 

data received: Fou
data received: nd I
data received: LI93
data received: 41 L
data received: CD d
data received: rive
data received: r

Why does this happen?