嗅探串口数据而不从缓冲区中删除数据 [英] Sniffing data of serial port without removing data from buffer

查看:85
本文介绍了嗅探串口数据而不从缓冲区中删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 bgapi 库来管理使用 USB 加密狗的蓝牙通信.该库将从我的程序中获取命令,并在其自己的线程中通过 COM 端口处理所有串行通信.我想回显来自 COM 端口的所有数据,但库只允许我访问它选择自己解析的内容.

我可以进入 bgapi 库并更改代码的功能,设置一个变量或函数来返回当前正在读取的数据,但其他人也在做这个项目,更改库可能会导致更大的问题或使更新无效.

有什么方法可以让我在不干扰库的情况下访问进入 COM 端口的数据,例如嗅探通过 COM 端口的数据而不将其从库的缓冲区中取出?库为自己打开端口并丢弃我想查看的额外数据.

解决方案

我不确定我是否完全理解你的库是如何工作的,所以我不确定这对你有用,但你还是可以尝试一下.

您(在 Windows 上)可以做的是使用

为 COM1 选择正确的设置后,您通过单击标记为 COM1 57000 bps... 的大按钮接受并连接,您将看到 COM1 上传入的所有内容都转发到 COM2 并显示在控制台上.

I am using the bgapi library to manage bluetooth communication using a USB dongle. The library will take a command from my program and will handle all serial communications through the COM port in its own thread. I want to echo back all data coming out of the COM port, but the library only gives me access to what it chooses to parse out itself.

I could go into the bgapi library and change the functionality of the code, setting up a variable or function to return what data is currently being read, but other people are also working on this project and changing the library could cause larger problems or invalidate updates.

Is there any way for me to access the data coming into the COM port without interfering with the library, like sniffing the data going through the COM port without taking it out of the buffer for the library? The library holds the port open for itself and discards the extra data that I want to see.

解决方案

I'm not sure I understood completely how your library works so I'm not sure this will work for you but you can give it a try anyway.

What you can do (on Windows) is use Termite as a man-in-the-middle with port forwarding.

Since you probably want to keep everything inside one computer you can use com0com to create a couple of virtual ports.

To activate port forwarding on Termite you have to go to settings and then forward on the bottom-left side of the screen. You'll see a menu where you can choose the port you want to forward to. On the following screenshot I can forward from COM1 to COM2:

After selecting the right settings for COM1 you accept and connect by clicking on the big button marked COM1 57000 bps... and you'll see everything incoming on COM1 forwarded to COM2 and displayed on the console.

这篇关于嗅探串口数据而不从缓冲区中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