L
L
lamazavr2016-04-22 10:17:07
Node.js
lamazavr, 2016-04-22 10:17:07

How to deal with serial port in nodejs synchronously?

Good day everyone!
The task is to implement an exchange protocol over a serial channel.
Decided to use the node-serialport module ( https://github.com/voodootikigod/node-serialport).
Trouble: there are a lot of protocols, they have a synchronous interface (modules in C ++), you need to make this one synchronous too (get rid of callbacks).
Is it possible somehow in js to organize waiting for a response?
Desired example:

> var regs = bus.readRegister(100, 3);
[100, 101, 102]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fetis26, 2016-04-22
@fetis26

If you remove asynchrony, then the node process will only wait until the data arrives. If the data goes once an hour, this is a bad decision. What is the problem to do with callbacks. It's simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question