We'll edit our python code to just send command #1 and see what happens. From our logs we know that for sending commands from host-to-device, we should use bRequestType of 0x40 (verify this by looking at the bmRequestType bits of the command packets), wIndex and wLength of zero

For command #1, set bRequest to 0x06 and a wValue to 4. The final argument is now an empty array [] to indicate no data is transmitted

import usb.core
import usb.util
import sys
# find our device
dev = usb.core.find(idVendor=0x045e, idProduct=0x02B0)
# was it found?
if dev is None:
    raise ValueError('Device not found')
# set the active configuration. With no arguments, the first
# configuration will be the active one
ret = dev.ctrl_transfer(0x40, 0x6, 0x1, 0, [])
print ret

We ran our python code and…nothing happened!

OK well maybe that was some initialization command. Lets replace it with the next command #2, set bRequest to 0x06 and a wValue to 1

ret = dev.ctrl_transfer(0x40, 0x6, 0x1, 0, [])

We ran this command and the motor didn't move but the LED stopped blinking.

For fun we ran the previous command again and the LED started blinking again.

Now we have an idea: maybe this bRequest 0x6 controls the LED?

On your own, continue this line of thought by trying different wValues from 0 on up to see what other wValues do, keep track of them all in a notebook or project file.

This guide was first published on Jul 29, 2012. It was last updated on Mar 08, 2024.

This page (Command #1 & 2 - LED blinky!) was last updated on Jun 13, 2012.

Text editor powered by tinymce.