Linux下的Arduino(RXTX)? - 适用于 Windows

发布于 2025-01-08 06:07:10 字数 882 浏览 0 评论 0 原文

我目前正在使用 Java 开发一个程序来与 Arduino 模块交互。现在在 Windows 中,到目前为止它运行得很好(我收到了我所期望的;我可以处理数据),但在 Linux 中(Ubuntu 在我的例子中);恰恰相反。我安装了 Arduino 和 rxtx-java 软件包。

当我尝试使用 Arduino 程序连接到 Arduino 板时,我必须在 ACM 模块上设置到某个串行或 USB 模块的软链接。例如,

ln -s /dev/ttyACM0 /dev/ttyS99

否则它甚至不会出现在 Arduino 程序的列表中。所以我当时所做的就是启动串行监视器工具(Ctrl + Shift + M)并向其发送我的启动序列以等待答案。它在那里工作没有问题(它是二进制数据,所以我无法验证它是否正确,但我至少得到了答案)。

我做的下一件事是尝试对我的程序执行相同的操作,因此将 Arduino 连接到 PC,软链接设置正确,列出了设备以及我的程序中 PC 中的两个普通 COM 端口,并且我尝试连接,但没有成功。

没有错误,没有什么,只是董事会没有答复。我等了几分钟后,它仍然没有做任何事情,所以我断开了它与 PC 的连接,然后我得到了一个零字节数组作为答案。

什么可能导致此类问题以及如何解决?

感谢您的帮助 Volker

PS:该程序是一个 jar 文件,其中包含所有库/依赖

项编辑: 硬件是 Arduino UNO Board Model R3,在 Windows 上我使用 Arduino 1.0 对其进行编程

I'm currently developing a programm with Java to interact with an Arduino module. Now in Windows, it's running pretty well so far (I receive what I expect; I can work with the data), but in Linux (Ubuntu in my case); it's like the opposite. I installed Arduino and rxtx-java packages.

When I tried to use the Arduino program to connect to the Arduino board, I had to set a softlink on the ACM module to some serial or USB module. For example,

ln -s /dev/ttyACM0 /dev/ttyS99

Otherwise it won't even show up in the list in the Arduino program. So what I did then was starting the serial monitor tool (Ctrl + Shift + M) and sent it my start sequence waiting for an answer. It worked without a problem there (it was binary data so I couldn't verify if it was correct, but I got an answer at least).

The next thing I did was trying to do the same with my program, so the Arduino was connected to the PC, the softlink was set correctly, the device listed along with two normal COM-ports I have in my PC in my program, and I tried to connect, but it didn't work.

No error, no nothing, simply no answer of the board. After I waited a couple of minutes, it still didn't do anything, so I disconnected it from the PC, and then I got an array of zero-bytes as the answer.

What could cause this kind of problems and how would I fix it?

Thanks for your help
Volker

PS: the program is a jar file with all libraries/dependencies included

EDIT:
Hardware is an Arduino UNO Board Model R3,and on windows i'm using Arduino 1.0 to program it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守望孤独 2025-01-15 06:07:10

您到 /dev/ttyACM0 的符号链接是双重可疑的:

  • 断开+重新连接或关闭+打开电源可能会更改开发人员的编号。
  • ttyACM 通常指调制解调器,而不是像 Arduino 使用的普通 USB 串行转换器(至少是那些带有 FT232 芯片的转换器)。我期望像 ttyUSB0 这样的东西。对于那些你也不需要符号链接。

Your symlink to /dev/ttyACM0 is double dubious:

  • Disconnecting+reconnecting or powering off+on might change the number of the dev.
  • ttyACM usually refers to modems, not to plain USB-serial converters like that used by Arduino (at least those with the FT232 chip). I would expect something like ttyUSB0. For those you also would not need a symlink.
°如果伤别离去 2025-01-15 06:07:10

如果您是从 Ubuntu 软件包安装的,那么您肯定会遇到问题。我自己先尝试了一下,结果发现存在严重的问题。我建议下载最新版本的 IDE arduino-1.0-src。 tar.gz

你会注意到它是来源,我想你会更喜欢这样。或者您可以从 Git 获取存储库,您将找到该信息以及如何在 构建 Arduino,首次设置步骤。除了 Ubuntu 发行版存在 bug 之外,它也像一样,很旧。

If you installed from the Ubuntu packages you're bound to have problems. I tried this first myself only to find that there are serious issues. I would recommend downloading the most recent version of the IDE arduino-1.0-src.tar.gz.

You'll notice it's the source, I think you'll like it better that way. Or you can get the repository from Git, you'll find that information plus how to build the IDE in Building Arduino, Steps for First Time Setup. Besides the fact that the Ubuntu distribution version is buggy, it's also like old, big time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文