AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein IsCheckedOut in der JvHidControllerClass
Thema durchsuchen
Ansicht
Themen-Optionen

IsCheckedOut in der JvHidControllerClass

Ein Thema von schwa226 · begonnen am 20. Dez 2011 · letzter Beitrag vom 24. Dez 2011
Antwort Antwort
schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#1

IsCheckedOut in der JvHidControllerClass

  Alt 20. Dez 2011, 17:09
Hallo!

Da ich nicht weiterkomme muss ich hier mal nachfragen!

Ich arbeite mit einem HID USB Device.
In der OnArrival Methode vom JvHidDeviceController kommt nun beim Starten eins nach dem anderen Device rein.
Wenn nun meins dabei ist mache ich ein Checkout des Devices.

Delphi-Quellcode:
procedure TMainForm.OnArrival(HidDev: TJvHidDevice);
var
  i : integer;
begin
  if ((HidDev.Attributes.VendorID = VendorID) AND
    (HidDev.Attributes.ProductID = ProductID) AND
    (HidDev.ProductName = ProductName )) then
  begin

    //store device:
    HIDDevice := HidDev;
    //device found, lets do the init:
    if HIDDevice.CheckOut then
      begin
        //set feature type
        HIDDevice.ReportTypeParam := HidP_Feature;
        HIDDevice.UsagePageParam := HID_USAGE_PAGE_GENERIC;
        HIDDevice.LinkCollectionParam := $01; // CollectionType=Application
        HIDDevice.UsageParam := HID_USAGE_CONSUMER_UNDEFINED;
      end;
  end;
end;
Starte ich nun ein zweites mal meine Anwendung wird wieder ein Checkout ohne Probleme durchgeführt und das Device ist von beiden Anwendungen in Verwendung.

Das Problem ist jetzt, wenn ich zwei gleiche USB Devices angeschlossen haben werden beide geöffnet.
Das IsCheckedOut gilt nur für das eine Programm. Wie kann ich aber das Device als "belegt" markieren, damit die zweite Anwendung es nicht auch noch öffnet?
Delphi 2010, Update 4 & 5
  Mit Zitat antworten Zitat
DonAlfredo

Registriert seit: 13. Mai 2010
19 Beiträge
 
#2

AW: IsCheckedOut in der JvHidControllerClass

  Alt 21. Dez 2011, 12:44
I hope you can read English ... my German writing is very bad ... !!

I have had the same problem.
An application with more than 10 identical USB-devices.

Normally, you could use the serial number of a device, but sometimes these are all similar.

I used the loaction of a device, on arrival.
Each USB device has a unique location: hub, port.

With this location, you can very reliable distinguish between devices !!
Two devices will NEVER have the same location.

Registry-entry: "SYSTEM\CurrentControlSet\Enum\USB\" ; LocationInformation.

You will need some extra code to use this method.

Good luck, Alfred.
Alfred
  Mit Zitat antworten Zitat
schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#3

AW: IsCheckedOut in der JvHidControllerClass

  Alt 23. Dez 2011, 08:14
Thx for this tipp.

I also was testing it to identify the device by the serial number.
But I have a self programed AVR V-USB device. So I need to have different firmwares for different serial numbers.

The idea to take a look to the hub/port where the device is connected sounds good.

But anyway I will need to rewrite a lot of code because than I will need a list where I store the data of the device. Now I have only a single HIDDevice. I f the same device is getting plugged in the HIDDevice will be overwritten...
Delphi 2010, Update 4 & 5
  Mit Zitat antworten Zitat
DonAlfredo

Registriert seit: 13. Mai 2010
19 Beiträge
 
#4

AW: IsCheckedOut in der JvHidControllerClass

  Alt 24. Dez 2011, 06:51
Well,

If you write your own firmware, this makes life easier.

I would advice against a different USB-serial.
This would mean special firmware for each device.
Which will be hard to maintain.

My suggestion:

Make use of a flag inside your USB-device.
Mark the device as being in use after arrival and checkout.
On arrival, check the in-use-flag of the device.
If in use, then skip (checkin), and go to the next one.



About your (correct) remark about the hub/port usage:
I maintain a list of devices inside the registry.
This list is checked on every device-arrival.
Alfred
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz