Example USBHidNetClass with VC# and VB

DOWNLOAD

Project with microcontrollers here: >>>>>>>

Download  Free Demo USBHidNetClass Project Visual C# and Visual Basic.NET + microgenioUsbHID.dll (lib USBHidNetClass). Atual version: v1.8 Download Free Demo USBHidNetClass

Download Free DemoDownload Free Demo USBHidNetClass

History: 1 – Version: Upgrade to framework 4.

Download  Free Demo USBHidNetClass Project Visual C# and Visual Basic.NET + microgenioUsbHID.dll (lib USBHidNetClass). current version: v1.8 Download Free Demo USBHidNetClass Limitation Free Demo.

  • Temporized message showing “Versão Estudantil”
  • After 30 minutes of use the USB it will be automatic disconnected from your computer
  • The demo version it´s only for the educational use  and it cannot be commercialized
  • History:

1 – Version: Upgrade to framework 4

 

To use the USBHidNetClass component you have first to add on the ToolBox of Visual Studio, for this you just have to copy and paste using (CTRL C + CTRL V).

Toolbox USBHid

After that you just have to click on the component and drag into your form.

Easy USBHIDNetClass:

 

Bellow the functions and methods to use the component.


Exemplo no Visual C#:

using microgeniosUsbHID; //inclui a lib no projeto

 

Exemplo no VisualBasic:

 

Imports microgeniosUsbHID' //inclui a lib no projeto

 

 

 


Establishment of buffers for storing data for read and write to the USB port.

Exemplo no Visual C#:

 

byte[] DataWrite = new byte[64]; //buffer de escrita na USB

byte[] DataRead = new byte[64]; // buffer de leitura na USB

 

 

 

 

Exemplo no Visual Basic:

 

Dim DataWrite(64) As Byte 'buffer de escrita na USB

 

Dim DataRead(64) As Byte 'buffer de leitura na USB

 


Configuring PID and VID on the project. Don´t forget that the PID and VID must be the same programmed on the microcontroller code.

Exemplo no Visual C#:

 

microgeniosUsbHID_Port1.DeviceUsbHID_Init(USB_VID, USB_PID); //informa o VID e PID da aplicação

 

 

Exemplo no VisualBasic :

 

MicrogeniosUsbHID_Port1.DeviceUsbHID_Init(USB_VID, USB_PID) 'informa o VID e PID da aplicação

 

 


The following method is invoked via the operating system itself every time a USB device that uses HID class is removed from the computer. Regardless of the PID and VID setting this method will always be invoked to remove a USB device.

Exemplo no Visual C# :

private void microgeniosUsbHID_Port1_microgeniosAnyDeviceUSBHid_Removido(object sender, EventArgs e)

{

if (InvokeRequired)

{

 

 

Invoke(new EventHandler(microgeniosUsbHID_Port1_microgeniosAnyDeviceUSBHid_Removido), new object[] { sender, e });

}

else

{

lblStatus.Text = "Algum dispositivo HID foi removido do PC";

 

 

}

}

Exemplo no Visual BASIC :

 

