|
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
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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;
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);
}
TIA,
modified on Wednesday, March 18, 2009 12:31 PM
|
|
|
|
|
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))
{
string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);
if (strDevicePath.IndexOf(strSearch) >= 0)
{
HIDDevice oNewDevice = (HIDDevice)Activator.CreateInstance(oType);
oNewDevice.Initialise(strDevicePath);
return oNewDevice;
}
nIndex++;
}
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}"
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
No.
Because usb printer is not a human interface device(HID)and use it's own driver.So this lib can't find it.
|
|
|
|
|
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
|
|
|
|
|
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?
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
You should limit the iteration variable to the data length as it's shorter.
And btw, there's an Array.Copy[^] method for this kind of stuff.
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
I see you have used the sample for a special Barcode Scanner.
I'm trying to get data which I scan with the USB barcode scanner Symbol Technologies LS2208'.
Following error occurs during the Inialize Method of the HDIDevice Class:
UsbLibrary.HIDDeviceException: Msg:UsbLibrary.HIDDeviceException: Msg:Failed to create device file WinEr:00000005
at UsbLibrary.HIDDevice.Initialise(String strPath) in HIDDevice.cs:line 136
at UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) in HIDDevice.cs:line 287
at UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) in HIDDevice.cs:line 295
at UsbLibrary.SpecifiedDevice.FindSpecifiedDevice(Int32 vendor_id, Int32 product_id) in SpecifiedDevice.cs:line 42
at UsbLibrary.UsbHidPort.CheckDevicePresent() in UsbHidPort.cs:line 218
The Windows Error Code 5 is 'Access Denied' during Method CreateFile.
I tried your sample application on Windows XP (32-bit) and Windows Vista (64-bit)
with bug fixing of DeviceInterfaceDetailData size problem 5 or 8, doesn't help.
What I found strange was the DevicePath with the value
devicePath = "\\?\hid#vid_05e0&pid_1200#6&1aeb9946&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
Can you give me a hint where could be the problem?
If all the tree become pen and all ocean become ink and many more other ocean become ink even then the ALLAH praise could not be written completely. (AL-Quran)
|
|
|
|
|
I'm having the same problem.
|
|
|
|
|
I get the same error and am trying to diagnose now. Google brought me here and I'm disappointed no-one has answered the question yet. on goes the search for what causes this.
|
|
|
|
|
Тот же самый EXCEPTION и у меня возникает!
|
|
|
|
|
I solved this problem replacing the next code line:
m_hHandle = CreateFile(strPath, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
with this:
m_hHandle = CreateFile(strPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
After that change, the CreateFile method return me a positive number
Now, I have a problem in the BeginAsyncRead method, in the code line:
m_oFile.BeginRead(arrInputReport, 0, m_nInputReportLength, new AsyncCallback(ReadCompleted), arrInputReport);
The exception I got is this:
Excepción del tipo 'System.UnauthorizedAccessException' en mscorlib.dll
Excepción del tipo 'UsbLibrary.HIDDeviceException' en UsbLibrary.dll
Excepción del tipo 'UsbLibrary.HIDDeviceException' en UsbLibrary.dll
UsbLibrary.HIDDeviceException: Msg:UsbLibrary.HIDDeviceException: Msg:Failed to get the detailed data from the hid. WinEr:00000005
en UsbLibrary.HIDDevice.Initialise(String strPath) en C:\_usb_hid\usb hid\UsbLibrary\HIDDevice.cs:línea 132
en UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) en C:\_usb_hid\usb hid\UsbLibrary\HIDDevice.cs:línea 280
en UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) en C:\_usb_hid\usb hid\UsbLibrary\HIDDevice.cs:línea 288
en UsbLibrary.SpecifiedDevice.FindSpecifiedDevice(Int32 vendor_id, Int32 product_id) en C:\_usb_hid\usb hid\UsbLibrary\SpecifiedDevice.cs:línea 42
en UsbLibrary.UsbHidPort.CheckDevicePresent() en C:\_usb_hid\usb hid\UsbLibrary\UsbHidPort.cs:línea 218
I hope someone help us to find a solution!
|
|
|
|