title: Find which TTY port Arduino is connected to in Ubuntu using C/C++
body: <p>I'm writing a program in <a href="http://en.wikipedia.org/wiki/C++" rel="nofollow">C++</a>, and it is required to communicate to an Arduino via <a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus" rel="nofollow">USB</a>. Each time the Arduino restarts, it is possible that the port the Arduino is connected to changes (for example, located at <code>/dev/ttyAMC0</code>, Arduino restart, connected at <code>/dev/ttyAMC1</code>).</p>
  
  <p>The code I am using is</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  ...
  arduino = open("/dev/ttyAMC0", O_RDWR | O_NOCTTY | O_NDELAY);
  if(arduino != -1) 
      fcntl(_arduino, F_SETFL, 0);
  ...
  </code></pre>
  
  <p>Each time the Arduino changes port locations, I have to manually change this in my code and then re-compile my program.</p>
  
  <p>Is there a way to determine exactly which port the Arduino connected to, and have the location returned to me as a string (that is, "/dev/ttyACM1")?</p>