title: How to find which device is attached to a USB-serial port in Linux using C?
body: <p>We are making a device and it has 8 serial ports. It runs on the Monta Vista Pro5 kernel. And we are working in C.</p>
  
  <p><strong>Suppose:</strong> A device gets attached to ttyUSB0, ttyUSB1 and ttyUSB2. The next device gets connected to ttyUSB3 and another to ttyUSB4. How can I know which device gets attached to which port ?? ie ttyUSB0 or ttyUSB1 or so on. Is there a way to directly query the device and find which port it is attached to. Or, in C, open ttyUSB0, query it somehow and get some reply as to which device it is ??</p>
  
  <p><strong>A rather complicated way:</strong> do a stat of, say /dev/ttyUSB0. Get the device number. And search for this in /proc/bus/usb/devices and find the vendor id or something to identify the device.</p>
  
  <p><strong>Or:</strong> Is there some way to reserve ttyUSB0,ttyUSB1 and ttyUSB2 for one device, ttyUSB3 for another and so on when they are plugged in ? This way I will know which device is connected to which port.</p>
  
  <p>Help please..... :)</p>
  
  <p>Thanks in advance.
  Nubin Stanley</p>