[英]How to use serial port in a Mono application under Linux?
I would like to use an application under Debian, that is written in .net appearantly.我想在 Debian 下使用一个应用程序,它看起来是用 .net 编写的。 I don't have the source, only the .exe file.
我没有源,只有 .exe 文件。 I installed mono from the Debian repositories.
我从 Debian 存储库安装了 mono。 The program starts and runs fine.
该程序启动并运行良好。
The program is not a complicated one, and uses serial port.程序并不复杂,使用串口。 (This is a car ECU programmer.)
(这是一个汽车ECU程序员。)
The program seems written in a way, I can only select COM0...COM100 as serial port, seems not prepared for Linux.程序好像写得有点像,我只能选择COM0...COM100作为串口,好像不是为Linux准备的。
Is there any way for making it work under Linux?有没有办法让它在Linux下工作?
What I did so far, I added an udev rule (ACTION=="add" KERNEL=="ttyUSB0" NAME="COM0"), but it didn'T work.到目前为止,我添加了一个 udev 规则(ACTION=="add" KERNEL=="ttyUSB0" NAME="COM0"),但是没有用。
Is there any way on operating system or on mono framework level, that would lure the program to use the /dev/ttyUSB0 by selecting "COM0" in the application itself?在操作系统或单声道框架级别上有什么方法可以通过在应用程序本身中选择“COM0”来引诱程序使用 /dev/ttyUSB0 吗?
Error messages in the application when trying to reach the COM0 port: "CloseObdPort: Object reference not set to an instance of an object" and then "No such file or directory"尝试访问 COM0 端口时应用程序中的错误消息:“CloseObdPort:未将对象引用设置为对象的实例”,然后是“没有这样的文件或目录”
Regards, Daniel问候, 丹尼尔
Check that the user is member of dialout group.检查用户是否是拨出组的成员。 You can do this using the 'groups' command.
您可以使用“groups”命令执行此操作。
To add a user to dialout group, you can use -: 'sudo adduser username dialout'要将用户添加到拨出组,您可以使用 -: 'sudo adduser username dialout'
From memory I think you need to log out & back in to take effect.根据记忆,我认为您需要注销并重新登录才能生效。
I'm answering my own question:我在回答我自己的问题:
The solution is surprisingly simpe: I created a symlink ./COM0 -> /dev/ttyUSB0解决方案非常简单:我创建了一个符号链接 ./COM0 -> /dev/ttyUSB0
This way the application was looking for "COM0" in the application root, it found the symlink and managed to open the port.通过这种方式,应用程序在应用程序根目录中寻找“COM0”,它找到了符号链接并设法打开了端口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.