USB/串口与Netty通信
在我们的组织中,我们通过 UDP 和 TCP 实现了自己的协议,让连接到互联网的外部设备与我们使用 Netty 开发的服务器交换消息(确实如此!)。
出于测试目的,我们希望通过 USB/串行接口将这些设备直接连接到我们的计算机(我们尚未选择串行通信库)。我们还希望在计算机上部署/移植为设备开发的嵌入式软件,以模拟设备并使用命名管道(IPC)等直接连接到我们的服务器。
在 Netty 架构概述文档中,您声称我们可以使用Netty 也适用于此类串行通信:
“此外,您甚至可以通过仅替换几行构造函数调用来利用尚未编写的新传输(例如串行端口通信传输)。此外,您可以编写通过扩展核心 API,您自己的传输。”
是否有人已经在 Netty 中开发了此类实现,或者其他人是否计划进行此类实现?我还想知道 Netty 是否真的非常适合这种情况,因为 Channel 接口和许多其他接口使用 SocketAddress 来绑定/连接到对等点?
谢谢您的建议、忠告!
In our organisation, we implemented our own protocol over UDP and TCP to let external devices connected to the Internet exchange messages with a server that we developed using Netty (indeed!).
For testing purpose, we would like to connect those devices directly to our computers through USB/serial interface (we did not choose the serial communication library yet). We would also like to deploy/port the embedded software we developed for our devices on our computer to simulate the devices and to connect directly to our server using a named pipe for example (IPC).
In the Architecture Overview documentation of Netty, you claim that we could use Netty as well for such serial communication:
"Also, you are even able to take advantage of new transports which aren't yet written (such as serial port communication transport), again by replacing just a couple lines of constructor calls. Moreover, you can write your own transport by extending the core API."
Is anyone somewhere already developed such implementation in Netty or does someone else plan to do such implementation? I am also wondering if Netty is really well-suited for that since the Channel interface and many other ones use a SocketAddress to bind/connect to a peer?
Thank you for your suggestions, advices!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想知道您是否可以使用新的 iostream 包来实现这一点。这里你所需要的只是一个输入流和输出流。请参阅[1]
[1] https://github.com/netty/netty/tree/master/transport/src/main/java/io/netty/channel/iostream
I wonder if you may be able to use the new iostream package for that. All you need here is an InputStream and Outputstream. See [1]
[1] https://github.com/netty/netty/tree/master/transport/src/main/java/io/netty/channel/iostream
实施这样的解决方案是可能的。我没有遇到与 SocketAddress 绑定的问题。
我正在发布我的 USB 连接与 Netty 的实现。
串行通信非常相似,为了简洁起见,我不会发布它。不过,如果有人需要的话,我也很乐意添加它。
这是连接的基类。 ChannelHandler根据通信需要实现。
需要对该连接器进行扩展以实现所需的连接类型以及通道实现。
USB 连接器:
USB 通道:
It is possible to implement such a solutions. I have not meet problems with binding with SocketAddress.
I’m posting my implementation of USB connection with Netty.
Serial communication is quite simillar, I'm not posting it for brevity. However I am happy to add it as well if anyone needs it.
Here is base class for connection. A ChannelHandler shall be implemented according to communication needs.
An extensions of that connector for needed type of connection together with Channel implementations is needed.
USB connector:
USB Channel: