<br><br><div><span class="gmail_quote">On 5/20/07, <b class="gmail_sendername">Jon Hylands</b> &lt;<a href="mailto:jon@huv.com">jon@huv.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi everyone,<br><br>On my current robotics project, I&#39;m using a gumstix verdex to talk over a<br>USB to serial converter chip (FT232) to a serial bus.<br><br>My brother Dave made up a new kernel driver for the gumstix, and when I
<br>plug in the chip it registers itself as ttyUSB0.<br><br>For work I&#39;ve done previously on Squeak on the gumstix, I&#39;ve used standard<br>serial ports, which map to ttyS0, ttyS1, ttyS2, etc, which correspond to<br>
port 0, 1, and 2 when I open the Serial Port in Squeak. However, I have no<br>idea which port number ttyUSB0 corresponds to...<br><br>Anyone got any idea?<br><br></blockquote></div><br>I have to scratch this itch :-). This is something I should know but don&#39;t.
<br><br>At a guess, I&#39;d say this is your answer, from usb-serial.c in the Linux kernel:<br><br>static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_ports, unsigned int *minor)<br>{<br>&nbsp;&nbsp;&nbsp; unsigned int i, j;
<br>&nbsp;&nbsp;&nbsp; int good_spot;<br><br>&nbsp;&nbsp;&nbsp; dbg(&quot;%s %d&quot;, __FUNCTION__, num_ports);<br><br>&nbsp;&nbsp;&nbsp; *minor = 0;<br>&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; SERIAL_TTY_MINORS; ++i) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (serial_table[i])<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;<br><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; good_spot = 1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (j = 1; j &lt;= num_ports-1; ++j)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((i+j &gt;= SERIAL_TTY_MINORS) || (serial_table[i+j])) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; good_spot = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i += j;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (good_spot == 0)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *minor = i;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dbg(&quot;%s - minor base = %d&quot;, __FUNCTION__, *minor);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (i = *minor; (i &lt; (*minor + num_ports)) &amp;&amp; (i &lt; SERIAL_TTY_MINORS); ++i)
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; serial_table[i] = serial;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return serial;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return NULL;<br>}<br><br>I&#39;m assuming that serial_table[] is a list of the ttyUSBn ports, and this just finds a free one starting from ttyUSB0, but somebody smarter than me is going to have to verify this.
<br><br>Also mentioned somewhere is that the device allocation will appear in the system logs. That&#39;s a pretty disgusting way to find the device mappings. Another way would be to iterate through the /dev/ttyUSB*&#39;s to find your device which I find equally disgusting. It&#39;s probably easiest to simply assume that it is always /dev/ttyUSB0 or /dev/usb/tts/0 if you&#39;re using devfs.
<br><br>Did Dave write the code, or did he simply compile it? It sounds like he&#39;d be the person to ask, and I&#39;m surprised he didn&#39;t make a /dev/microraptor for you :-).<br><br>Michael.<br>p.s. I&#39;ve seen a video of your raptor - it rocks!
<br>