hot to get out reports.

10 views
Skip to first unread message

ulao

unread,
Sep 14, 2021, 1:54:49 PM9/14/21
to LUFA Library Support List

Not finding much on this but I have something working with strange results.

some examples are
actual data sniffed a,1,1,1 but data seen a,1,3,0
actual data sniffed 5,1,ff,0  but data seen 5,1,ff,0 
actual data sniffed 2,1,ff, ff   never seen
actual data sniffed 1,1,15,0  never seen

I think maybe I need a wait loop, but unsure how that works.

void HID_Task(void)//Function to manage HID report generation and transmission to the host.  
{
    //Device must be connected and configured for the task to run
    if (USB_DeviceState != DEVICE_STATE_Configured)
      return;
 
        Endpoint_SelectEndpoint(EPNUM2);
        if (Endpoint_IsOUTReceived())//we received something on the OUT endpoint.
        {
            if (Endpoint_IsReadWriteAllowed())//  packet has data, react to it.
            {       
                uint8_t GenericData[64];    // temporary buffer
                uint8_t out_wait_report_bytes = 0;
                Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData), NULL);// Read in to buffer
                FfbProcessor(OutReportSize[ GenericData[0] -1 ], &GenericData);
            }
            Endpoint_ClearOUT();//acknowledge an OUT packet on this endpoint.
        }
  
}

ulao

unread,
Sep 14, 2021, 9:07:15 PM9/14/21
to LUFA Library Support List
tried to do it like this but also not having much luck, data seems to be wrong still.

Endpoint_SelectEndpoint(EPNUM2); //ffb

    
    if ( Endpoint_IsOUTReceived() ) //  packet has data
    {

        GenericData[dataElement]  = FetchNextByte();   
        if (dataElement==0) { memset(GenericData + 1,0,OutReportSize[ GenericData[0] -1 ]); dataElement++; return; }//report data is ready   
        if ( dataElement == OutReportSize[ GenericData[0] -1 ]  )
        {

            FfbProcessor(GenericData, OutReportSize[ GenericData[0] -1 ]);
            dataElement=0;
        } else    dataElement++;
    }

uint8_t FetchNextByte(void)
{
    uint8_t byteToReturn;
    byteToReturn = Endpoint_Read_8();//Fetch the next byte from the OUT endpoint    
    Endpoint_ClearOUT();
    return byteToReturn;
}
 

ulao

unread,
Sep 15, 2021, 10:24:58 AM9/15/21
to LUFA Library Support List
getting very close here this version gets all the data accept one report that seems to have the wrong data in it? Is getting one byte at a time the best way to do this? I'm not sure why the one report is wrong when all other are correct but it is the last report in the sent data.


if ( Endpoint_IsOUTReceived() ) //  packet has data
    {

        if (  Endpoint_BytesInEndpoint() )
        {
            if (dataSize == 0)
            {
                GenericData[0] =  Endpoint_Read_8(); //report
                dataSize = Endpoint_BytesInEndpoint(); //save size
                memset(GenericData + 1,0,dataSize);//set memory
            }

            GenericData[dataSize - Endpoint_BytesInEndpoint() + 1]  = Endpoint_Read_8();
               
            if ( Endpoint_BytesInEndpoint() == 1 )

            {
                FfbProcessor(GenericData, OutReportSize[ GenericData[0] -1 ]);
            }            
        } else { Endpoint_ClearOUT(); dataSize=0; }
    }

ulao

unread,
Sep 15, 2021, 10:50:15 AM9/15/21
to LUFA Library Support List
false alarm this method does work.
Reply all
Reply to author
Forward
0 new messages