无法使用 Interceptty 或 slsnif 嗅探通过串口发送的数据 [英] Can't use Interceptty or slsnif to sniff data sent via serial port

查看:92
本文介绍了无法使用 Interceptty 或 slsnif 嗅探通过串口发送的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确切地确定控制器向具有自己的处理器的板外电机控制器发送了哪些数据.我也没有成功使用纯文本命令或 json 命令.有一个电机控制器可以使用的程序,但是我需要我自己的程序以正确的格式发送相同的信息.使用的软件是 Coolterm 和一个 tinyg 板.

I want to determine exactly what data is sent by a controller to a off-board motor controller that has its own processor. I have not had success with plain text commands or json commands either. There is a program that the motor controller works with, however I need my own program to send the same information in the right format. Software being used is Coolterm and a tinyg board.

通过拦截,我已经能够从电机控制器获得一种方式的通信,但不能将数据发送到控制器.<代码>"拦截 -s 'ispeed 115200 ospeed 115200'/dev/ttyUSB0/dev/tty<>"在<>" 中,我尝试了自己的单词、字母或其他目录,例如 S1.我也试过 /dev/<> 但coolterm 无法在下拉菜单中识别它.

With interceptty I have been able to get one way communication back from the motor controller but not the data being sent to the controller. "interceptty -s 'ispeed 115200 ospeed 115200' /dev/ttyUSB0 /dev/tty<>" In the "<>" I have tried my own words, letters, or other directories like S1. I have also tried /dev/<> but coolterm won't recognize it in the dropdown menu.

没有真正的错误消息,只是无法获取计算机发送的数据.可以获取收到的数据.

No real error message just can't get data being sent by the computer. Can get data received.

推荐答案

在我的设置中,我在 /dev/ttyUSB0/dev/ttyUSB0 上有两个真正的(好吧,它们实际上是 USB 到串行适配器)串行端口code> 和 /dev/ttyUSB1.我用电线将它们连接在一起:端口 0 上的 RX 转到端口 1 上的 TX,端口 0 TX 转到端口 1 RX.

In my setup, I have two real (well, they are actually USB-to-serial adaptors) serial ports on /dev/ttyUSB0 and /dev/ttyUSB1. I have linked them together with wires: RX on port 0 goes to TX on port 1, port 0 TX goes to port 1 RX.

我可以打开两个终端并使用 minicom 或任何其他终端实用程序将文本从端口 0 发送到端口 1,反之亦然.

I can open two terminals and send text from port 0 to port 1 or viceversa with minicom or any other terminal utility.

现在,如果我想嗅探这个链接,我可以执行以下操作:首先我创建几个虚拟串行端口并将它们链接到我的真实端口:

Now, if I want to snif on this link I can do the following: first I create a couple of virtual serial ports and link them to my real ports:

$ sudo socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,link=/dev/ttyUSB1,raw,echo=0

这是我得到的输出(注意创建的虚拟设备的名称):

This is the output I get (note the names of the virtual devices created):

2019/07/23 08:23:32 socat[10743] N PTY is /dev/pts/1
2019/07/23 08:23:32 socat[10743] N PTY is /dev/pts/2
2019/07/23 08:23:32 socat[10743] N starting data transfer loop with FDs [5,5] and [7,7]

然后我可以在第三个终端上运行拦截:

And then I can run interceptty on a third terminal:

$sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/2  /dev/ttyUSB1

我现在将看到总线上传输的所有数据.这是我使用 minicom 在端口 0 和端口 1 上捕获写入的示例:

I will now see all data traveling on the bus. This is an example of what I capture writing on port 0 and port 1 with minicom:

>       0x48 (H)
>       0x65 (e)
>       0x6c (l)
>       0x6c (l)
>       0x6f (o)
>       0x2c (,)
>       0x20
>       0x74 (t)
>       0x68 (h)
>       0x69 (i)
>       0x73 (s)
>       0x20
>       0x69 (i)
>       0x73 (s)
>       0x20
>       0x61 (a)
>       0x20
>       0x74 (t)
>       0x65 (e)
>       0x73 (s)
>       0x74 (t)
>       0x20
>       0x66 (f)
>       0x72 (r)
>       0x6f (o)
>       0x6d (m)
>       0x20
>       0x55 (U)
>       0x53 (S)
>       0x42 (B)
>       0x30 (0)
< 0x41 (A)
< 0x6e (n)
< 0x64 (d)
< 0x20
< 0x6e (n)
< 0x6f (o)
< 0x77 (w)
< 0x20
< 0x66 (f)
< 0x72 (r)
< 0x6f (o)
< 0x6d (m)
< 0x20
< 0x55 (U)
< 0x53 (S)
< 0x42 (B)
< 0x31 (1)

对于您的特定情况,您的计算机上只有一个端口,因此您可以通过一个链接创建虚拟端口对:

For your particular case, you only have one port on your computer, so you can create the virtual port pair with just one link:

$ sudo socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,raw,echo=0

并运行两个拦截会话:

$ sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/1 /dev/ttyUSB0
$ sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/2 /dev/ttyUSB0

为了让它可靠地工作,我必须先运行两个拦截实例,然后打开 USB 端口(在我的例子中是 minicom).

For this to work reliably, I have to run first the two instances of interceptty and then open the USB ports (in my case with minicom).

Windows 用户可以参考此处以获得类似的解决方案使用 Termite 和 com0com.

Windows users can refer here for a similar solution using Termite and com0com.

请注意,这些过程仅在您没有激活硬件流控制时才有效.

Note that these procedures only work if you don't have hardware flow control active.

这篇关于无法使用 Interceptty 或 slsnif 嗅探通过串口发送的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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