Not able to read data from serial port after initializing it with dynamic path and baud rate. #2572
Unanswered
sinister296
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on an app using Electron along with typescript and react.
I am using the SerialPort library in the main process of the app (the electron end, although my issue can be generalized though out.)
So, I am trying to pass the path and baud rate to the "new SerialPort({options})" from the front end and then initialize it. I have managed to achieve it by using typescript and creating a class for the serial port. Now the problem is with using the SerialPort.on('data') event. As I am not able to declare it independently inside the class.
Here's the code for creating the class:
export class SerialCommunication {
private port: SerialPort
}
Now, I'm trying to figure out a viable method to read the data incoming from the port. Since the parser.on('data') listener on works once immediately after the open function is called on the class from the other file.
Beta Was this translation helpful? Give feedback.
All reactions