USB and C# in .NET Micro Framework (NETMF)

The .NET Micro Framework implements a USB device (also known as USB client) that enables your device to act as a USB device, like a mouse, keyboard, or printer. For example, a .NET Micro Framework device can function as a mouse, and after connecting to a PC can provide mouse coordinates.

Does .NET Micro Framework supports the USB host?

The USB host feature that allows you to connect other USB devices to your .NET Micro Framework device is not supported. However, .NET Micro Framework devices from GHI Electronics (www.ghielectronics.com) are all capable of USB host through a proprietary implemented USB host stack.

The GHI Embedded Master SDK includes a mouse sample, along with other samples, that shows how to make your device available as a virtual COM port when connected to a PC.

An extensive article that shows how to use a USB device feature with the .NET Micro Framework be found at www.guruce.com/blogpost/communicating-with-your-microframework-application-over-usb. It also covers how to write custom drivers for your USB devices.

USB 3.0 and C#

USB 3.0 defines a new, 10x faster SuperSpeed bus (a bus speed of 5 Gbps) that operates parallel to the USB 2.0 bus.

How to use USB device in C#?

To use the USB device in your C# application, you can use libusb (from www.libusb.org) which is a library that gives user level applications uniform access to USB devices across many different operating systems.

There is also another library called LibUsbDotNet (from libusbdotnet.sourceforge.net) that is a .NET C# USB library for WinUsb, libusb-win32, and Linux libusb v1.x developers. All basic USB device functionality can be performed through common device classes allowing you to write OS and driver independent code.

LibUsbDotNet is a development tool written for .NET software developers who need a fast and easy way to create a custom USB driver solution for Unix-like and Windows platforms. LibUsbDotNet 2.1.0 and above supports the genuine libusb-win32 driver package. However, access to basic device information via the Windows registry is not available. LibUsbDotNet features full support for WinUSB and extended kernel level support for libusb-win32. It also allows common device classes a single code base to support multiple drivers and platforms, and includes a wizard utility for generating USB installation packages and removing devices.
LibUsbDotNet also features device discovery using either of the following criteria: VendorID or ProductID, Device Interface GUID, Revision Code, and Serial Number.

Copyright © All Rights Reserved - C# Learners