0 purchases
dart usb
dart_usb #
dart library for obtaining USB interface information
Getting Started #
dart_usb: any
copied to clipboard
init #
void main(){
initUsbLibrary();
}
copied to clipboard
Api #
get usb list
List<UsbInfo> usbList = await getUsbInfos();
// print
for (var element in usbList) {
print(element.vendorId);
print(element.productId);
}
copied to clipboard
get usb name
Future<void> printName(UsbInfo usbInfo) async {
final name = await usbInfo.readUsbName();
print(name.productName);
print(name.manufacturerName);
print(name.serialNumber);
}
copied to clipboard
write data
Future<void> writeData(UsbInfo info) async {
UsbHandle handle = await info.open();
handle.writeData(
endpoint: 3, buf: "hello world".codeUnits, timeout: BigInt.from(1000));
}
copied to clipboard
listen #
void listenData() {
// 500 mills
listenUsbEventHandle(sleep: BigInt.from(500)).listen(
(event) {
print('usb devices : ${event}');
},
);
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.