Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using getReport with a HID device...



Hi Charles,

The reportID in getReport refers to the report ID associated with the particular feature report you are trying obtain.  This corresponds in the first byte of the report if there are more than one reports associated with the device.  Since your example is modifying the first byte, it's safe to say that there are not multiple reports defined by the device.  In this case, just use 0 for the reportID.

The reportID information should be detailed in the report descriptor for the device.  To view the descriptor on X, use the USB Prober application located in /Developer/Applications/Utilities/.

- Rob

On Apr 13, 2005, at 12:32 PM, Charles Reader wrote:

I've been looking around for a way to get data from my device. I got some code from a PC guy who'd written a test program in XP and he did used the following calls...

    if (DeviceDetected==TRUE)
    {

        // Set the report buffers so that there are enough of them to
        // get all the data.  We have 256x64byte packets which will be
        // sent back over EP2 IN in interrupt transfers.
        HidD_SetNumInputBuffers
                (DeviceHandle,
                256);

        // Set report allows us to configure the device
        // Configuration bits, Byte0:
        // bit<7:6>        '10' = BIST, '01' = NORMAL Operation
        // bit<5:0>        reserved for future use
        // Configuration bits, Byte1:
        // bit<7>        1=IMPERIAL, 0=METRIC
        // bit<6:0>        reserved for future use
        Result = HidD_SetFeature
            (DeviceHandle,
            WriteBuffer,
            Capabilities.FeatureReportByteLength);

        //Get a report from the device.
        //This will trigger the device to begin streaming the 16K EEPROM
        //data back to the host.
        Result = HidD_GetFeature
            (DeviceHandle,
            ReadBuffer,
            Capabilities.FeatureReportByteLength);

        //Read reports from the device until all data is captured.
        ReadReport();
    } 

and

void CUsbhidiocDlg::ReadReport()
{
    CString    ByteToDisplay = "";
    CString    MessageToDisplay = "";
    DWORD    Result;
    char InputReportTemp[65];
    char    j;
    UINT    i;

    //Read a report from the device.

     

    /*API call:ReadFile
    'Returns: the report in InputReport.
    'Requires: a device handle returned by CreateFile
    '(for overlapped I/O, CreateFile must be called with FILE_FLAG_OVERLAPPED),
    'the Input report length in bytes returned by HidP_GetCaps,
    'and an overlapped structure whose hEvent member is set to an event object.
    */

    for(i=0;i<256;i++) {
        Result = ReadFile 
            (ReadHandle, 
            InputReportTemp, 
            Capabilities.InputReportByteLength, 
            &NumberOfBytesRead,
            (LPOVERLAPPED) &HIDOverlapped); 


I poked around in the HID programming information and found this routine


Obtains a report from the device. 
Availability: Mac OS X version 10.2.3 and later. 



IOReturn (*getReport) (
    void * self, 
    IOHIDReportType reportType, 
    UInt32 reportID, 
    void * reportBuffer, 
    UInt32 * reportBufferSize, 
    UInt32 timeoutMS, 
    IOHIDReportCallbackFunction callback, 
    void * callbackTarget, 
    void * callbackRefcon); 

Parameter Descriptions
reportType
The report type.
reportID
The report ID.
reportBuffer
Pointer to a preallocated buffer.
reportBufferSize
Size of the reportBuffer in bytes. When finished, will contain the actual size of the report.
timeoutMS
callback
If null, this method will behave synchronously.
callbackTarget
The callback target passed to the callback.
callbackRefcon
The callback refcon passed to the callback.
function result
Returns an IOReturn code.

Most of this stuff I can figure out but I'm not sure what the Report ID is in this context. Am I even on the right track? _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden

References: 
 >Using getReport with a HID device... (From: Charles Reader <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.