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"
#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**);
@ -45,24 +54,29 @@ int main(void)
* Try to transfer data about status
*
* http://www.beyondlogic.org/usbnutshell/usb6.shtml
* test_libhid.c
*/
unsigned char blah[8];
libusb_control_transfer(
unsigned char data[WEIGH_REPORT_SIZE];
unsigned int len = libusb_control_transfer(
handle,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS |
LIBUSB_RECIPIENT_INTERFACE,
//bmRequestType => direction: in, type: class,
// recipient: interface
0x01, //bRequest => HID get report
0x0300, //wValue => feature report
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS |
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
blah,
8, //wLength
1000 //timeout => 1 sec
data,
WEIGH_REPORT_SIZE, //wLength
10000 //timeout => 1 sec
);
int i;
for(i = 0; i < 8; i++) {
printf("%x\n", blah[i]);
printf("Got %d bytes from control transfer:\n", len);
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_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.iProduct,
desc.iSerialNumber);
desc.iSerialNumber,
desc.bDeviceClass,
desc.bDeviceSubClass);
/*
* A char buffer to pull string descriptors in from the device