C#调试USB程序

本文介绍了如何在C#中利用开源库LibUsbDotNet调试USB程序。通过示例代码展示了如何连接、读写USB设备,并实现设备变更监听,以便于操作和管理USB设备。
摘要由CSDN通过智能技术生成
最近在用C#调试USB程序,libusb源码是C语言的,C#用起来不方便,偶然在网上看到了LibUsbDotNet,这是开源的项目,下载后参考Example,用起来非常方便。



LibUsbDotNet下载 - http://sourceforge.net/projects/libusbdotnet/



我写的示例工程(附件传不上来,只能直接贴代码了^_^) - Enjoy...





using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Threading;



using LibUsbDotNet;

using LibUsbDotNet.Info;

using LibUsbDotNet.Main;

using LibUsbDotNet.DeviceNotify;





using LibUsbDotNet.LibUsb;







namespace USBLib

{

public partial class Form1 : Form

{

const int myPID = 0x050F; //产品ID

const int myVID = 0x0425; //供应商ID



public static UsbDevice MyUsbDevice;//USB设备

public static DeviceNotifier DeviceNotifier = new DeviceNotifier();//设备变化通知函数

public static UsbEndpointWriter writer = null;

public static UsbEndpointReader reader = null;



delegate void SetTextCallback(string text);//安全线程访问txtReadInt的值





Boolean EnbaleInt = false;//是否使用中断接收



public Form1(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值