Mar*_*ioB 5 linux tty serial-port
我需要禁用然后启用串行端口以在 Java 程序上进行测试。
由于该man页面setserial指出:“使用 UART 类型不会禁用该端口。 ”,我使用sudo setserial /dev/ttyS4 uart none禁用该端口。这成功地禁用了串行端口。为了再次启用串行端口,我使用了该sudo setserial /dev/ttyS4 -a autoconfig端口,并且端口按预期启动。
禁用该端口后,我尝试使用Java gnu.io.CommPortIdentifier函数打开该端口。当我在执行该函数后尝试启用端口时gnu.io.CommPortIdentifier,我得到以下输出:
$ sudo setserial /dev/ttyS4 -a autoconfig
Cannot autoconfigure port: Device or resource busy
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?有没有更好的方法来启用/禁用串行端口?或者我可以清除向端口发出的请求列表吗?
显然我不能直接终止该进程,因为我的测试正在其中运行。
| 归档时间: |
|
| 查看次数: |
18558 次 |
| 最近记录: |