java Mac 上的 RxTx - 串行端口已在使用中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12866572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 10:33:41  来源:igfitidea点击:

RxTx on Mac - Serial port already in use

javaarduinorxtx

提问by mkstlwtz

I have RXTXinstalled on a Mac. Both a Java JAR program and the Arduino software see the Arduino as a USB modem if it is Both claim the port is "already in use" if we try to open the serial port. Both claim "Unknown User". I have the rxtxcomm.jarin the Java Extensions.

我在 Mac 上安装了RXTX。Java JAR 程序和 Arduino 软件都将 Arduino 视为 USB 调制解调器,如果我们尝试打开串行端口,则两者都声称该端口“已在使用中”。两者都声称“未知用户”。我rxtxcomm.jar在 Java 扩展中有 。

How do I get either of these to work?

我如何让其中任何一个工作?

回答by mkstlwtz

The OS X has some kind of exclusion mechanism on the serials ports. The MacBook does not have any serial ports, but the USB ports emulate them. When the Arduino is hooked up, it appears in the port list as "/dev/tty.usbmodem..." where ...are some trailing digits.

OS X 在串行端口上有某种排除机制。MacBook 没有任何串行端口,但 USB 端口模拟它们。连接 Arduino 后,它在端口列表中显示为“/dev/tty.usbmodem...”,其中...有一些尾随数字。

When is said the port was busy, that's a standard I/Oexception that meant that we could not get access. The current owner was undefined because there was no current owner. We just did not have the required access to the directory to take ownership.

当说端口繁忙时,这是一个标准的I/O异常,这意味着我们无法访问。当前所有者未定义,因为没有当前所有者。我们只是没有获得所有权所需的目录访问权限。

Using the Apple Terminal, do the following:

使用 Apple 终端,执行以下操作:

 sudo mkdir /var/lock
 sudo chmod a+rw /var/lock

This creates the required directory and makes it accessible. The serial port will no longer be busy, unless of course something else is really using it!

这将创建所需的目录并使其可访问。串口将不再忙碌,除非当然有其他东西真的在使用它!

回答by andreskwan

processing.app.SerialException: Serial port '/dev/tty.usbmodem...' already in use. Try quitting any programs that may be using it.

processing.app.SerialException: 串行端口“/dev/tty.usbmodem...”已在使用中。尝试退出任何可能正在使用它的程序。

This happens to me when my external USB HDD is also connected. when I disconnect it, Arduino's upload process works as it should.

当我的外部 USB 硬盘也连接时,我会发生这种情况。当我断开它时,Arduino 的上传过程会正常工作。

回答by JAMESSTONEco

I found some information on the RXTX site under troubleshooting, Mac OS X. They have a shell script that you can run called fixperm.shthat changes the permissions of /var/lock/. There is more information about /var/lockon the FHS site.

我发现下面的RXTX网站的一些信息,故障排除,Mac OS X的。他们有一个 shell 脚本,您可以运行fixperm.sh该脚本来更改/var/lock/. /var/lockFHS 网站上有更多信息。