USB und MONO

USB und MONO

SharpUSBLib ist eine Wrapper-Klasse für libusb, die unter Ubuntu bereits installiert ist.


> lsusb|grep FT232
Bus 004 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

Das Mono-Programm

using System;

using ICSharpCode.USBlib;

namespace optischeMaus

{

class MainClass

{

public static void Main (string[] args)

{

foreach (Bus bus in Bus.Busses) {

Console.WriteLine(bus);

foreach (Descriptor descriptor in bus.Descriptors) {

Console.WriteLine("\t" + descriptor);

try {

using (Device device = descriptor.OpenDevice()) {

Console.WriteLine("\t\t Product: " + device.Product);

Console.WriteLine("\t\tManufacturer: " + device.Manufacturer);

Console.WriteLine();

}

} catch (UsbException e) {

Console.WriteLine("Got Exception : " + e);

}

}

}

}

}

}

Führt zu folgendem Output

[Bus: DirectoryName = 004]

	[Descriptor: DescriptorType = Device, DeviceClass = PerInterface, FileName = 004, VendorId=0x403, ProductId=0x6001]

Got Exception : UsbException: Unable to fetch manufacturer string.

Kner 2011 /home/roland/Dropbox/home/news.Mono.odt 1/1