Using libusb to communicate with your Arduino board

Today, I investigated the USB capabilities of my Arduino Leonardo compatible boards: the Adafruit ATmega32U4. I bought them a few months ago when the official Leonardo wasn’t available yet. Besides these board are less expensive than the now available Leonardo. Anyway, I’d like to develop my own USB classes to exchange data between a computer and the board. Why develop a new class when by default all the Arduino stack provides the CDC-ACM class emulating a serial port? Simply because it’s fun ;-)

Therefore I began studying the USB protocol and the libusb to write a driver for the CDC-ACM class found on the board. This class is relatively simple yet USB can get much more complicated. I won’t describe all the details of the USB protocol neither the CDC-ACM specifications, so whether you want to read them before or directly dive into the code, I’ll let that to your discretion. Here are a C program using the libusb with comments and the equivalent Python program using PyUSB.

blogroll

social