• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

More to one USB HID devices.

Started by Ferdie, August 16, 2009, 07:22:12 pm

Previous topic - Next topic

Ferdie

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

Hello

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


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

August 18, 2009, 11:59:44 am #2 Last Edit: August 20, 2009, 03:07:13 pm by hid1
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.

      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?

Roman Novgorodov

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.