On Wed, Jun 29, 2011 at 11:00 AM, Vishwanath Saragadam
<vishwa....@gmail.com> wrote:
> DLL version:    0.1.12.1
> Driver version:    0.1.12.1

Please update to the latest version, which is 1.2.4.0 for the
release version (and 1.2.4.6 for snapshot version).

> bus/device  idVendor/idProduct
> bus-0/\\.\libusb0-0001--0x04d8-0x0204     04D8/0204
> - Manufacturer : Microchip Technology Inc.
> - Product      : Microchip Libusb Example Device

Are you using the stock Microchip libusb example? If yes,
then you should already know the protocol and they
have already a libusb based example. Read the codes
carefully and then port it to pyusb.

Eg:
1)toggle LED.

char OutputPacketBuffer[64];
//Allocate a memory buffer which will contain data to send to the USB device

OutputPacketBuffer[0] = 0x80;           
//0x80 is the "Toggle LED(s)" command in the firmware
//For simplicity, we will leave the rest of the buffer uninitialized,
but you could put rea
//data in it if you like.
//Writes data to a bulk endpoint. The Function call will send out 64
bytes to the USB Device.
     if(usb_bulk_write(MyLibusbDeviceHandle, 0x01,
&OutputPacketBuffer[0], 64, 5000) != 64)
         {
            return;
         }

2) read push button status

 char OutputPacketBuffer[64];
 //Allocate a memory buffer which will contain data to send to the USB device

 char InputPacketBuffer[64];
 //Allocate a memory buffer for the data which we will read from the USB device

 OutputPacketBuffer[0] = 0x81;
 //0x81 is the "Get Pushbutton State" command in the firmware
 //For simplicity, we will leave the rest of the buffer uninitialized,
but you could put real
 //data in it if you like.

 //To get the pushbutton state, first, we send a packet with our "Get
Pushbutton State" command in it.
 //The following call to usb_bulk_write() sends 64 bytes of data to
the USB device.
 if(usb_bulk_write(MyLibusbDeviceHandle, 0x01, &OutputPacketBuffer[0],
64, 5000) != 64)
 {
     return;
 }

 //Now get the response packet from the firmware.
 //The following call to usb_bulk_read() retrieves 64 bytes of data
from the USB device.
 if(usb_bulk_read(MyLibusbDeviceHandle, 0x81, &InputPacketBuffer[0],
64, 5000) != 64)
 {
     return;
 }

 //InputPacketBuffer[0] is an echo back of the command.
 //InputPacketBuffer[1] contains the I/O port pin value for the pushbutton.
 if (InputPacketBuffer[1] == 0x01)
 {
     StateLabel->Text = "State: Not Pressed";
 }
 else
 {
     StateLabel->Text = "State: Pressed";
 }

If you have changed the firmware, then you should following your own
firmware protocol and not to just write any codes and expect it to work.

-- 
Xiaofan

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to