简体   繁体   English

写然后等待响应serialport nodejs

[英]Write then wait for response serialport nodejs

i'm trying to use serialport.js and I wondered how can it be possible to write and wait response from the other side because all is asynchronous. 我正在尝试使用serialport.js,但我想知道如何才能编写和等待来自另一端的响应,因为它们都是异步的。

My problem is I must know to which response is associated the send message. 我的问题是我必须知道发送消息与哪个响应相关联。

I think that involve to manage when response never send from the other part. 我认为这涉及管理何时从不发送响应。

Should I use queue system ? 我应该使用队列系统吗? is there a example to do it or a library ? 有没有这样做的例子或图书馆?

thanks in advance. 提前致谢。

You need to write something to parse the stream. 您需要编写一些内容来解析流。 I do this by implementing a writable stream which fires events for the parts of the stream data that I want. 为此,我实现了一个可写流,该流为我想要的流数据部分触发事件。

How you do this specifically depends on the protocol you're trying to implement. 具体执行方式取决于您要实现的协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM