用于 linux 的空调制解调器模拟器 (com0com) [英] Null modem emulator (com0com) for linux

查看:11
本文介绍了用于 linux 的空调制解调器模拟器 (com0com)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中包含一些用于测试使用 COM 端口(在 Windows 中)的串行通信的单一测试.我使用 com0com 创建一对虚拟的有界端口并执行测试.

I have a project that contains some unitary tests used to test the serial communications using COM ports (in windows). I use com0com to create a virtual pair of bounded ports and execute the tests.

但是我不知道如何在 Linux 和 MACOS 中做到这一点.我读过这个话题:Linux中有像COM0COM这样的程序吗? 答案建议使用 socat.我已经尝试过这种方法,但它不起作用,我的应用程序没有检测到我刚刚在 socat 中定义的端口.

However I don't know how to do that in Linux neither in MACOS. I've read this topic: Are there some program like COM0COM in linux? Where the answer suggests using socat. I've tried that approach but it doesn't work, my application doesn't detect the ports I've just defined in socat.

socat PTY,link=/dev/COM98 PTY,link=/dev/COM99

我的理论是socat不能创建虚拟端口,它只能绑定现有的端口.

My theory is that socat cannot create virtual ports, it can only bind together existing ports.

我该如何解决这个问题?

How can I solve this issue?

谢谢!

这是我运行上一个 socat 命令后得到的.如果仔细观察,您会发现 COM98 和 COM99 端口位于/dev/中.但是,如果我写入/dev/COM98 并使用 tail -f 来跟踪 COM99,我不会从中得到任何输出.

This is what I get after running the previous socat command. If you look closely, you'll see that COM98 and COM99 ports are in /dev/. However if I write to /dev/COM98 and use tail -f to follow COM99 I don't get any output from it.

好吧,如果我使用 cat 而不是 tail 我可以看到输出(为什么?!)

Well, if I use cat instead of tail I can see the output (why?!)

'

'

'

解决方案:不要将端口命名为 COMxx 而是 ttySxx!

SOLUTION: Don't name the ports COMxx but ttySxx instead!

例子:

socat PTY,link=/dev/ttyS98 PTY,link=/dev/ttyS99

原因:某些串行通信库可能不支持其他命名法,例如 RXTX 2.X.X 和以前的版本.

Reason why: Some serial-comm libraries may not support other nomenclature, such as RXTX 2.X.X and previous versions.

推荐答案

socat -d -d pty,raw,echo=0 pty,raw,echo=0

工作正常并打印:

2014/05/26 13:29:15 socat[27177] N PTY is /dev/pts/32
2014/05/26 13:29:15 socat[27177] N PTY is /dev/pts/33
2014/05/26 13:29:15 socat[27177] N starting data transfer loop with FDs [3,3] and [5,5]

我假设您应该能够写入/dev/pts/32 并从/dev/pts/33 读取.

I assume that you should be able to write to /dev/pts/32 and read from /dev/pts/33.

/dev/COM9{8,9} 也是您可以使用的字符设备吗?

Also is /dev/COM9{8,9} a character device you can use?

ls -l /dev/COM989 

如果是这种情况,应该打印一个以 c 开头的模式.

should print a mode which starts with c if that is the case.

这篇关于用于 linux 的空调制解调器模拟器 (com0com)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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