I'm trying to read the output from a Trimble SPS-361 GPS receiver, which is connected to a Windows 7 machine via USB, using C++ (preferably) or Java. I know people have asked similar questions, but I can't seem to find what I'm looking for. It sounds like libusb is my best bet, is that true? If so, what is a good tutorial/guide/example code?
It sounds like I need to install/write some sort of device-specific driver and then I can read data off the device with C++ through libusb. Is that the general process for reading from a USB or am I confused?
To summarize what I think need (I know I'm all over the place):
Well, if you want the raw data from the device, you can find it in the USB device list and literally read from it like a file.
Start with getting all the devices:
HDEVINFO hDevInfo = SetupDiGetClassDevs( &HIDWatch::GUID_DEVINTERFACE_HID, 0, 0, DIGCF_DEVICEINTERFACE );
Enumerate each one until you find what you're looking for:
SetupDiEnumInterfaceDevice( hDevInfo, NULL, &HIDWatch::GUID_DEVINTERFACE_HID, index++, &InterfaceInfoData )
Get the device detail via SetupDiGetInterfaceDeviceDetail
... then open a file handle to the device path via CreateFile
with GENERIC_READ
access... run an DeviceIoControl
to get the product string using IOCTL_HID_GET_PRODUCT_STRING
. If it's not your device, close up the file CloseHandle
. If it is yours, sit in a loop (preferably on a thread) doing a ReadFile
and you'll get raw records from the device.
That should get you going...