Griffin Powermate Driver Windows 8
Table of Contents Motivation We wanted to find a new solution to connect our Hardware to the PC via USB because the experience we made with FTDI Chips was not satisfying at all. The USB controller of our choice was the Maxim MAX3420E that is connected to the microcontroller through a Serial Peripheral Interface (SPI). The MAX3420E comes without any drivers or libraries you can use to “speak” with it. Budidaya Pepaya Calina Pdf To Word.
Buy Griffin Technology PowerMate Assignable USB Multimedia Controller featuring Shuttle Wheel & One-Touch Button, Connects Via USB Programmable. The downside is that there is not a Windows 7 driver but the Vista Driver seems to work well but it will probably not have all the intended functionality. Looking for a Windows 8/8.1 device to control volume. I've read that Griffin's PowerMate has difficulty with Windows 8/8.1. Perhaps it's better suited to a. I used to have issues with my powermate, update the drivers not only for the powermate but for the USB controllers and whatnot as well. That solved a.
This is the reason why I had to develop my own “driver”. After a day of reading and googling I decided that the best an easiest way is to use the Human Interface Device Class (HID). The HID-Class is a generic device class which means that all devices in this class are supported by Microsoft Windows and there are already existing DLLs with functions that we can use. The start point for the “driver” was an article I found in the Microsoft developer network: „Is That You? Writing Better Software for Cool USB Hardware” written. Scott’s software is based on the.
Luckily the MAX3420E comes with a code sample that configures the controller as a Human Interface Device so we didn’t have much trouble to find out how to configure it as HID. The Human Interface Device Class As mentioned above the HID Class is a generic device class so the driver is integrated in the operating system which makes things easy. If a new HID device is plugged in there is no need of any driver installation. The functions to access and control a HID device are included in the Windows hid.dll which is located in the System32 folder. If you do not know for sure if your device is a HID device you should have a look at this little application. Artistic Anatomy By Dr Paul Richer Pdf Editor.
It is a part of windows and you can run it with the start ->run “msinfo32.exe” command. Or under Windows Vista just press the Windows-Key Type msinfo32.exe and hit enter. USB Specific Stuff Identify your USB device USB device are identified by their vendor and product id. Those IDs are consisting of a prefix (“vid_” for vendor id or “pid_” for product id) and a 4 digit HEX number. The MAX3420E for example has the vendor id vid_06ba and the product id pid_5346.
Usually both values can be changed in the source code of the USB device (assumes that you have access to that code). Package Size / Communication Speed HID devices are communicating with the pc through so called hid reports. Those reports consist of 64 bytes of data. Each microsecond one report is send from pc to the USB device and vice versa. This means that theoretical a transfer rate of 64 Kbytes per second can be achieved.
The HID USB Driver Interface The driver is written in C# and designed as a DLL, this has the benefit so it is very easy to integrate the drive into a new project. Just import the DLL or the project and you are finished.
I tried to keep the interface as simple as possible on the one hand and on the other hand to integrate as much functionality as possible. At the moment it has the following functions: USBInterface(String,String) constructor This method initializes a new instance of the USBInterface class. Parameters vid The vendor id of the USB device (e.g.
Vid_06ba) pid The product id of the USB device (e.g. Pid_5346) USBInterface(String) constructor This method initializes a new instance of the USBInterface class.
Parameters vid The vendor id of the USB device (e.g. Connect() method This method establishes a connection to the USB device. You can only establish a connection to a device if you have used the construct with vendor AND product id. Otherwise it will connect to a device which has the same vendor id is specified, this means if more than one device with these vendor id is plugged in, you can’t be determine to which one you will connect. Returns False if any error occurs Disconnect() method Disconnects the device getDeviceList() method Returns a list of devices with the vendor id (or vendor and product id) specified in the constructor. This function is needed if you want to know how many (and which) devices with the specified vendor id are plugged in. Returns String list with device paths write(Byte[]) method This method writes the specified bytes to the USB device.
If the array length exceeds 64, the array while be divided into several arrays with each containing 64 bytes. The 0-63 byte of the array is sent first, then the 64-127 byte and so on. Parameters bytes The bytes to send.
Returns Returns true if all bytes have been written successfully startRead() method This method is used to activate the “reading-State”. If you execute this command a thread is started which listens to the USB device and waits for data. StopRead() method This method switches from “reading-State” into “idle-State”. By executing this command the read data thread is stopped and now data will be received. EnableUsbBufferEvent(EventHandler) method By calling this method with an event handler (System.EventHandler) the add-event listener of the USB Buffer is enabled. Thus whenever a dataset is added to the buffer (and so received from the USB device) the event handler method will be called. Parameters eHandler The event handler (System.EventHandler) method.
How to integrate the HID USB Library into a Visual Basic Project There a two ways to integrate the HID USB Library into a Visual Studio project. One is to add the library project to your Visual Studio solution. The other way is to add a reference to the USBHIDDRIVER.dll in the visual basic project you want to use. Add the library project to a Visual Studio 2005 solution 1. Open your Visual Studio solution.
Go to “File >Add >Existing Project” 2. The following Dialog will open. Navigate to the USBHIDDRIVER.csproj and click open. Right click on your Visual Studio project and click « Add Reference » 4. Select the „Projects“-tab. Then select the USBHIDDRIVER and click ok. Add the USBHIDDRIVER.dll to a Visual Studio project 1.
Right click on your Visual Studio project and click « Add Reference » 2. Select the „Browse”-tab.
Then navigate to the USBHIDDRIVER.dll.dll and click ok. Use the USBHIDDRIVER.dll with Visual Basic 6 The.Net runtime allows unmanaged COM aware clients (like Visual Basic 6 applications) to access.Net components through the COM interop and through the tools provided by the framework. The USBHIDDRIVER.dll is a.NET assembly which can not be accessed by Visual Basic 6. Therefore we have to create a type library which can be used with Visual Basic 6. This can be done with the Tool RegAsm.exe that you will find in the directory of your.Net framework installation. Create a.bat file in the directory of the USBHIDDRIVER.dll and write the following command into it.
Then run the bat file. “C: WINDOWS Microsoft.NET Framework v2.0.50727 RegAsm.exe” USBHIDDRIVER.dll.dll /tlb: USBHIDDRIVER.dll.tlb Now you have to copy both the dll and the tlb file in the same directory as the application which is consuming it. How to use the HID USB Library Let’s say you want to communicate with an USB device that has the vendor id vid_06ba and multiple products id. So the first thing you may want to have is a list of all devices connected to the pc which have the specified vendor id. To do this just make a new instance of the USBInterface class with only the vendor id as parameter. Then call the getDeviceList-Mehtod and you will receive a list of the devices that are connected. USBHIDDRIVER.USBInterface usb = new USBInterface(“vid_06ba”); String[] list = usbI.getDeviceList(); For communicating with the device make a new instance of the USBInterface class with the vector id and the product id as parameter.
After that, you can call the connect-method and a connection will be established. USBHIDDRIVER.USBInterface usb = new USBInterface(“vid_0b6a”, “pid_5346”); usb.Connect(); Once your device is connected you can read or write data. To write data just call the write method with an array of bytes you want to send as parameter. For reading you have to options: first without the USB buffer event and second with USB buffer event. If the event is enabled, the event handler method will be called when a new dataset is received.
Otherwise you can process the data with a timer or something like this. Usb.write(startByte); usb.enableUsbBufferEvent(new System.EventHandler(myEventCacher)); Thread.Sleep(5); usb.startRead(); usb.stopRead(); usb.write(stopByte) How the HID USB Library works internal The library is based on the USBSharp class that imports all needed methods from the kernel32.dll and hid.dll. The HIDUSBDevice class wraps those methods and handles the read thread. The USBInterface is the main interface, which is accessible from outside the dll. In the USBInterface class exists a object of the ListWithEvent, which is basically a ArrayList with the bonus that an event is fired when a new dataset is added. Last but not least in the HidApiDeclaration class you will find some declarations needed for the whole hid-thing.
Where can I get the HID USB Library? You can the library. If you like the library and want to give something in return here is my. This entry was posted in,,,. Bookmark the. Okay, it looks like HidDeclarations.cs is basically unused so maybe that does not matter, but the HID structures are also defined in USBSharp.cs. In there the UnitsExp and Units fields of HIDP_VALUE_CAPS are defined, but their specified sizes appear incorrect as are LogicalMin/Max and PhysicalMin/Max which should all be 32-bit values.
Do you concur? Can you also explain your use of “unsafe” in declaring many of these structures that don’t appear to contain pointers? My understanding was that unsafe was only used with pointers. I cant get any HID devices to show up with your tutorial. So i made a simple for loop to try all possible VID’s and still got nothing. Any help would be appreciated.
Dim usb As USBHIDDRIVER.USBInterface Dim hexcount As String = “” Dim vids As String = “” Dim loopvar As Integer For loopvar = 0 To 65535 If loopvar = 16 And loopvar = 256 And loopvar = 4096 Then hexcount = Hex(loopvar) vids = “vid_” + hexcount usb = New USBHIDDRIVER.USBInterface(vids) Dim list As String() = usb.getDeviceList() If list.Length 0 Then ListBox1.Items.Add(vids) Next. Your library is great although having some trouble using it. I have been trying to write my own library and I was having some problem with that so I decide to try yours. I have created a C# application. First I have a question.
In your example code for connecting to a device, USBHIDDRIVER.USBInterface usb = new USBInte.; usb.Connect(); But from the code, the 1st line will create a connection a file (HIDHandle). Do we need the 2nd line? The next question is the GUID. In the code you have [assembly: Guid(“3adea963-ff5f-4213-bc50-ac25c4769dfb”)] Is this the GUID of the software APP or the device? From what I can see, it seems to be the GUID for the APP. I ask because some of the other example code that I’ve seen uses specific GUID values, to what I thought was referencing the device, when calling SetupDiGetClassDevs & SetupDiEnumDeviceInterfaces. Now to my problem.
Basically I cannot seem to write to my USB device (SI Labs Eval board – which comes up as a USB-HID device). The return value for the WriteFile command always comes back as false (number of bytes written is 0) but when I check for errors (Marshal.GetLastWin32Error()), that is also returning 0. I’m struggling to come up with ideas as to why this is happening. The code: bool connected = false; byte[] USB_iobuf = new byte[64]; USBHIDDRIVER.USBInterface usb = new USBHIDDRIVER.USBInterface(“vid_10c4”, “pid_8044”); connected = usb.Connect(); USB_iobuf[0] = 1; USB_iobuf[1] = 1; // other USB_iobuf values are not included here usb.write(USB_iobuf); Any ideas? Thanks in advance for any help! Hi guys, sorry for the delay.
———- @Jon: If you run USBHIDDRIVER.USBInterface usbI = new USBInterface(“_”); String[] list = usbI.getDeviceList(); You will get all USB Devices plugged in. ———- @ Anish Thomas: Connect(): You are right, the usb[].Connect() command is not needed to establish the connect.
But it is usefull if the connection to device is lost and you want to re-establish it. GUID: It’s the GUID of the app. @ Anish Thomas & Flo: Write: Are your shure that your device is accepting write requests and it is ready to receive? A good way to debug the read and write function is using a USB Monitor (e.g. ) If this does not help feel free to contact me 😉.
Hi, Florian Leitner. I’m a student of electrical engineering in indonesia. Several month ago i tried to learn USB and make ‘max3420’ works.
And last week it’s happen like maxim tutorial. And after that,i’m going to start my final project to make some application that using usb connectivity.and the problem is, i still can’t reply host ‘out’.i don’t have much information to developed it. Can you explain how you configure the ‘max3420’ in your tutorial? Did you use another endpoint?
(in maxim tutorial-HID, just endpoint in 3 interrupt) how device send data if endpoint out 1 is not configured? Any changes in report descriptor?
Can you send me your example code that i can learn? Sorry for my english. I’m still learning.i hope you will understand my message. Thank you for your help. Hi, help please.
I have aproblem with write to the usb. The connect is successful ( i got “true” from the function) but the function UsbI.write() all the time return “false”. I am using also USB Monitor Pro and i see that there is no writing to the device. When i debug the software i see that the failure happens in the low level function USBSharp.WriteFile() in HIDUSBDevice.cs file this function return “false”. My device is microcontroller ARM with a firmware that supports USB HID.this device works good for writing and reading with other HID Software so i dont think that the problem is in the device. Is everyone have any idea what is the problem? Thanks lior p.s.
Hi Florian, I’m very happy finding your library, it would make my life 100 times more easier with 1 restriction 🙂 I can’t find out, why can I only “talk” with HID devices? In my case, I have a Non-fiscal thermo-printer (Wincor Nixdorf TH230) wich is connected a powered-usb (24V) and i can find it on the device list PID and VID too but i cannot retrive the serial number because it’s not known as a HID device by Windows (Windows Embedded for POS). Do you have any ideas how can i bring this to run?
Sorry, my last post was truncated for some reason. Nevertheless, I can indeed read from 2 devices. The problem that remains though is that after closing the app, it seems as if a thread is still running, because the app is still alive somehow. Perhaps the associated EventCatcher is still running? BTW, the devices I’m reading from are 2 magnetic swipe readers: Magtek and IDTech. When I use win32 (using Delphi), I need to use Report Descriptors, which is a very different way of getting info from the device. Hi, help please.
I have aproblem with write to my usb device. The connect is successful ( i got “true” from the connect() function) but the function Usb.write() all the time return “false”. I am using also USB Monitor Pro and i see that there is no writing to the device. When i debug the software i see that the failure happens in the low level function USBSharp.WriteFile() in HIDUSBDevice.cs file this function return “false”. My device is microcontroller PIC 18f4550 with a firmware that supports USB HID.this device works good for writing and reading with other HID Software so i dont think that the problem is in the device. Is everyone have any idea what is the problem? Thanks valioman.
Hi, I have designed my activeX control with the win32 usb library. All work fine and i am getting the detection as well as the event notification into my web application throught javascript. The only problem is when i close my HTML page this make the device disconnected. I am using the win32.unregister “Win32Usb.UnregisterForUsbEvents(Handle)” alos on my usercontrol dispose method on the activex side. But that dosen’t makes any changes.
Please help me as t his is kind of a urgent thing Thanks & Regards Syed. Thanks for your time.
I am using cypress usb development board. The number of devices and their paths are shown correctly. But i am facing problem with READing data from the device. When i put some data in the usb buffer and then read. It works and the correct data is given. But i cant find any data coming into yhe buffer from the device. And the following error i get when i use the event handler method “Error2The name ‘myEventCacher’ does not exist in the current contextC: Documents and Settings faizan.rasool My Documents Visual Studio 2005 Projects edited edited Form1.cs53” regards Faizan R.
Great library, Florian! A big help for my project. (I’ll have to check that wishlist!) However, I don’t understand the usefulness of the List.ListWithEvent. At first I thought it might clue me into when a USB device was plugged or unplugged. But that doesn’t seem to fire. Maybe I’m not doing it correctly (I’m not all the great a programmer, anyway). Can anyone suggest what the ListWithEvent is useful for?
Or better, yet, how I can detect, using this library, that the magstripe reader has been unplugged or plugged back in? Thanks in advance. Hi, i have been searching about HID USB libreries for a week because i have a special joystick which need to receive a Set_Feature 1 before start to send packets. I tried a lot of things and all crash or dont compile or something similar.
Looking at the source code i saw you import the Set_Feature from hid.dll Is this function avaiable throught VB6? Can you write a little example of how to use your lib with vb6? Im getting a lot of sintaxis errors. Hi Florian, first of all: this is one great library. After spending days with the microsoft windows DDK, this is something is was looking for. My Problem now is: an HID-compatible device (AVR-Controller) sends binary data over usb to the pc, whereas windows on the pc executes the recieved data as window messages(KeyCode, SystemEvent, etc.). Do you have a solution or an idea of howto terminate the parsing of such messages by the native wm_proc function under any windows application?
After looking too long at the windows dde, i would prefer a managed code solution Nevertheless, thank you very much for developing and introducing this library. Best regards JKP. In the VS 2008 will be the project file not accepted. If i try to open it in the vs2008 open project browser, they will be not displayed. If i made simply doubleclick on it, only not usable html file, will be opened.
But the menue: >Build>Rebuild>>AddReference>, will not be available. I try it on the german Microsoft Visual Basic Express edition 2008, and on the english full version too. The same thing. Is there a way to publish it on the 2008 version instead 2005? Or a guide, how to open it in the 2008 version.
Next i try it to test under VB6, because the generatig of the files was ok, so i will see. Best regards, thank you, Feri (you can write on my email in german too). I’m a Delphi user And a PIC18F user I personally have a project with all this I have been using Mikro Pascal to write my pic This language is so much less messy and things get done faster generally for me when i have the tools. Personalty I do not think we should write code to have limits if what go with what only. Manufactures need to be held competitive. I personally see its much easier for Delphi users to get access through *.OCX or a *.Dll file with what you have written. But what impresses Delphi/Bourland users more is a HIDUSB.DCU file that no other exe files become necessary as its all in one *.exe.
I found a file HIDUSB.h and converted it with CTOPAS.exe I also found windows at driver level does not generally like HID but at the same time found an event written in Delphi that identify’s USB devices being connected/disconnected. I have not tested it in HID USB devices yet. I have just been looking at ActiveX in the MSDN (half a gig to install) and their is.Net too that you like also..net is no good on single processor computers only mufti processor computers. Theirs lots of single processor computers out their that are ideal to drive micro’s very well. For those that do not use.Net (windows XP) can a number of DLL’s me copied and installed instead.
Is that a simpler option. I’m considering doing this with activeX also as another option. The reason that I like Axtivex personally is its more future proof as. Net is changing to fast. And all will be throughen out with USB3 any way. Its about getting the job done well to me and hitting the most end users.
Any way CtoPas.exe is windows based and can be found on TorryPages web site its easy to use if your C file complies ok. Points again 1/ your files run on PIC18F’s, Windows XP 2/ Can I help you to make a Delphi version after all every one should acknowledge the developers, as its free. 3/ I’m doing this for my Pic project and trying to combine a Delphi written program to support the Pic through the Pic’s HID interface. With out this my project will not work. 4/ The more you give developers the real code rather than handing it in *ocx’s or *DLL’s for the writters esteem the more developers are empowered to make better choices and more reliable products become. As the problem is MicroSoft are trying to make money off developers by not letting USB be open source.
And that hurts hobbyists like me. I hope this is not seen as offensive but only a different developers opionion running from a different language thinking how to make better good to all hobby devalopers. Hi, I really appreciate that you have taken the time to develop this for the community. Please keep that in mind as you read the following. What you’ve written here is extremely poor code.
In addition, you have built the project based on other poorly written code. Almost nothing here actually works, except in specific scenarios. Your thread-handling is very poor and error prone. You don’t use any thread safety techniques.
Why is usbBuffer a static property? It should be a property of the USBInterface class, and it should only recieve data sent to the specific USBInterface object (not ALL connected objects). And it should be based on a Queue mechanism, not an arraylist.
You should expose a Connect(path) method that allows you to connect to a specific device based on its path or guid. MANY devices (even simple ones) install multiple HID instances that have the SAME pid and vid. Your code does NOT allow anyone to connect to any but the FIRST one.
What happens if you have two similar devices attached? It is SO easy to do this much better than you have done it. I just can’t understand why it is so poorly written. Take this for example: Thread.ThreadState.ToString()==”Running” WHY WHY WHY? Why spend the extra time converting to a string?
That is absurd and outrageous. Just do Thread.ThreadState==ThreadState.Running Come on, this is C#, a sophisticated language with great exception handling and thread-safety capabilities. You act like it is some primitive form of VB.!!! I hate to be so mean, and normally I would say it was a great and noble deed for you to have posted this.
But the reality is that most of the people here would have done better just to keep browsing for another option. You’re code has actually hurt them by introducing so many terrible potential errors! Hi Rich, thanks for your comment, you are absolutely right about the poor style of the code, there are many things that one could improve easily unfortunately I lack the time and the test device to do so. But any one who is interested in contribute to the code, please send me an eMail or post a comment here and I will give you access to the repository. To be honest when I developed the “library” in 2006 I would never have thought that it will still be used in 2010.
At the time it was developed for Windows XP, it worked with Windows Vista and works now with Windows 7 without a lot of maintenance. I see this project as something I want to provide to everyone who wants to educate himself on USB HID programming and needs some starting point. If you know of better libraries I will be happy to link them or as already said if you want to contribute to the project please let me know. Hello Florian, great work! I was finally able to receive data from my eDio Multi Remote device (remote control) – there are no working drivers. At least none worked for me, so I decided to write my own. I’ve a minor problem though: I connect to the USBInterface in my Form_Load()-event (C#).
It’s also the event where I do myDevice.startRead(). I assigned an event that is triggered whenever I press a button on my remote – works well. Now if I close the form I call myDevice.stopRead() and set myDevice to null. However it still requires a single press on my remote control (no matter what button) to actually terminate the program.
Do you have any idea what I might be doing wrong? Thank you very much. Hi people, I have been using this library for hours, I connect and read from the device sucessfully but I am unable to read, ok, After hours of try and error I notice tthat some devices (like mine) receive the byte array and its values in hex base, so I find that a WriteFileEx function exist but is not declared in the USBSharp class, so I have don’t try this yet but I think it is the solution to the wrie problem.
If any of you try this and can confirm please feedback. And Florian, thanks for the project 🙂. Hello Florian, I’m trying to use this library. But I have te same problem as some other people have/had. I’m using a USB barcode scanner (which the pc recognises as a Keyboard device). But what I would like to know is: Has someone found a solution to make this also be detected (by the way, when I connect to the device it can connect).
And to make it possible to read the data send by the barcode scanner. Or is there a way to install the device and not make it recognised as a keyboard device. Hope someone has the answers. Kind regards JKorsten. Hi Florian, your library is great! I finally understand how I can communicate to an USB device. But, I have a little problem: I can write data from the PC to the USB device (I use a Microchip PIC 18F4550) but I cannot read the usbbuffer.
I know it´s receiving data (I tried with the USB monitor and the counter from usbbuffer) but I can´t read the data in usbbuffer. I´m using Visual Basic 2008 and I will very very greated with you if you can write a little example code to read any data and save it in a string. I´ll apreciate that. Greetings from Lima-Peru, and sorry if my english is bad. I am new in this HID USB library stuff.I am getting no errors, no warnings but still getting this message while compiling the code “A project with an output type of class library cannot be started. In order to debug this project,add an executable project to this solution which references the library project.Set the executable project as the startup project. ” I also made USBHIDDRIVER as a startUp project and set output type as class library.
But still not getting any output and above message appears on compiling. Please someone help!!!thanks. Florian, Thank you for your contribution with the USBHID library. I am attempting to interact with a Magnetic Stripe Card Reader/Writer (Model#: MSR905H) As such, I have implemented your library in Microsoft Visual Basic.NET 2010 Express.
Hey florian-leitne, nice work man. I am interfacing pic 18F4550 with my pc through usb port.first I found it quite difficult but after a lot of googling,I found your page.nice work.but I am facing a little problem.kindly help me the problem is im using visual studio 2005,I am creating c# project,then I am adding your “csharp-usb-hid-driver” to my project.now i write functions like “USBHIDDRIVER.USBInterface usbI = new USBInterface(”vid612,pid415″);” my c# compiler gives me a lot of error.not recognizing USBInterface.means anu thing I am new to C#.Bt exxperienced with Visual C++.
So if any one tell me how to use this library with Visual C++ then i shall be extremely thankful. Thanks for your time. Anyone used this driver for the wireless playstation Buzz controllers? I tried but haven’t succeeded in writing to the buzzcontrollers (switching the Red lights) I can seem to connect to the controllers but not writing to them nor reading data from it? Here is a piece of my code: bool bLight1 = true; bool bLight2 = false; bool bLight3 = true; bool bLight4 = false; USBHIDDRIVER.USBInterface usbI = new USBInterface(“vid_054c”, “pid_1000”); usbI.Connect(); byte[] arrBuff = new Byte[8]; arrBuff[2] = (byte)(bLight1? 0xff: 0); arrBuff[3] = (byte)(bLight2? 0xff: 0); arrBuff[4] = (byte)(bLight3?
0xff: 0); arrBuff[5] = (byte)(bLight4? 0xff: 0); usbI.write(arrBuff); The write() method keeps returning ‘false’ How do I get this driver to work on the buzz controllers? Regards nicci. VS 2010 C# create and list work fine. Write returns false with 87 (Parameter Error) All parameters look reasonable to me, length of report is 65. Result = USBSharp.WriteFile(hidHandle, ref outputReportBuffer[0], outputReportBuffer.Length, ref NumberOfBytesWritten, 0); // Result = false Int32 rc = Marshal.GetLastWin32Error(); Debug.WriteLine(rc.ToString()); // 87 I have example code that opens and writes the HID device using win32 just fine. I liked your C# class because I want to use C# and it is a lot cleaner than the example.
I will post back if I am able to solve the problem myself before punting. Florian Leitner friend I am working card data acquisition of temperature and humidity and energy consumption with pic 18F4550 and the interface and database for the’m done with c # 2008 but not as work as the dll and api besides I could not identify sending data to the pic hid the device and the host reconose and tells me that I have used and monitor connected USB device and identifies me but api and dll confuses me as I have guided examples are on the web and not how to import the dll to my project tells me that is not valid com tool nesecito please help me thank you in advance Vrinda. Thanks dude for giving such a wonderful open source tool Because of ur dll i came to know a lot abt how usb works. Most part of ur work was clear 🙂 Btw what i actually wanted to ask is, “Am I allowed to edit the dll and add some custom classes for my game?” I am asking this because i wanna use this in Unity3d game engine, which is mono based so some of the classes are not supported and also i need to change the scope of some members so i can process it with inbuild unity function. Hope u get it! Anyway thanks again 🙂. Csharp-usb-hid-driver USBHIDDRIVER TESTS folder of the dowload.
There is an example of the code to use. Take the implementation of the myEventCacher method. Where it says “//DO SOMETHING WITH THE RECORD HERE” add your own code to read the data.
My code looks like this: Console.WriteLine(currentRecord[0].ToString()); Console.WriteLine(currentRecord[1].ToString()); usb4.stopRead(); The stopRead will throw a Threading.ThreadAbortException, so if you handle that properly, you get a way to exit from the thread that the event runs in. Use a timer to run startRead() method at intervals, or if you have code where you send data to the USB device and expect an answer, then run startRead() from there. Hopes this help. Has anyone found a way to get this to work with C++ I tried and I can pull all the files no problem I added an interface so I can use the MSDN example of #import “ USBHIDDRIVER.tlb” using namespace USBHIDDRIVER; HRESULT he = CoInitialize(NULL); InterfaceOfTheClass objectName(__uuidof(USBInterface)); However I keep getting this error.
First-chance exception at 0x774a070c in ConsoleApplication2.exe: Microsoft C++ exception: _com_error at memory location 0x0066ee64. Followed by System.Runtime.InteropServices.SEHException. Don’t know why any help is appreciated. Thank you for posting the code. It would be great if the companies that make these things would give sharing a try. It’s hard to even find basic information about these products.
I believe there are 3 versions now. 1.0 is serial over usb, 2.0 is hid, and I saw a 3.0 on usbfever.com. I’ve rewritten some other code I found online to get the TEMPer 1.0 to work in visual basic 6, but I haven’t attempted anything hid yet. Has anyone rewritten the code in vb6 and got it to work? Here’s my email address I would extremely appreciate it if anyone could send me any vb6 code they have for the temper hid. Even if you haven’t gotten it to work yet, maybe I can figure it out.
When I get something working, I’ll post it on planetsourcecode.com. I am playing around with this lib and trying to hack the Dream Cheeky USB Panik Button. I can read the data and detect if the button is pushed or not. My problem now is: currently, I also have to run the original driver, as it seems to poll the button for its state and I would like to do this myself. I have found out, that I would have to send Set report 00 00 00 00 00 00 00 02 to it, in order to get the button state (doing so with e.g. SimpleHIDWrite.exe works fine). If I now want to use your write-method, it seems to fail.
I get an “The supplied user buffer is not valid for the requested operation” error (implemented the windows error tracking: [DllImport( “kernel32.dll”, CharSet=CharSet.Auto )] public static extern int GetLastError(); ) Here is my piece of write code: Byte[] writeBytes = new Byte[8]; writeBytes[0] = 0x00; //writeBytes[0] = 0x00; //writeBytes[1] = 0x00; //writeBytes[2] = 0x00; //writeBytes[3] = 0x00; //writeBytes[4] = 0x00; //writeBytes[5] = 0x00; //writeBytes[6] = 0x00; writeBytes[7] = 0x02; //writeBytes[0] = 2; bool ok = usb.write( writeBytes ); ok is always false. Do you have any ideas? Hi, First of all, I wanted to thank you for publishing the code. Saved me alot of work I modified it a bit to allow to specify from “outside” the vendorId, and PID but otherwise works fine. But.(there’s always a but) after I encountered problems and narrowing it down a bit, I realized that it apparently doesn’t support 64-bit.
So my question is (a) Have you added support for this? (b) Can you point me to to what needs to be changed for 64-bit to work? (c) Do you know of someone else that has had the same issue and may have resolved it? Appreciate your help. Kirk, I also ran into the error when calling USBInterface.Disconnect(). Its because that function is calling Abort() on “usbThread”.
UsbThread is not actually created and used in the library at all. Null object reference.
I modified the source to call Abort() on the actual thread (dataReadingThread) being used to read from the USB device. I am currently stuck on the issue that I see everyone is having. Once you start the thread reading from the USB device, the thread blocks on the call to ReadFile() waiting for the device to return data. This is fine since its in a thread. The problem is that when you shut down the application, this call to ReadFile() is still waiting and hangs the application so that it will not shut down properly. If I hit a button on my USB device (or unplug it), the call to ReadFile() returns and the app closes.
I have tried calling Cancelio() which is supposed to cancel a blocking ReadFile() call but its not working. If I can just find a way to tell Windows to cancel that ReadFile() call we would be golden. I know others have been using the Environment.exit() call to force the application to exit, but I want to do it properly.
Florian, Thank you for putting this out there. It has been a huge help! For everyone who has a problem with write() function which returns false. I found a bug in a source code. Brief introduction: I’m making device with MSP430 microcontroller from Texas Instruments. I had big trouble with usb.write() function. So I was debugging C# codes and found out that in HIDUSBDEVICE.cs in function writeData() is allocated byte array “OutputReportBuffer” of size 65 bytes (MSP device needs 64 bytes packet!!!).
And also this function writes zero to the first byte of this array, so the function clears ID report number, which I put into first byte in the function usb.write(). But if I change size of array to 64 and delete line with zero to the first byte, everything will go well.
Hi, Great library!! The only problem is that my device is listed as two separate items in the device manager and using usb.getDeviceList(). The two devices has the same VID and PID, so there is no way to separate them I have tried the following: var usb = new USBHIDDRIVER.USBInterface(“0c45”, “7401”); var list = usb.getDeviceList(); // returns two items usb.enableUsbBufferEvent(new EventHandler(DataRecieved)); Thread.Sleep(5); usb.startRead(); but nothing happends My device works is I use an application like ThermoHID, but I can’t get any data out of it using the library Any suggestions? My device is a TEMPer1 (-40 – +120, with external sensor) Steinar. Hi everyone, I wrote the library back in the days of Windows XP, I’m actually quite surprised that the library still works with Windows Vista and Windows 7. Right now I’am not able to maintain the library, which is among other reasons due to the lack of time and due to the lack of hardware (I don’t have any USB HID hardware device that I could use with the library anymore). My best guess is that Microsoft made some changes in how USB HID devices can be accessed in Windows 8 an the library will not work with Windows 8.
Nevertheless if anyone gets the library to work with Windows 8, please share the code and let me know! Hello Florian Leitner-Fischer, I am also using MAX3420E USB to read the data from microprocessor. I also want to develop a driver which read the data from the USB but i want in C++,because i am not aware of C#. I have downloaded the USBHIDDRIVER Code,the code successfully complied by getting an error when tried to Debug. “A project with an output type of class library cannot be started directly. In order to debug this project,add an executable project to this solution which references the liberary project.Set the executable project as the startup Project” Where USBHIDDRIVER is my Startup project.Can you let me the solution as i am very new to the filed.