空的Linux模拟器(com0com)for Linux [英] Null modem emulator (com0com) for linux

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

问题描述

我有一个包含一些单一测试的项目,该测试用于测试使用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.

好吧,如果我用猫代替尾巴,我会看到输出(为什么?!)

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)for Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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