[libhid-discuss] Get feature report - select report ids?

Tim Braun tim.braun at librestream.com
Wed Sep 12 16:52:35 UTC 2007


Here's a patch which changes the API for accessing feature reports to
allow
accessing more than the first feature report.

I have a device which supplies five different feature reports, and this
code
change allows me to access them all.

A couple of questions :

1. How do we feel about adding a parameter to this api call?

2. Why is it necessary to set the report id twice?  After the return
from
   the hid_find_object() call, the ReportID field is reset from that
   which is requested.



Index: include/hid.h
===================================================================
--- include/hid.h	(revision 350)
+++ include/hid.h	(working copy)
@@ -142,7 +142,8 @@
     unsigned int const depth, char const* const buffer, unsigned int
const size);
 
 hid_return hid_get_feature_report(HIDInterface* const hidif, int const
path[],
-    unsigned int const depth, char* const buffer, unsigned int const
size);
+    unsigned int const depth, char* const buffer, unsigned int const
size, 
+	unsigned int report_id);
 
 hid_return hid_set_feature_report(HIDInterface* const hidif, int const
path[],
     unsigned int const depth, char const* const buffer, unsigned int
const size);
Index: src/hid_exchange.c
===================================================================
--- src/hid_exchange.c	(revision 350)
+++ src/hid_exchange.c	(working copy)
@@ -131,9 +131,11 @@
  * @param[in] depth See hid_find_object()
  * @param[out] buffer Result is stored here
  * @param[in] size  How many bytes to fetch
+ * @param[in] report_id  which feature report to get
  */
 hid_return hid_get_feature_report(HIDInterface* const hidif, int const
path[],
-    unsigned int const depth, char* const buffer, unsigned int const
size)
+    unsigned int const depth, char* const buffer, unsigned int const
size,
+	unsigned int report_id)
 {
   ASSERT(hid_is_initialised());
   ASSERT(hid_is_opened(hidif));
@@ -146,11 +148,12 @@
     return HID_RET_DEVICE_NOT_OPENED;
   }
 
-  TRACE("looking up report ID...");
+  TRACE("looking up report ID 0x%02x...", report_id );
   hidif->hid_data->Type = ITEM_FEATURE;
-  hidif->hid_data->ReportID = 0;
+  hidif->hid_data->ReportID = report_id;
 
   hid_find_object(hidif, path, depth);
+  hidif->hid_data->ReportID = report_id;
 
   TRACE("retrieving report ID 0x%02x (length: %d) from USB device
%s...", 
         hidif->hid_data->ReportID, size, hidif->id);


Tim Braun, Sr. Des. Eng.
LibreStream Technologies
200-55 Rothwell Rd, Winnipeg, R3P 2M5  http://www.librestream.com



More information about the libhid-discuss mailing list