Skip to content

Commit 8a63f36

Browse files
committed
Add usage to README
1 parent c1cea06 commit 8a63f36

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,34 @@
1414

1515
## Usage
1616

17+
### USB Stream
18+
19+
`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.
20+
This allows shipping your .NET nanoFramework device as an USB device without the need for any INF file or specific driver instalation.
21+
22+
#### Creating an UsbStream
23+
24+
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.
25+
26+
```csharp
27+
private static Guid deviceInterfaceId = new Guid("9e48651c-fa68-4b39-8731-1ee84659aac5");
28+
private static string deviceDescription = "nanoDevice";
29+
30+
// create USB Stream
31+
var usbStream = UsbClient.CreateUsbStream(deviceInterfaceId, deviceDescription);
32+
```
33+
34+
#### Writing to the `UsbStream`
35+
36+
To write to the `UsbStream` just call the `Write()` method just like any other .NET stream. Like this:
37+
38+
```csharp
39+
// buffer with dummy data
40+
var bufer = new byte[] { 1, 2, 3 };
41+
42+
usbStream.Write(bufer, 0, bufer.Length);
43+
```
44+
1745
## Feedback and documentation
1846

1947
For documentation, providing feedback, issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home).

0 commit comments

Comments
 (0)