• AVR Freaks

SetReportHandler answer

Author
FFB_Boy
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2011/04/19 22:50:05
  • Location: 0
  • Status: offline
2012/05/30 01:41:03 (permalink)
0

SetReportHandler answer

Hi,
On my application my device receive a SetReport(Feature id:1 len:4)  01-01-00-00
{
Feature Report (ID 1)
ET Constant Force = On    
Byte Count = 0
}
 

 
 I don't know what to answer to this request. I've found it in the HID 1.11 (p.52) but they don't explain what to answer.
 
And I've the same problem with the next packet
GetReport(Feature id:2 len:5) 

 
Any links to help me one more time ...
Thanks
 
 
 

#1

8 Replies Related Threads

    FFB_Boy
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2011/04/19 22:50:05
    • Location: 0
    • Status: offline
    Re:SetReportHandler answer 2012/05/30 02:11:10 (permalink)
    0
    Ok For the Get report it is simple look here http://www.microchip.com/forums/tm.aspx?tree=true&m=652776
    but in this code change
    BYTE bReportType;    // wValue highByte
    BYTE bReportID; // wValue lowByte
    to
    BYTE bReportID;        // wValue lowByte
    BYTE bReportType;    // wValue highByte
     
    in usb_ch9.h

    #2
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:SetReportHandler answer 2012/05/30 07:32:03 (permalink)
    0
    Here is a snippet for Set_Report( Feature ) request process.
     
    Tsuneo
     
     
    usb_config.h
    #define USER_GET_REPORT_HANDLER UserGetReportHandler
    #define USER_SET_REPORT_HANDLER UserSetReportHandler

     
    main.c
     
    enum {
        HID_REPORT_TYPE_INPUT   = 1,
        HID_REPORT_TYPE_OUTPUT  = 2,
        HID_REPORT_TYPE_FEATURE = 3
    };
    void USBHIDCBSetReportComplete(void);  // prototype
    #define HID_ID_FF_CONSTANT_FORCE   1
    #define HID_FEATURE_REPORT_SIZE    4   // report ID + body
    BYTE hid_feature_out[ HID_FEATURE_REPORT_SIZE ];  // buffer to receive a feature report from host
     
    void UserSetReportHandler(void)
    {
        if(SetupPkt.wValue == ((HID_REPORT_TYPE_FEATURE << 8) | HID_ID_FF_CONSTANT_FORCE))
        {
                                           // register buffer and completion callback to the stack
            USBEP0Receive( hid_feature_out, SetupPkt.wLength, USBHIDCBSetReportComplete );
        } 


    void USBHIDCBSetReportComplete(void)
    {
        // Stack fills the buffer (hid_feature_out[]) at Data stage, and it calls this comopletion routine.
        //   hid_feature_out[0]  : Report ID
        //   hid_feature_out[1..]: Report body
        // Process this data, here
    }

    post edited by chinzei - 2012/05/31 07:54:39
    #3
    bytencoder
    Super Member
    • Total Posts : 363
    • Reward points : 0
    • Joined: 2009/06/25 12:30:07
    • Location: 0
    • Status: offline
    Re:SetReportHandler answer 2012/05/30 09:33:51 (permalink)
    0
    - SET_REPORT(Output/Feature) is an Host-ToDevice request, you don't send data you receive data. All you have to do is to "acknowledge" the request (technically send a ZLP packet in the Status stage, but this is probably already handled in your framework, maybe all you have to do is to return a success code or something like that).
    - GET_REPORT(Input/Feature) is a Device-To-Host request where you should return the respective report content (this happens over the control pipe-EP0 ofcourse !).
     
    FFB_Boy
    ...
    my application my device receive a SetReport(Feature id:1 len:4)  01-01-00-00
    I don't know what to answer to this request. I've found it in the HID 1.11 (p.52) but they don't explain what to answer.
    ..... 

    As far as I can tell you are building a HID with PID (force-feedback) device. Did you looked into the PID specifications ?
    www.usb.org/developers/devclass_docs/pid1_01.pdf
     
    #4
    FFB_Boy
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2011/04/19 22:50:05
    • Location: 0
    • Status: offline
    Re:SetReportHandler answer 2012/05/30 12:44:22 (permalink)
    0
    Hi,
    thanks you guys I put the Chinzei code in my project it works but not for all SetReport don't know why !!! (see my log)
    And the error don't came at the same request !!!
    All effect are not validated by ForceTester.
    I've attached my USBLYSER log + ForceTester log
    I think I've forgot something...
    Thanks
    post edited by FFB_Boy - 2012/05/30 13:26:08
    #5
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:SetReportHandler answer 2012/05/31 08:13:27 (permalink)
    0
    On your sniffer log, all of Set_Report( Feature ) successfully finishes.
    Rather, your firmware fails to respond to Get_Report( Feature, ID:2 ) request.
    - Your firmware often STALLs this request.
    - Even when it succeeds, it returns just 3 bytes, instead of 5 bytes, requested by host.
    - This 3 bytes (0D 44 34) doesn't start with specified report ID (ID:2)

    These findings suggest you fails to implement Get_Report() process at all.
    Post your code of Get_Report() process.

    Tsuneo
    post edited by chinzei - 2012/05/31 10:36:17
    #6
    FFB_Boy
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2011/04/19 22:50:05
    • Location: 0
    • Status: offline
    Re:SetReportHandler answer 2012/06/01 12:40:07 (permalink)
    0
    Hi,
    Here is my Get report function  the structure and the descriptor
     
    typedef union _POOL_TYPEDEF
    {
            struct
            {     
     WORD RomBlockCount;
     BYTE PoolMoveReport;
     BYTE undefined_1:1;
     BYTE undefined_2:1;
     BYTE unused:6;
            }Report;
        BYTE val[4];
    } POOL_INFO;
    POOL_INFO Info_Pool;
     
     
    void USBHIDCBGetReportHandler(void)

     if (SetupPkt.bReportType == HID_FEATURE_REPORT) //0x03   
     { 
        switch(SetupPkt.bReportID)
         {
            case JOYSTICK_REPORT_ID://0x01
       // Send in the main loop in main.c
       //USBEP0SendRAMPtr((BYTE*)&Wheel_Input, sizeof(Wheel_Input),USB_EP0_NO_OPTIONS);
         break;
            case PID_REPORT_ID://0x02
       USBEP0SendRAMPtr((BYTE*)&Pid, sizeof(Pid),USB_EP0_NO_OPTIONS);     
     break;
            case POOL_REPORT_ID://0x03
      Info_Pool.Report.RomBlockCount = 0x0000;//0x00FF;
      Info_Pool.Report.RomBlockCount = 0x00;//0x01;
      Info_Pool.Report.undefined_1 = 0x00;
      Info_Pool.Report.undefined_2 = 0x00;
      Info_Pool.Report.unused = 0x00;
      USBEP0SendRAMPtr((BYTE*)&Info_Pool, sizeof(Info_Pool),USB_EP0_NO_OPTIONS);     
     break;
     }
     }
    }
    Thanks
     
    #7
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:SetReportHandler answer 2012/06/02 14:04:06 (permalink)
    0
    Do the arrays (or structures), Wheel_Input[], Pid[] and Info_Pool[], start with their report ID?
    The first byte of feature reports is its report ID, specified by host.
    And then, the report body follows.

    As of PID Block Load Report (ID:2), it's 5 bytes report,
    byte
     0: Report ID = 2, PID Block Load Report
     1: Effect Block Index (1 ~ 255)
     2: Block Load Status, success (1), out of memory (2), error (3)
     3-4: RAM Pool Available

    The sniffer log tells that your code sends back just 3 bytes, instead of 5 bytes.

    I'm not sure, why this code STALL the Get_Report request.
    Some problem lives in elsewhere.
    In USBCBCheckOtherReq() routine, do you have any code other than USBCheckHIDRequest() call?

    OR

    Is Pid array (structure) placed on ROM?

    Tsuneo
    post edited by chinzei - 2012/06/02 14:44:19
    #8
    FFB_Boy
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2011/04/19 22:50:05
    • Location: 0
    • Status: offline
    Re:SetReportHandler answer 2012/06/05 05:21:18 (permalink)
    0
    I've made an error in the structure declaration .
    I've forgot the PID Block Load Report structure and I send instead
    //3 bytes 
    typedef struct
    {     
     BYTE ID;
     BYTE DevicePaused:1;
     BYTE ActuatorsEnabled:1;
     BYTE SafetySwitch:1;
     BYTE Unused:5;
     BYTE Playing:1;
     BYTE BlockIndex:7;
    } PID_INFO;
    that is only 3 bytes that why it stall
    Now it work but sometime there a stall on the ID 2 Report
    I suppose it is because I send wrong value.
    I update all the structure in the main loop like : 
    // 0 : OFF 
     // 1 : ON
     Pid_info.ID = 0X02;
     Pid_info.DevicePaused =0;
     Pid_info.ActuatorsEnabled =1;
     Pid_info.SafetySwitch =0;
     Pid_info.Unused =0;
     Pid_info.Playing =0;
     Pid_info.BlockIndex =0;
     
     Pid_Block_Status.ID = 0x02;
     Pid_Block_Status.EffectIndex = 0x00;
     Pid_Block_Status.LoadStatus = 0x01; //success (1), out of memory (2), error (3) (pid 1.0 page 43)
     Pid_Block_Status.RAMPoolAvailable = 0xFF00;
     
     Info_Pool.ID = 0x03;
     Info_Pool.RomBlockCount = 0x0000;//0x00FF;
     Info_Pool.RomBlockCount = 0x00;//0x01;
     Info_Pool.undefined_1 = 0x00;
     Info_Pool.undefined_2 = 0x00;
     Info_Pool.unused = 0x00;

    In attached file I put the main loop update , my structure declaration and the USBHIDCBGetReportHandler()
    In USBCBCheckOtherReq() I've only USBCheckHIDRequest() call.
    How do you update the data
    How do you use the RAM pool ?
    File.c  
     
    Edit:
    while reading  HID 1.11 I've found that everything is wrong here is th good USBHIDCBGetReportHandler
                 
         switch(SetupPkt.bReportType)
         {
            case HID_INPUT_REPORT://0x01
         break;
            case HID_OUTPUT_REPORT://0x02
     break;
            case HID_FEATURE_REPORT://0x03
          switch(SetupPkt.bReportID)
       {
              case 0x02 :// Report ID 2 : Block Load Status
        USBEP0SendRAMPtr((BYTE*)&Pid_Block_Status, sizeof(Pid_Block_Status),USB_EP0_NO_OPTIONS);     
       break;
              case 0x03:// Report ID 3 : Rom POOL Size    
        USBEP0SendRAMPtr((BYTE*)&Info_Pool,sizeof(Info_Pool),USB_EP0_NO_OPTIONS);     
       break;
       }
     break;
     }
     

      
      
     
    
    post edited by FFB_Boy - 2012/06/06 00:23:06
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5