title: Detect serial ports installed on Android device
body: <p>I have various devices with serial ports and I connect a printer to them. The problem is that for configure I have to show to the user all the tty files of the <code>/dev</code> directory.</p>
  
  <p>I've found that the file <code>/proc/tty/drivers</code> contains the prefix of the serial devices:</p>
  
  <blockquote>
  <pre><code> serial    /dev/ttyS    4 64-95 serial
  </code></pre>
  </blockquote>
  
  <p>I want to know only the real serial ports installed on the device. This approximation tells me that
  my device serial ports are :</p>
  
  <blockquote>
  <pre><code>/dev/ttyS0
  /dev/ttyS1
  /dev/ttyS2
  /dev/ttyS3
  </code></pre>
  </blockquote>
  
  <p>But only ttyS0 and ttyS1 exists on my device. How can I detect that?</p>
  
  <p>Note: On a PC with Linux I can do <code>/dmesg | grep tty</code> and returns me the serial ports installed on the PC. Unfortunately on my Android devices this command does not return anything.</p>
  
  <p>Note 2 : Using <code>/proc/tty/drivers</code> I can't discriminate between serial ports and usb ports because all of them are tagged as serial.</p>