我目前正在使用 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
发布评论
评论(2)
您到
/dev/ttyACM0
的符号链接是双重可疑的:Your symlink to
/dev/ttyACM0
is double dubious:如果您是从 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.