Current attempt to read data

This commit is contained in:
Eric Jiang 2011-02-13 20:38:25 -05:00
parent 7b4cde73b0
commit d862cd1e94

View File

@ -5,6 +5,15 @@
#include "scales.h" #include "scales.h"
#define DEBUG 1 #define DEBUG 1
/*
* These constants are from libhid/include/constants.h
* and usage based on libhid/src/hid_exchange.c
* also vvvoutput.txt
*/
#define HID_REPORT_GET 0x01
#define HID_RT_INPUT 0x01
#define WEIGH_REPORT_ID 0x06 // Scale Data Report ID
#define WEIGH_REPORT_SIZE 0x07
static libusb_device* find_scale(libusb_device**); static libusb_device* find_scale(libusb_device**);
@ -45,24 +54,29 @@ int main(void)
* Try to transfer data about status * Try to transfer data about status
* *
* http://www.beyondlogic.org/usbnutshell/usb6.shtml * http://www.beyondlogic.org/usbnutshell/usb6.shtml
* test_libhid.c
*/ */
unsigned char blah[8]; unsigned char data[WEIGH_REPORT_SIZE];
libusb_control_transfer( unsigned int len = libusb_control_transfer(
handle, handle,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS |
LIBUSB_RECIPIENT_INTERFACE,
//bmRequestType => direction: in, type: class, //bmRequestType => direction: in, type: class,
// recipient: interface // recipient: interface
0x01, //bRequest => HID get report LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS |
0x0300, //wValue => feature report LIBUSB_RECIPIENT_INTERFACE,
//bRequest => HID_REPORT_GET
// see HID1_11.pdf 60/97 (pg 51)
HID_REPORT_GET,
//wValue => hid report, no report ID
0x0100,
0x00, //windex => interface 0 0x00, //windex => interface 0
blah, data,
8, //wLength WEIGH_REPORT_SIZE, //wLength
1000 //timeout => 1 sec 10000 //timeout => 1 sec
); );
int i; int i;
for(i = 0; i < 8; i++) { printf("Got %d bytes from control transfer:\n", len);
printf("%x\n", blah[i]); for(i = 0; i < WEIGH_REPORT_SIZE; i++) {
printf("%x\n", data[i]);
} }
@ -113,10 +127,12 @@ static libusb_device* find_scale(libusb_device **devs)
libusb_get_bus_number(dev), libusb_get_bus_number(dev),
libusb_get_device_address(dev)); libusb_get_device_address(dev));
printf("It has descriptors:\n\tmanufc: %d\n\tprodct: %d\n\tserial: %d\n", printf("It has descriptors:\n\tmanufc: %d\n\tprodct: %d\n\tserial: %d\n\tclass: %d\n\tsubclass: %d\n",
desc.iManufacturer, desc.iManufacturer,
desc.iProduct, desc.iProduct,
desc.iSerialNumber); desc.iSerialNumber,
desc.bDeviceClass,
desc.bDeviceSubClass);
/* /*
* A char buffer to pull string descriptors in from the device * A char buffer to pull string descriptors in from the device