Linux下软件串口环回
目前我需要开发一些通过串行线与思科设备通信的程序。我想在我的开发linux机器上构建测试环境。所以,我找到了dynamips cisco模拟器。该模拟器可以通过带有“-U /dev/ttyS0”选项的串行线提供接口。好吧,这会导致 dynamips 打开硬件串行端口并通过它进行通信。我可以使用 minicom 等串行客户端从另一台 Linux 机器连接到此硬件串行端口。
但是,由于我在两台 Linux 机器上使用 virtualbox,因此我通过 virtualbox 功能链接串行端口,将串行端口转发到命名管道。这个方案似乎有效,但是非常多余。我正在寻找一种在单个 Linux 机器上运行 dynamips 和 minicom 的方法。
我发现伪终端对我来说可能很有用。但我尝试使用“-U /dev/ptmx”运行 dynamips,然后与 minicom 连接以创建 /dev/pts/... 端口,反之亦然。在这两种情况下,我的两侧都有输入/输出错误。
Currently I need to develop some program that will communicate with cisco devices over serial line. I want to build testing environment on my development linux machine. So, I found dynamips cisco emulator. This emulator can provide interface via serial line with '-U /dev/ttyS0' option. Well, this causes dynamips to open hardware serial port and communicate via it. I'm able to connect to this hardware serial port from another linux machine with serial client like minicom.
However, since i'm using virtualbox for both linux machines, I link serial ports via virtualbox ability to forward serial port to named pipe. This scheme seems to be working, but very redunant. I'm looking for a method to run dynamips and minicom on a single linux machine.
I found that pseudo-terminals could be useful in my case. But I've tried to run dynamips with '-U /dev/ptmx' and then connect with minicom to created /dev/pts/... port and vice versa. In both cases I've got input/output error on both sides.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,现代伪终端并不那么容易。使用
posix_openpt()
或open("/dev/ptmx")
打开 master 后,必须调用grantpt()
和在主FD及其相应的从设备可用之前,先在主FD上解锁pt()
。 (openpty()
等实用函数简化了这一点。)作为一种解决方法,方便的 socat 可能有用。
Unfortunately, modern pseudo-terminals aren't that easy. After opening the master with
posix_openpt()
oropen("/dev/ptmx")
, you must callgrantpt()
andunlockpt()
on the master FD before it and its corresponding slave device are usable. (Theopenpty()
etc. utility functions simplify this.)As a workaround, the ever handy socat may be of use.