Author Topic: Interrupt with generichid c#  (Read 7407 times)

korrea

  • Member
  • ***
  • Posts: 2
Interrupt with generichid c#
« on: June 03, 2011, 04:12:26 am »
Hi all!. First of all, I would like congratulate you for this forum, really nice ;).

I downloaded the generic_hid project for C# and I'm using it. I've got a PIC 18F4550 and I'm comunicating through usb. With your library, it's very simply send and read data.

But this PIC, each 5 ms, send a interrupt to PC for send data (8bytes). How can I capture this interrupt from generic_hid??? Or must I create a thread for read each 5ms???

Thanks !!!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Interrupt with generichid c#
« Reply #1 on: June 03, 2011, 09:40:36 am »
USB interrupt transfers are "interrupt-like" because the host promises a guaranteed maximum latency for requesting or sending data. There is no interrupt for applications to capture.

For IN endpoints, the HID driver requests data according to the bInterval value in the endpoint descriptor. To retrieve received data from the HID driver's buffer, applications can use ReadFile or Filestream methods. There is no way to know in advance is data is available. To read data continuously, use a loop, a timer, or a thread that reads data and notifies the main application when data is available.

If the application can't keep up with the reports, use a bigger read buffer. If multiple reports are available, the read operation will return as many as fit in the buffer.

Jan

 

korrea

  • Member
  • ***
  • Posts: 2
Re: Interrupt with generichid c#
« Reply #2 on: June 09, 2011, 02:40:05 am »
Thank you Jan ;). I created a thread with loop, and work perfect!.