Hi everynone and Good Afternoon
I am looking to implement a Program using Python for USB interfacing.
How should i go for it.Any idea?

PyUSB seems to be the recommended way of talking to USB devices. Here's a small example inspired by their tutorial:

import usb.core
# find() can be used to find a single device,
# or all devices.
devices = usb.core.find(find_all=True)

# I'm just printing the list of devices.
# I'm not big on raw usb communications.


[<usb.core.Device object at 0x7f19fba6b7b8>,
 <usb.core.Device object at 0x7f19fba6b828>,
 <usb.core.Device object at 0x7f19fba6b8d0>,
 <usb.core.Device object at 0x7f19fba6b978>,
 <usb.core.Device object at 0x7f19fba6ba20>,
 <usb.core.Device object at 0x7f19fba6bac8>]

What you want to do with these devices is up to you. I think you can read/write and set/get config values. You may need the proper permissions to access them though (so sudo or Admin may be needed).

But if you are just trying to communicate over a serial line (as I have done with my Arduino/RaspberryPi) then you can use the serial library (pySerial). This is again a small example taken from their tutorial:

import serial
# This just finds the first serial port and uses the
# default rate. All of this is customizable.
ser = serial.Serial(0)
# Print the name of the actual port we are using.
# Always release your resources.

Edited 2 Years Ago by chriswelborn: Formatting, spelling, comments

This article has been dead for over six months. Start a new discussion instead.