Ad

Nodejs Serialport Cannot Run Both Code At The Same Time

I am trying to stream data in from the MSP432 xds110 so i can plot it on my website in real time.

To do this i am using node.js serialport library to get the data. this is the page for serialport: https://serialport.io/docs/guide-usage

in my MSP432 code it is very similar to the arduino and i am simply counting and printing numbers to the serial monitor - this part works.


Now the problem is here:

  • if i run the msp432 code i cannot run my nodejs code because the port is being used.

  • if i run my nodejs code i cannot run my msp432 code because the port is being used


How am i suppose to run and read the data at the same time?

I have attached the nodejs code i am currently using.

  const SerialPort = require('serialport');
  const myPort = new SerialPort("COM5", {
   baudRate: 9600
  })

  myPort.on('open', function () {
    console.log("opened the port")
  })

  myPort.on('data', function (data) {
  console.log('Data:', data)
  })

extra info:

The MSP432 XDS110 has 2 ports for some reason, since i am using COM5 (xds110 user UART) to send the data to the serial monitor that is the same port i am using in the code. There is also the data port COM6 but from what i have searched it does nothing.

Ad

Answer

Solved it myself....

I had the serial monitor open, if you have it open you are using the port, so close the serial monitor and just view the data in the nodejs file

You should run the microcontroller code but just dont open the serial monitor.

Ad
source: stackoverflow.com
Ad