C#如何使用LibUsbDotNet实现USB通信的示例详解


当前第2页 返回上一页

引用  


1

2

3

using LibUsbDotNet;

using LibUsbDotNet.Main;

using LibUsbDotNet.Info;

PrintUsbInfo


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

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");

           }

       }

调用


1

2

3

4

5

6

7

public static void Main(string[] args)

        {

            PrintUsbInfo();

 

            // Wait for user input..

            Console.ReadKey();

        }

以上就是C#如何使用LibUsbDotNet实现USB通信的示例详解的详细内容!

返回前面的内容

相关阅读 >>

c#实现表格隔行换色

asp.net在网站根目录下创建文件夹

.net core配置与自动更新的实现方法_实用技巧

c#cs与bs数据请求交换

关于.net 3.5中的委托实例

c#中关于list<t>的并集与交集以及差集解析

c#中使用反射以及特性简化的实例代码

c#之fastsocket实战项目的示例分享

浅谈.net core开发日志中edge.js是什么?如何用?

.net mvc 使用ueditor上传图片

更多相关阅读请进入《LibUsbDotNet》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...