C#怎样运用LibUsbDotNet完成USB通讯的示例详解【C#.Net教程】,LibUsbDotNet,csharp,.net
作者:搜教程发布时间:2019-11-27分类:.Net教程浏览:39评论:0
导读:网上C#USB通讯的材料比较少,基本上都是基于LibUsbDotNet和CyUsb,关于打印机装备的另有一个OPOS。本篇文章基于LibUsbDotNet。 ...
网上C#USB通讯的材料比较少, 基本上都是基于LibUsbDotNet 和 CyUsb, 关于打印机装备的另有一个OPOS。
本篇文章基于LibUsbDotNet。
1. 下载并装置 LibUsbDotNet 装置文件。
2. 运转Filter Wizard, Install a device filter。 装置须要通讯的usb装备。
3. 建一个简朴的控制台项目,举行测试, 下图为打印须要通讯装备的信息。
相干代码:
援用
using LibUsbDotNet; using LibUsbDotNet.Main; using LibUsbDotNet.Info;
PrintUsbInfo
public static void PrintUsbInfo() { UsbDevice usbDevice = null; UsbRegDeviceList allDevices = UsbDevice.AllDevices; Console.WriteLine("Found {0} devices", allDevices.Count); foreach (UsbRegistry usbRegistry in allDevices) { Console.WriteLine("Got device: {0}\r\n", usbRegistry.FullName); if (usbRegistry.Open(out usbDevice)) { Console.WriteLine("Device Information\r\n------------------"); Console.WriteLine("{0}", usbDevice.Info.ToString()); Console.WriteLine("VID & PID: {0} {1}", usbDevice.Info.Descriptor.VendorID, usbDevice.Info.Descriptor.ProductID); Console.WriteLine("\r\nDevice configuration\r\n--------------------"); foreach (UsbConfigInfo usbConfigInfo in usbDevice.Configs) { Console.WriteLine("{0}", usbConfigInfo.ToString()); Console.WriteLine("\r\nDevice interface list\r\n---------------------"); ReadOnlyCollection<UsbInterfaceInfo> interfaceList = usbConfigInfo.InterfaceInfoList; foreach (UsbInterfaceInfo usbInterfaceInfo in interfaceList) { Console.WriteLine("{0}", usbInterfaceInfo.ToString()); Console.WriteLine("\r\nDevice endpoint list\r\n--------------------"); ReadOnlyCollection<UsbEndpointInfo> endpointList = usbInterfaceInfo.EndpointInfoList; foreach (UsbEndpointInfo usbEndpointInfo in endpointList) { Console.WriteLine("{0}", usbEndpointInfo.ToString()); } } } usbDevice.Close(); } Console.WriteLine("\r\n----- Device information finished -----\r\n"); } }
挪用
public static void Main(string[] args) { PrintUsbInfo(); // Wait for user input.. Console.ReadKey(); }
以上就是C#怎样运用LibUsbDotNet完成USB通讯的示例详解的细致内容,更多请关注ki4网别的相干文章!
相关推荐
- mysql装置后.net顺序运转失足怎样处理【MySQL教程】,mysql,.net,运行
- .net读写xml文档详解【XML教程】,.net,xml
- .net和c#有什么区别【C#.Net教程】,.net,c#
- C#中VB.NET给Word文档增加/打消书签的实例【C#.Net教程】,VB.NET,csharp,Word
- C#怎样完成loading提醒控件简朴的实例【C#.Net教程】,loading,csharp,.net
- C#怎样完成增加和修正以及删除PDF书签的要领引见【C#.Net教程】,csharp,.net,以及
- asp .net 面试题及答案分享【C#.Net教程】,.net,自己,整理,问题,面试
- Memcached在.net中的运用【C#.Net教程】,Memcached,.net
- .net是什么言语 视频【C#.Net教程】,.net
- .net core和.net区分【C#.Net教程】,.net
你 发表评论:
欢迎- .Net教程排行
-
- 1案例分享c++ map的运用和 查找机能测试【C#.Net教程】,性能,map,c++
- 2c#怎样运用?c#的基础语法【C#.Net教程】,c#,关键字
- 3细致引见C# string花样的日期时候字符串转为DateTime范例的要领【C#.Net教程】,C#,string,DateTime
- 4详解ASP.NET中衔接数据库设置要领【C#.Net教程】,ASP.NET,数据库,配置
- 5C# DataSet机能最好实践【C#.Net教程】,C#,DataSet
- 6.net和c#有什么区别【C#.Net教程】,.net,c#
- 7C#_挪用封装的一个类完成导出Excel表格的功用【C#.Net教程】,C# Excel表格
- 8asp .net 面试题及答案分享【C#.Net教程】,.net,自己,整理,问题,面试
- 9让WebAPI 返回JSON花样的数据实例教程【C#.Net教程】,javascript,WebAPI,JSON,api,web,搭建,返回
- 最新文章
- 广而告之