PORTS Forum
Ports and Interfaces => USB => Topic started by: kberisso on December 28, 2011, 11:59:54 am
-
Dear Jan,
Good morning. I am working with a USB HID RFID reader (radio frequency id) and am having a bit of trouble. I have your book (USB Complete 4th ed) and have tried downloading the code from the website, but even the basic demo app seems to crash on a regular basis. I have been looking into other solutions and just can’t seem to get things licked.
First off, I should warn you I am not the best of programmers. However, having said that, I can usually figure things out with a bit of specific help/direction. The problems I seem to have with the demo on your web page is that the app keeps dying during the report exchange. I also get errors in the WndProc override.
Using the LibUsbDotNet tools, I get the following info about my device. As you will see, it is a fairly basic device and the software I am working on is specific for this hardware, so I don’t necessarily need to “learn” about the device – I can hard code much of the info such as report sizes. As a result, I have tried to comment out the sections that get the report sizes - still no luck.
Standard system devices) - USB Input Device OSVersion:Microsoft Windows NT 6.1.7601 Service Pack 1 LibUsbDotNet Version:2.2.8.104 DriverMode:LibUsb
Length:18
DescriptorType:Device
BcdUsb:0x0110
Class:PerInterface
SubClass:0x00
Protocol:0x00
MaxPacketSize0:64
VendorID:0x1325
ProductID:0xC029
BcdDevice:0x0000
ManufacturerStringIndex:1
ProductStringIndex:2
SerialStringIndex:0
ConfigurationCount:1
ManufacturerString:MTI
ProductString:RU-888
SerialString:
CONFIG #1
Length:9
DescriptorType:Configuration
TotalLength:41
InterfaceCount:1
ConfigID:1
StringIndex:0
Attributes:0x80
MaxPower:250
ConfigString:
INTERFACE (0,0)
Length:9
DescriptorType:Interface
InterfaceID:0
AlternateID:0
EndpointCount:2
Class:Hid
SubClass:0x00
Protocol:0x00
StringIndex:0
InterfaceString:
ENDPOINT 0x81
Length:7
DescriptorType:Endpoint
EndpointID:0x81
Attributes:0x03
MaxPacketSize:64
Interval:10
Refresh:0
SynchAddress:0x00
ENDPOINT 0x02
Length:7
DescriptorType:Endpoint
EndpointID:0x02
Attributes:0x03
MaxPacketSize:64
Interval:10
Refresh:0
SynchAddress:0x00
I am developing on a Win7, 64bit machine with c#.
Thanks
Kevin
-
See:
http://www.lvr.com/forum/index.php?topic=696.0
What line of code is causing an error and what is the error? Use breakpoints and single-stepping if needed to isolate the problem.
Jan
-
OK. I have updated things per the referenced post and here is what is happing:
When I run the software without break points, it will get as far as trying to register for notifications in the FindTheHid routine. When it dies, I get the following as the last message in the debugger.
"The OS is more recent than Windows 98 Gold.The program '[6816] GenericHid.vshost.exe: Managed (v2.0.50727)' has exited with code -1073740940 (0xc0000374)."
If, however, I manually step through the remainder of the code beyond the "if(myDeviceDetected)" line, then all is ok. I tried putting in some 20ms sleep statements, but that didn't seem to matter... :'(
Thanks
Kevin
-
So if you comment out registering for device notifications, the application works (except for notifications)?
What line of code causes the error?
Jan
-
Ok. Here is what I have found after some more testing. It seems that
"MyHid.Capabilities = MyHid.GetDeviceCapabilities(hidHandle);"
is causing the problems... For some reason if I comment this out and manually add in the capability values then I am in good shape. If I step through GetDeviceCapabilities, all is ok - no problems. However, whenever I let the software run through on it's own, I am back at the
"The program '[4776] GenericHid.vshost.exe: Managed (v2.0.50727)' has exited with code -1073740940 (0xc0000374) " error.
So my two questions at this point are:
1) do you have any ideas on what might be causing the problem. Because of what I am doing, I can cheat and hardcode all of the capabilities in.
2) Can you think of any where that not using the GetDeviceCapabilities might cause problems?
Thanks
Kevin
-
Retrieving the device capabilities is optional. A host that knows what to do with the report data doesn't have to ask for the capabilities.
I don't know why you're seeing the error.
To isolate the problem further, you could put a breakpoint halfway through the routine that is crashing the program.
If the program crashes, move the breakpoint 1/4 of the way in the routine and retest.
If the program reaches the breakpoint without crashing, move the breakpoint 3/4 of the way through the routine and retest.
Continue until you find the problem line.
Jan