1

I have an Arduino Uno connected through USB to my Ubuntu PC (one USB hub in between).

I run a program that communicate through serial and use then the port /dev/ttyACM0

It works well though not stable, the Arduino, every now and then, suddenly change to \dev\ttyACM1, making the code crash. I can change the port in my code and restart. It will then run well until the Arduino decides to go back to /dev/ttyACM0.

I can't figure out the reason, and even less the solution. Would there be any help here?

Memes
  • 370
  • It sounds like you are saying that your Ubuntu PC is the one that is changing ports randomly. That is also common on Windows PCs. You should know that is a function of the PC, and not of the Arduino. I don't know any way of preventing that in Windows, and I don't have any experience with Ubuntu. But if you think this is an Arduino problem, you may have asked the wrong question. –  Jun 24 '16 at 04:57
  • OK, maybe I'll ask on Ubuntu forum too :) thanks – Memes Jun 24 '16 at 04:58
  • The proper answer to this would be to write the code so that it can handle port changes. – SomeoneSomewhereSupportsMonica Jun 24 '16 at 04:59
  • Check under hardware/tools for a utility called listComPorts. There is a listComPorts.exe in arduino 1.6.4 ide windows, not sure whether they include a posix version. But should be possible for software to enumerate USB VID/PID values. –  Jun 24 '16 at 05:28
  • 2
    you should be able to set a udev rule for this. I don't this question is a fit for this site, this is an OS problem. –  Jun 24 '16 at 05:55
  • Exactly, a UDEV rule for the arduino's serial number to always access the same tty port. –  Jun 24 '16 at 06:00
  • I'm voting to close this question as off-topic because this is really a Linux setup question. Flagged for migration. –  Jun 24 '16 at 06:01
  • the arduino changes USB port while plugged, udev is not enough, I just tried it. it is not like I plug today on one tty and tomorrow on another one – Memes Jun 24 '16 at 06:08
  • 1
    \dev\ttyACM1 is a typo? and yes "udev" is the way to do this. Here is an example creating a softlink; http://playground.arduino.cc/Linux/Udev – Rinzwind Jun 24 '16 at 07:20
  • yes, \dev\ttyACM1 was a typo. I tried udev, it solved half of the problem. It does not change port anymore because it is always on the created Symlink. Well, it appeared that if the Arduino is always changing port it is because there is an underlying issue that makes it disconnect. This is what needed to be tackled. In my case, a view to dmesg | grep usb indicated me that the USB hub was ending the connection to Arduino, then reconnecting it. Further debug made me found out that my relays (what my arduino pilots) are firing back some EMI. I need now to take care of that. – Memes Jun 27 '16 at 02:04
  • so, behind an apparent OS config issue, there was a real electronics and Arduino issue. – Memes Jun 27 '16 at 02:05

1 Answers1

1

Different cases can happen :

  1. The Arduino gets a new USB port each time it is connected. In that case, the solution is to create a symlink for the connection. This is done using udev.
  2. The Arduino randomly changes USB port, without being physically unplugged or the computer to be rebooted. Usage of udev will as well help but further debugging is necessary to understand why the Arduino disconnects in the first place. using udev rule might be enough to workaround the problem but might as well not be enough (for instance if the Arduino is hung after the disconnection happens).
Memes
  • 370