Private Sub MicrogeniosUsbHID_Port1_microgeniosAnyDeviceUSBHid_Removido(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MicrogeniosUsbHID_Port1.microgeniosAnyDeviceUSBHid_Removido

If InvokeRequired Then

Invoke(New EventHandler(AddressOf MicrogeniosUsbHID_Port1_microgeniosAnyDeviceUSBHid_Removido), New Object() {sender, e})

Else

Me.Label1.Text = ("Algum dispositivo HID foi removido do PC")

End If

 

 

End Sub

 


This method checks if any USBHid dispositive was found on the computer.

Exemplo no Visual C#:

private void microgeniosUsbHID_Port1_microgeniosAnyDeviceUSBHid_Encontrado(object sender, EventArgs e)

{

lblStatus.Text = "Algum dispositivo HID foi encontrado na USB";

}

 

 

 

Exemplo no Visual Basic:

 

Private Sub MicrogeniosUsbHID_Port1_microgeniosDeviceUsbHID_Encontrado(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MicrogeniosUsbHID_Port1.microgeniosDeviceUsbHID_Encontrado

Label1.Text = "Algum dispositivo HID foi encontrado na USB"

 

 

End Sub


Method to send data to the Microcontroller.

Exemplo no Visual C#:

(..)

if (this.microgeniosUsbHID_Port1.DeviceUsbHID != null) //verifica se existe conexão USB

{

this.microgeniosUsbHID_Port1.DeviceUsbHID.EnviarDados(DataWrite); //envia buffer DataWrite

}

 

 

 

Exemplo no Visual Basic:

(..)

If Me.MicrogeniosUsbHID_Port1.DeviceUsbHID IsNot Nothing Then

Me.MicrogeniosUsbHID_Port1.DeviceUsbHID.EnviarDados(DataWrite) 'envia buffer DataWrite

 

 

End If


 

Esta função será executada toda vez que chegar dados na porta USB do PC enviado pelo Microcontrolador.

Exemplo no Visual C#:

private void microgeniosUsbHID_Port1_microgeniosDeviceUsbHID_ReceberDados(object sender, DataRecievedEventArgs args)

{

if (InvokeRequired)

{

try

{

Invoke(new DataRecievedEventHandler(microgeniosUsbHID_Port1_microgeniosDeviceUsbHID_ReceberDados), new object[] { sender, args });

}

catch

{

(...)// exception

}

}

else

{

//Leitura dos dados USB enviado pelo Microcontrolador

if (args.data[0] == 1) {...}; //trata dados...

if (args.data[1] == 1) {...};

if (args.data[2] == 1) {...};

}

}

 

 

 

Exemplo no Visual Basic:

Private Sub microgeniosUsbHID_Port1_microgeniosDeviceUsbHID_ReceberDados(ByVal sender As Object, ByVal args As microgeniosUsbHID.DataRecievedEventArgs) Handles MicrogeniosUsbHID_Port1.microgeniosDeviceUsbHID_ReceberDados

If InvokeRequired Then

Try

Invoke(New DataRecievedEventHandler(AddressOf microgeniosUsbHID_Port1_microgeniosDeviceUsbHID_ReceberDados), New Object() {sender, args})

Catch ex As Exception

(...)

End Try

Else

'Leitura dos dados USB enviado pelo Microcontrolador

If (args.data(0)) Then (...) End If

If (args.data(1)) Then (...) End If

If (args.data(2)) Then (...) End If

End If

End Sub

 

 

 

 

Comments (3111)

Leave a comment

You must be logged in to post a comment.

WindForms USB Control

Connect on the USB your microcontroller projects using the component USBHidClass with Visual C# or Visual Basic.NET. USBHidClass it´s a Windows Form component compatible with FrameWork 2.0, 3.5, 4.0, 4.5 and + with all support for Visual C# and Visual Basic.NET 2005, 2008 and 2010/2012/2013 and new 2015!.

USBHidNetClass, What does this do?

Mostly of the programmers has a big problem to develop projects with USB communication. USBHidNetClass it´s a library created on the platform .NET Microsoft with access to the API of the OS Windows and allows it to be integrated into the Visual C # and VisualBasic with a simple Windows Form component (it will be integrated on the ToolBox of the Visual Studio), which makes the creation of projects easier, allowing novice programmers to develop their projects shortly. Note: HID is the class for the native Windows control of the mouse, joystick and keyboards

Examples with C# | VB.NET

To facilitate the integration of the component on Visual Studio we offer programs examples in C# and VB.NET with microcontroller PIC18F4550 Microchip. The USBHidNetClass enables the quickly development of Graphical Interfaces with USB communication using the USB microcontrollers: PIC, dsPIC, AVR, ARM etc. Click here to see the examples.

Free Download USBHidNetClass

FREE DOWNLOAD
Free Download WindForms USB Control USBHidNetClass.

How To Buy?

To purchase you just have to click on the button “Buy Now” and make the payment via PayPal (international credit card). After the release of payment by the operator we will send by e-mail the USBHidNetClass component (on the dll format) and the user key + programs example. Note: it won’t be send the source code of the library. It will be on the dll format ready to use on Visual Studio.

License: To 01 end-user or developer:
U$45,00 (U.S. dollars)

License: To 10 end-user or developer::
U$65,00 (U.S. dollars)

License: To 100 end-user or developer::
U$85,00 (U.S. dollars)


License: UNLIMITED end-user or developer::
U$455,00 (U.S. dollars)

 


payment method Forma de Pagamento Microgenios' company is our Premium Partner.