nanoFramework.System.Device.UsbStream 1.0.62

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.System.Device.UsbStream --version 1.0.62                
NuGet\Install-Package nanoFramework.System.Device.UsbStream -Version 1.0.62                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.System.Device.UsbStream" Version="1.0.62" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.System.Device.UsbStream --version 1.0.62                
#r "nuget: nanoFramework.System.Device.UsbStream, 1.0.62"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install nanoFramework.System.Device.UsbStream as a Cake Addin
#addin nuget:?package=nanoFramework.System.Device.UsbStream&version=1.0.62

// Install nanoFramework.System.Device.UsbStream as a Cake Tool
#tool nuget:?package=nanoFramework.System.Device.UsbStream&version=1.0.62                

Quality Gate Status Reliability Rating NuGet #yourfirstpr Discord

nanoFramework logo


Welcome to the .NET nanoFramework USB Client repository

Build status

Component Build Status NuGet Package
System.Device.UsbStream Build Status NuGet

Usage

USB Stream

UsbStream class provides a seamless interface to a stream that can read from and write to an USB Device that's enumerated as a WinUSB device. This allows shipping your .NET nanoFramework device as an USB device without the need for any INF file or specific driver instalation.

Creating an UsbStream

Creating an UsbStream requries 2 parameters: a Guid that will be used as the Device Interface ID and a string which will be used as the device description for the USB device.

private static Guid deviceInterfaceId = new Guid("9e48651c-fa68-4b39-8731-1ee84659aac5");
private static string deviceDescription = "nanoDevice";

// create USB Stream
var usbStream = UsbClient.CreateUsbStream(deviceInterfaceId, deviceDescription);
Writing to the UsbStream

To write to the UsbStream just call the Write() method just like any other .NET stream. Like this:

// buffer with dummy data 
var bufer = new byte[] { 1, 2, 3 };

usbStream.Write(bufer, 0, bufer.Length);

Debug hints

USB can be hard. Be prepared for that! There are a number of issues that are prone to cause frustration. Follows some (hopefully valuable) advice.

  • If you need to debug device enumeration issues and check what's being passed from the devices, install a tool such as USB Device Tree Viewer from Uwe Sieber. With it you can peruse into every bit of detail about USB device, their interfaces, end points, strings, etc.

  • Another great tool is USBDeview from NirSoft. This tool lists all USB devices that currently connected to your computer, as well as all USB devices that you previously used. Extended information is displayed for each USB device. It's possible to uninstall/disable and enable USB devices from the tool.

  • Windows caches enumeration of USB devices. What's the problem with that? During development, if the enumeration fails at some point, the device most likely will be marked as being enumerated and on the next connection Windows won't do it again. This can cause the enumeration data to be wrong or incomplete. To fix this and truly force the enumeration to happen from scratch, make sure that:

    1. Delete the device from the Device Manager.

    2. Delete the entry from the enumeration cache in Registry. This lives at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\vvvvpppprrrr

      Where vvvv is the vendor id, pppp is the PID and rrrr is the device release number.

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.

Credits

The list of contributors to this project can be found at CONTRIBUTORS.

License

The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on nanoFramework.System.Device.UsbStream:

Repository Stars
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
Version Downloads Last updated
1.0.75 92 2/4/2025
1.0.74 61 2/4/2025
1.0.73 79 1/31/2025
1.0.68 127 1/7/2025
1.0.62 346 5/31/2024
1.0.59 469 11/9/2023
1.0.56 139 11/9/2023
1.0.46 453 12/28/2022
1.0.43 309 12/27/2022
1.0.40 488 11/10/2022
1.0.38 343 11/10/2022
1.0.36 354 11/8/2022
1.0.34 349 11/7/2022
1.0.32 406 10/27/2022
1.0.30 435 10/26/2022
1.0.28 397 10/25/2022
1.0.26 435 10/24/2022
1.0.24 429 10/23/2022
1.0.22 400 10/14/2022
1.0.20 431 10/14/2022
1.0.18 429 10/12/2022
1.0.16 423 10/11/2022
1.0.14 434 10/11/2022
1.0.12 423 10/11/2022
1.0.7 424 10/4/2022
1.0.5 414 10/4/2022