Author Topic: Device Notify Host App  (Read 23613 times)

Babu

  • Member
  • ***
  • Posts: 11
Re: Device Notify Host App
« Reply #15 on: April 02, 2015, 12:52:36 pm »
How can i check whether the device supports Get Report?

Babu

  • Member
  • ***
  • Posts: 11
Re: Device Notify Host App
« Reply #16 on: April 02, 2015, 01:03:17 pm »
My firmware and host code looks something like this: [ I have not copied the complete code ]



//*******************************************************************************************************
//               DEVICE CODE
//*******************************************************************************************************

unsigned char ReceivedDataBuffer[64];
unsigned char ToSendDataBuffer[64];


// Main program entry point
void main(void)
{   

    initialisePic();

   // If we are running in interrupt mode attempt to attach the USB device
    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif
   

   
    //ON the LED
    mStatusLED0_on();
   


    while(1)
    {
        #if defined(USB_POLLING)
         // If we are in polling mode the USB device tasks must be processed here
         // (otherwise the interrupt is performing this task)
           USBDeviceTasks();
        #endif
       
       // Process USB Commands
        processUsbCommands(); 
       
        // Note: Other application specific actions can be placed here     
    }
}

void processUsbCommands(void)
{   


    if(!HIDRxHandleBusy(USBOutHandle))
    {   
           
             switch(ReceivedDataBuffer[0])
             {
           // Toggle the LED   
               case 0x80:
 
            // Toggle the LED0
            mStatusLED0_Toggle();
               break;
           
           // Read the push switch status
               case 0x81:
            ToSendDataBuffer[0] = sw0;

            // Transmit the response to the host
                      if(!HIDTxHandleBusy(USBInHandle))
            {
               USBInHandle = HIDTxPacket(HID_EP,(BYTE*)&ToSendDataBuffer[0],64);
            }
               break;
       }
    }
}


//*******************************************************************************************************
//               HOST CODE
//*******************************************************************************************************

void CHID_Window_NewDlg::UpdateSwitchState()
{
   //Read the data from the device.
   //First send the command to the control end point
   BYTE commandBuffer[65];

   //First byte should be 0.It is reserved for windows
   commandBuffer[0] = 0;

   //Second byte should be the command id which reads the LED status
   commandBuffer[1] = 0x81;

   //Write this command to the control end point
   WriteData(commandBuffer);

   //Now read the status in the input buffer
   BYTE* pbInBuffer = NULL;

   //Read the data from the device
   BOOL bResult = ReadData( pbInBuffer );

   //First byte contains the state of the LED
   if( pbInBuffer[1] )
   {
      m_butSwitchState.SetBitmap(m_bmpON);
   }
   else
   {
      m_butSwitchState.SetBitmap(m_bmpOFF);
   }
}

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device Notify Host App
« Reply #17 on: April 02, 2015, 03:29:46 pm »
In your original question, you said:

I can continuously poll for the state of the device using HID_GetInputReport.

if that works, your device supports sending reports using control transfers.

You also mentioned using raw input, and that uses reports transferred using interrupt transfers.

Babu

  • Member
  • ***
  • Posts: 11
Re: Device Notify Host App
« Reply #18 on: April 02, 2015, 04:28:36 pm »
Sorry about that.
It was a different code I tried.
Now the code what I have shown you is the firmware code I use..

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device Notify Host App
« Reply #19 on: April 02, 2015, 04:46:21 pm »
If you can get reports using ReadFile, your device supports sending reports using interrupt transfers.