<div class="gmail_quote">On Tue, Mar 30, 2010 at 9:01 AM, Marc <span dir="ltr">&lt;<a href="mailto:marc@marcd.org">marc@marcd.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<br>
I was wondering if anyone could point me to Python modules or example code for accessing USB connected devices.  I would like to get as close to the hardware as possible with Python.  I would like to be able to monitor as well as control USB connected devices.  I&#39;ve looked at the missile launcher code by Pedram Amini at <a href="http://dvlabs.tippingpoint.com" target="_blank">dvlabs.tippingpoint.com</a>, but am looking to see what else has been done in this area.<br>

<br></blockquote><div><br></div><div>I&#39;ve used pyserial, I believe, to directly access the usb. Here&#39;s the important connection bits of my code:</div><div><br></div><div><div>import serial</div><div><br></div><div>

class pyDuin:</div><div>    ser = serial.Serial()</div><div>    def __init__(self, port=&quot;/dev/ttyUSB0&quot;, baud=&quot;115200&quot;, timeout=0):</div><div>        self.ser.baudrate = baud</div><div>        self.ser.port = port</div>

<div>        self.ser.timeout = timeout</div><div><br></div><div>    def ready(self):</div><div>        self.ser.write(&quot;%c&quot; % 41) </div><div><br></div><div>    def open(self):</div><div>        self.ser.open()</div>

<div>        if not self.ser.isOpen():</div><div>            print &quot;Error, not able to open serial connection on %s&quot; % \ </div><div>                    (self.ser.port, )</div><div><br></div></div><div>-------------</div>

<div><br></div><div>I was using it to connect to my arduino. If you&#39;d like the rest of the source, let me know.</div><div><br></div><div>HTH,</div><div>Wayne</div></div>