Author Topic: More to one USB HID devices.  (Read 2483 times)

Ferdie

  • Newbie
  • *
  • Posts: 2
    • View Profile
More to one USB HID devices.
« on: August 16, 2009, 10:22:12 pm »
Hello, I am Manuel from Opencockpits.

We have purchased your product for use with our HID devices (in this moment we use Jedi libraries).

Now i prepare one unit for replace our software with the nrcommLib.

But, the first problem appear when more to one devices should to be managed.

With your example only one HID device can receive data in the same time.

In the first test program, when i active more to one HID Devices, only one receive data from AfterReceive event. ¿?

Can you give me one solution for use many HID devices in the same time ?

Regards, Manuel.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: More to one USB HID devices.
« Reply #1 on: August 18, 2009, 01:40:40 am »
Hello

You need to create a one instance of TnrHid component per every reading device.
Code can be something like this:

Code: [Select]
for i := 0 to deviceCount do begin
    hidDev := TnrHid.Create(Self);
    hidDev.Update;
    hidDev.DeviceIndex := i; // i is changing from 0 to device count
    hidDev.OnAfterReceive := nrHid1AfterReceive; // attach handler
    hidDev.Active := True; // open device
end;

Our other product (HIDPlugin for winamp and WMP) works with defferent HID devices at same time.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

hid1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: More to one USB HID devices.
« Reply #2 on: August 18, 2009, 02:59:44 pm »
Hello Roman ,

2 HID devices connected to PC. Same device, same serial , same manufacturer etc. but connected  2different USB ports.

HidFind(nrhid component) periodically search for new devices attached. or removed. then nrhid1..nrhid2, will be active for each device.

But sometimes manufacturer name cannot  returned.  

This code below, for finding devices. We have to be sure, this is our company's device or not.

Code: [Select]
      i:=0;
        myHidcount:=0;
       HidFind.Update;
        memodebug.Clear;
        repeat
          if HidFind.Device[i].NameFriendly = my_device_name then begin
            myHidcount :=myHidcount+1;
              if HidFind.Device[i].Manufacturer=my_company_name then
                   memodebug.Lines.Add('ok');

          end;

          i:=i+1;
        until i= HidFind.DeviceCount;

2 device connected to pc. IF a button pressed, this code finds our devices.
But sometimes 2 'OK' added for memodebug lines. but sometimes only 1 'OK' added.

HidFind.Device.NameFriendly detected for each time. but HidFind.Device.Manufacturer not.

nrUSB detects, devices descriptors manufacturer, strings etc.  but nrhid component  not detect Manufacturer for every time.  unfortunately nrUSB and Pipes cannot be used for my application. Becouse of "unknow driver" error occured.  
nrUSB component Cannot be used for HID devices?
« Last Edit: August 20, 2009, 06:07:13 pm by hid1 »

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: More to one USB HID devices.
« Reply #3 on: August 20, 2009, 06:38:43 pm »
Hello

Usual we are using VendorID and ProductID for identify needed device.

Manufacturer can be empty because something wrong was with usb descriptor request during device initialization.
You can try to add time delay before search devices.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.