 |
|
 |
There is no real explaination to what is going on. The code is poorly documented and not at all in some places. This would be less important if it would actually work out of the proverbial "box".
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
FYI, I just found this out. In Win32Usb, the call to SetupDiEnumDeviceInterfaces is returning false. Of course, that's probably why it's called Win32Usb, not Win64Usb. 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I just figured it out. I added the source from this link to determine the # of bits for the OS: http://www.csharp411.com/determine-windows-version-and-edition-with-c/[^]
I changed the DeviceInterfaceData Reserved member datatype from an int to an Intptr:
[StructLayout(LayoutKind.Sequential, Pack = 1)] protected struct DeviceInterfaceData { public int Size; public Guid InterfaceClassGuid; public int Flags; public IntPtr Reserved; }
Then I added the following code to HIDDevice.GetDevicePath:
DeviceInterfaceDetailData oDetail = new DeviceInterfaceDetailData(); if (OSInfo.Bits == 64) { oDetail.Size = 8; // 64 bit OSes need this } else { oDetail.Size = 5; // hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to the struct sizeof failed miserably. If you manage to sort it, mail me! Thx }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have been working on reading a USB card swipe for about 3 days now, with not much luck. Your sample here is easy to use and works great! Thanks!
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi!
When the CloseHandle in the HIDDevice.Dispose function is called on my Vista computer the Async Callback is called and the handle is released. But when the same code is running on my Windows XP SP3 computer the Async Callback is not called and the handle is not released. This makes it imposible to open a new handle to the HID device unless it's first disconnected and then reconnected to the computer, or when I'm debugging I have to restart the app. I've tried to compile with .NET 2.0, 3.0, 3.5, it makes no difference.
The ErrorCode from Marshal.GetLastWin32Error is 0x3e5 after the CloseHandle on both Vista and my XP. When I try to open a new handle on Vista that is success (ErorCode 0x00) but on my WinXP I get ErrorCode 0x20.
Please help me!
Regards Henrik Danielsson
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello!
Can you give me advise how to code an USB HID access for windows mobile 5.0? I can not port your code as the dllimports (hid.dll, setupapi.dll) are missing in WM5, CF3.5.
Any ideas?
Regards, MIRKO
|
| Sign In·View Thread·PermaLink | 2.50/5 (2 votes) |
|
|
|
 |
|
 |
FYI. Probably available via CVS or whatever SF uses, but it would be great if the source was available in tar/zip as well as the DLLs.
Regards, -Mike
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi all. I have a smiple question. How do I specify endpoint number when sending data (SpecifiedDevice.SendData method)? More thorough explanation would be greatly appreciated.
Thanks in advance, Radovan.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
To Wimar, I am looking for a developer to help us develop an larger application using HID proximity cards and USB. How can I contact Wimar_ My email is duharth@gmail.com. Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
When receiving data, does anybody know what the first byte is for? It seems to always be 0, even though the data is coming from Endpoint 1. I would think it is the EndPoint Address, but that doesn't seem to be correct. How does the code differentiate which endpoint the data is coming from?
public class SpecifiedOutputReport : OutputReport { public SpecifiedOutputReport(HIDDevice oDev) : base(oDev) { }
public bool SendData(byte[] data) { byte[] arrBuff = Buffer; /* Is arrBuff[0] the endpoint */ for (int i = 1; i < arrBuff.Length; i++) { arrBuff[i] = data[i]; }
I noticed the code is similar to "Making C# USB Friendly", in that they seem to skip the first two bytes, instead of just 1.
public void SetLightStates(bool bLight1, bool bLight2, bool bLight3, bool bLight4) { byte[] arrBuff = Buffer; arrBuff[2] = (byte)(bLight1 ? 0xff : 0); arrBuff[3] = (byte)(bLight2 ? 0xff : 0); arrBuff[4] = (byte)(bLight3 ? 0xff : 0); // arrBuff[5] = (byte)(bLight4 ? 0xff : 0); }
TIA,
modified on Wednesday, March 18, 2009 12:31 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Well, In case anybody is wondering... I guess the first byte is always 0.
In order to communicate with different endpoints, I would have to specify an end point, or have multiple read threads, because it stops at the first found endpoint. I will probably end up implementing multiple read/write threads.
public static HIDDevice FindDevice(int nVid, int nPid, Type oType) {
int nIndex = 0; while (SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface)) // this gets the device interface information for a device at index 'nIndex' in the memory block { string strDevicePath = GetDevicePath(hInfoSet, ref oInterface); // get the device path (see helper method 'GetDevicePath') if (strDevicePath.IndexOf(strSearch) >= 0) // do a string search, if we find the VID/PID string then we found our device! { HIDDevice oNewDevice = (HIDDevice)Activator.CreateInstance(oType); // create an instance of the class for this device oNewDevice.Initialise(strDevicePath); // initialise it with the device path return oNewDevice; // and return it } nIndex++; // if we get here, we didn't find our device. So move on to the next one. }
This is the first Device Path/end point that it finds "\\\\?\\hid#vid_1043&pid_0000&mi_00#7&c5387b6&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
This is the 2nd Device Path/endpoint "\\\\?\\hid#vid_1043&pid_0000&mi_01#7&241713fb&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
About "mi_XY" from USB device path...it is related to USB device interface, specially on composite devices. So, - "mi_00" is interface 0 of composite USB device with VID 1043 and PID 0000 - "mi_01" is interface 1 of composite USB device with VID 1043 and PID 0000 USB device endpoints should be transparent to application level...in most of cases you cannot write data to specific endpoint.
Regards, Dan Berteanu
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm new to VS & c#. I changed the Vid & Pid for my device and the .exe works very well when I launch it from explorer. I get the event messages when I plug and unplug my device. *** When I try to run it within VS, however, I get: ArgumentException was unhandled" Assembly 'C:\Projects\Brain_Planes\USB_Radio\CodeProject_C#%5CUsbLibrary%5Cobj%5CDebug%5CUsbLibrary.dll' could not be found. Ensure the path is correct"
The file USbLibrary.dll IS at: C:\Projects\Brain_Planes\USB_Radio\CodeProject_C#\UsbLibrary\obj\Debug
So what is going on? (sorry if this is a dumb question :(
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
 |
I have a printer connecting with USB.
I tried to send data and print it.
but the sniffer didn't find my print device.
Is it impossible to send data and print?
modified on Monday, March 9, 2009 12:51 AM
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
No. Because usb printer is not a human interface device(HID)and use it's own driver.So this lib can't find it. 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello all, Thank you Wimar for this nice project.
Is it possible to get connected device VID/PID and display in the lb_message listbox?
Regards, B.Armagan
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
 |
I'm using Magtek, a magnetic stripe reader. I can read from it, but to write to it I think I need to use Feature Reports. Anyone knows how to do this?
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
Dear wimar,
Is it possible to capture with your SDK two HID keyboard mode barcode scanners data before it enters into the keyboard buffer? We like to crank up something that supports multiple HID keyboard barcode scanners but right now the data is mingled together. Do you have a solution for that?
Kind Regards, Gert
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
 |
Hello,
I would like to know how to remove a listed device without closing the program ? Actually, I have to close the application in order to relase the device.
Best regards, Clément.
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
just unplug it  or, If you have any other hid connected change followings to a valid value this.usb.ProductId this.usb.VendorId
and call this.usb.CheckDevicePresent(); again.
This is the easiest way I could find.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I am trying to send 4 bytes of data to my usb hid device. But when I am trying to send, this program gives an out of bound error.
in the file SpecifiedOutputReport ,
line16 for (int i = 0; i < arrBuff.Length; i++) { arrBuff[i] = data[i];
}
arrBuff array is 9bytes long and data array is only 4 bytes.
How can I fix this error? Thanks in advanced.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Hi all,
I've problems using this library to receive data from my HID device (an Oregon Scientific WMR100 weather station).
I think I made all steps correctly: I create an UsbHidPort object, I initialized the correct Product and Vendor Id, I specified a new DataRecieveHandler, I called the CheckDevicePresent method and I finally sent some data to the device to initialize it, all without any exception, but... my DataRecieveHandler is never called!
I'm sure the object is sending back data and I'm sure the data I send to initialize the device is correct.
Any idea?
Thanks in advance...
modified on Tuesday, December 30, 2008 7:03 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Did you get here from this page[^]? If not, check out the link to the C# project. I've found that the project has some problems but it should get you started.
|
| Sign In·View Thread·PermaLink | 2.00/5 (3 votes) |
|
|
|
 |
|
 |
Your article states: "A mouse is always in use by Windows, and cannot be captured by your own application"
Does this apply to a keyboard also?
I was hoping to control one of the leds on an extra USB keyboard so that I could switch on/off an external device. May have to toggle the Scroll-Lock led instead by other means.
Regards
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |