Using EasyHID with VBExpress 2005 (maybe .NET as well)


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Using EasyHID with VBExpress 2005 (maybe .NET as well)

    You can download Here 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
    Last edited by mister_e; - 6th June 2007 at 03:38.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Thanks to you!

    Quote Originally Posted by mister_e View Post
    ....
    Thanks again David!
    ....
    Thanks again Steve!


    --------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Thank you Steve and David.

    The VB5/Express part was my hold up.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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

    Finger crossed
    Last edited by mister_e; - 7th June 2007 at 02:13.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup, Yet another .NET thingy. 'Till now, i have found a way to make it work....
    Code:
       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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Feb 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    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
    Code:
    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".

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    here's a way to assign a fixed format string in dotnet

    [HTML]<VBFixedString(15)> Public VendorName As String[/HTML]

    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

    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

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10


    Did you find this post helpful? Yes | No

    Thumbs down easyHID problems in c #

    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
    Attached Files Attached Files

  11. #11


    Did you find this post helpful? Yes | No

    Default

    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 #
    Code:
    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
    Attached Files Attached Files

Similar Threads

  1. Replies: 4
    Last Post: - 5th November 2008, 16:21
  2. Problem with enumeration and EasyHID
    By jizyjuice in forum USB
    Replies: 22
    Last Post: - 9th April 2007, 20:40
  3. EasyHID and VB.net
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th September 2006, 05:40
  4. HIDMakerFS versus EasyHID
    By Demon in forum USB
    Replies: 4
    Last Post: - 15th August 2006, 08:01
  5. Replies: 0
    Last Post: - 5th September 2005, 09:09

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts