PDA

View Full Version : Using EasyHID with VBExpress 2005 (maybe .NET as well)



mister_e
- 6th June 2007, 02:50
You can download Here (http://www.mister-e.org/USBTemplate/USBTemplate.zip) a small code template to start using EasyHID DLL with VBExpress.

'Till now (june 5/2007) EasyHID don't generate the code template for VBExpress but VB5. I tested it a little bit here, and it seems to be reliable and bug free.

As we all know, David (Mecanique) have been kind enough to do this wonderful software & dll 100% free of charge. Knowing he's busy with something else, i think at least, we owe him a little hand with newer Microsoft Language platform.

This said, this would be nice to hear some comments from user here with this simple code template.

When i find some time, i'll do the VisualC Express template as well.

Thanks again David!

PS: the code template don't include any PIC code. Just VBExpress side. You could use the USBDemo one. The TextBox will show you the ADC results of AN0

sayzer
- 6th June 2007, 09:06
....
Thanks again David!
....

Thanks again Steve!


--------------------------

mackrackit
- 7th June 2007, 00:58
Thank you Steve and David.

The VB5/Express part was my hold up.

mister_e
- 7th June 2007, 01:53
Thanks guys, don't forget to post your "It's working or not" comments...

As i write it, (~24 hours later) the template have been downloaded 76 times already :eek:

Finger crossed ;)

Abnormal1
- 16th June 2007, 16:33
Hi,
Have been playing with this and it works great.

Only thing is that I can not get hidGetVendorName and hidGetProductName to work. I get an "Attempted to read or write protected memory" error with this and i'm not sure if im doing something wrong or that theres a problem with this .net version.

Thanks
Abnormal1

mister_e
- 16th June 2007, 20:51
Yup, Yet another .NET thingy. 'Till now, i have found a way to make it work....


Public Sub OnPlugged(ByVal pHandle As Integer)
Dim DeviceHandle As Integer
' Mister E
Dim VendorName As String = " "
' USB Demo
Dim ProductName As String = " "

If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then ' Good one?
'
' get the device handle
' =====================
DeviceHandle = hidGetHandle(VendorID, ProductID)
'
' Get the vendor and product name from the handle
' ===============================================
hidGetVendorName(DeviceHandle, VendorName, 255)
hidGetProductName(DeviceHandle, ProductName, 255)
End If
Label2.Text = VendorName
label3.text = ProductName

The trick is to assign a value to VendorName and ProductName before calling hidGetVendorName and hidGetProductName. Make sure your space/blank character are at least equal to the LEN if VendorName and ProductName. Unless, it will screw up things.

VB.NET doesn't seems to have a way to determine a fixed String size...

Anyways, i've ask the question on the MSDN forum, let's see if there's a more elegant way to do it. It has to... In meantime, the above solution work.

Abnormal1
- 17th June 2007, 11:23
Thanks for that, it now works.

I expected it to be related to not using a fixed length string, however I had only tried to set the strings to Null rather than a load of spaces.

Anyway I have found that using the following is easier than counting how many time you press the spacebar


Dim VendorName As String = New String(CChar(" "), 16)



Also in the code you posted I don't think that you need to call "hidGetHandle" as you already have that in the variable "pHandle".

mister_e
- 17th June 2007, 11:39
here's a way to assign a fixed format string in dotnet


<VBFixedString(15)> Public VendorName As String

you still need to load with character it so far... don't forget the Imports Sytem

Guys over there send me few links. Load of thing to learn/try with this new .NET. (marshallxxx, exception.. syntax, InteropService.. etc etc etc). Especially when dealing with API :eek:

I've also found few nice .CHM and .PDF on VB.NET and Express... RTFM sessions will begin... when i'll wake up. <hr>


EOM

http://www.mister-e.org/Pics/GoodNight

mister_e
- 10th February 2009, 16:17
Amr Bekhit has modified it a little bit and added some documentation as well

USB HID Template for Visual Basic 2005
http://www.helmpcb.com/Software/USBHIDVB/USBHIDVB.aspx

Moyano Jonathan
- 13th February 2010, 20:26
Hi i from argentina and my english is not very good...but i have a question ....anyone has try to use mcHID.dll (easy HID) in Visual C# ??
any help is welcome ;)

I have tried to write an application in c # but I have not worked :confused:

Moyano Jonathan
- 15th February 2010, 20:41
hello as they are, I could fix most errors in the program but were 5 not understand .... anyway I leave the program so that you take a look.


and finally the mistakes that I generated Visual C #


Error 1 No se puede pasar '<this>' como argumento out o ref porque es de sólo lectura C:\Documents and Settings\Flia. Moyano\Escritorio\Electrónica\easyHID c#\Form1.cs 32 37 easyHID_VB.net 2008
Error 2 'object' no contiene una definición de 'OnPlugged' ni se encontró ningún método de extensión 'OnPlugged' que acepte un primer argumento de tipo 'object' (¿falta una directiva de uso o una referencia de ensamblado?) C:\Documents and Settings\Flia. Moyano\Escritorio\Electrónica\easyHID c#\Module1.cs 121 16 easyHID_VB.net 2008
Error 3 'object' no contiene una definición de 'OnUnplugged' ni se encontró ningún método de extensión 'OnUnplugged' que acepte un primer argumento de tipo 'object' (¿falta una directiva de uso o una referencia de ensamblado?) C:\Documents and Settings\Flia. Moyano\Escritorio\Electrónica\easyHID c#\Module1.cs 125 16 easyHID_VB.net 2008
Error 4 'object' no contiene una definición de 'OnChanged' ni se encontró ningún método de extensión 'OnChanged' que acepte un primer argumento de tipo 'object' (¿falta una directiva de uso o una referencia de ensamblado?) C:\Documents and Settings\Flia. Moyano\Escritorio\Electrónica\easyHID c#\Module1.cs 129 16 easyHID_VB.net 2008
Error 5 'object' no contiene una definición de 'OnRead' ni se encontró ningún método de extensión 'OnRead' que acepte un primer argumento de tipo 'object' (¿falta una directiva de uso o una referencia de ensamblado?) C:\Documents and Settings\Flia. Moyano\Escritorio\Electrónica\easyHID c#\Module1.cs 133 16 easyHID_VB.net 2008