I should have posted this very minor update a while back, but here it is now.
This is version 2.4 and it has one significant change with a few minor changes:
- Added Name(Dev) property.
- Added range check on the IsOpen(Dev) property.
- Added a few comments and corrected some typos.
The significant change is the first one, which lets the client program retrieve the "names" of the devices found. This can be useful for programs that need to service multiple sensors since their sequence in the list cannot be guaranteed from run to run.
To make a long story short, I've confirmed my class can handle multiple devices properly.
The Long Story
Right now the class can handle TEMPer1 and TEMPer Gold devices but these look identical in terms of USB product and vendor codes, etc. Even the firmware version string can be identical!
In fact the only way they vary sems to be by where they are plugged into the PC. So these USB device names cannot absolutely tell you which is which. If you have two devices and swap them later your program will never "know" it. Examples:
Code:
\\?\hid#vid_0c45&pid_7401&mi_01#7&8fe1afd&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
\\?\hid#vid_0c45&pid_7401&mi_01#7&1602e383&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
This isn't as bad as it sounds though. Your program can map these names to a shorthand or descriptive name and the association should "stick" until you move devices around.
How I Handle Mappings
For example in one of my data logger programs I use an INI file to hold the mappings:
Code:
[Devices]
\\?\hid#vid_0c45&pid_7401&mi_01#7&8fe1afd&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}=
\\?\hid#vid_0c45&pid_7401&mi_01#7&1602e383&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}=
[\\?\hid#vid_0c45&pid_7401&mi_01#7&8fe1afd&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}]
SourceNameT1=Freezer1
RecordT1=True
SourceNameT2=RED7#9762T2
RecordT2=False
SourceNameH=RED7#9762H
RecordH=False
[\\?\hid#vid_0c45&pid_7401&mi_01#7&1602e383&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}]
SourceNameT1=Freezer2
RecordT1=True
SourceNameT2=RED7#3487T2
RecordT2=False
SourceNameH=RED7#3487H
RecordH=False
Here the T1 items are the TEMPer Gold's single temperature measurement. The T2 and H items reflect possible future support for dual-sensor TEMPer devices that have either a 2nd temperature sensor or a humidity sensor.
The SourceNameXX items in the INI file are manually configured once, after I do an initial run of my logger to scan for devices and build the INI file. Then I edit the file to set the individual sensor names I want and turn on recording for each.
The RED7#9999XX type names are random unique names the INI builder inserts (RED7 here being the computer name). "Freezer1" and "Freezer2" are what I renamed the two active sensors my two TEMPer units have. Those names are carried in my data logs and can be used as charting curve series labels, etc.