>>>We have a software that accesses the diabetes glucose meters via a serial port.
>>>Now they are introducing a new meter that has a USB connection. The way to access the meters needs to be done enumerating the USB devices and recognizing the meter by its device ID.
>>>
>>>I looked around for code that does the enumeration, but nothing that can simply be used in a VFP application.
>>>
>>>I wonder if there is an API or another third party interface that I could use in VFP?
>>
>>If it is just the device id that you need, maybe something like this can give you a starting point:
>>
>>
>>clear
>>loLocator = CREATEOBJECT('WBEMScripting.SWBEMLocator')
>>loWMI = loLocator.ConnectServer()
>>loDevices = loWMI.ExecQuery('Select * from Win32_USBControllerDevice')
>>
>>for each loDevice in loDevices
>> try
>> loDependent = GETOBJECT("winmgmts:" + loDevice.Dependent)
>> ? loDependent.Status, 'DeviceID: ', loDependent.DeviceID, 'Description: ', loDependent.Description, loDependent.Name
>> catch to loException
>> ? 'Exception: ', loException.Message
>> endtry
>>endfor
>>
>
>I think I need the device ID to be able to communicate with the device. Now I already got the device ID, or instance handle, now the challenge is that I need to send a string like "$time?[EOL]" to the device and supposedly I need to get a return value. Similar like we did with the serial port, but then we used an active X control to do that, so it was much easier to implement.
USB supports many device types - hard drives, flash sticks, printers, keyboards, mice... You don't talk to a generic USB device, you now need to know the specific protocol the device expects.
By far the easiest way to do that would be via an updated ActiveX control for the new generation of your devices. In a perfect world that would take care of finding the device(s) for you, establishing communication and requests/responses. Hopefully the device manufacturer can provide that for you, otherwise you may need to roll your own protocol stack.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up