欢迎来到传世资源网!
加载中...
正在加载,请耐心等待...
本站为收藏、学习站,如有侵权,请联系管理员删除!

USBHID通信

介绍 评论 失效链接反馈

USBHID通信
from clipboard

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace USBHIDControl{ public partial class Form1 : Form { USBHID usbHID = null; public Form1() { InitializeComponent(); usbHID = new USBHID(); foreach (string device in usbHID.GetDeviceList()) list_UsbHID.Items.Add(device); usbHID.DataReceived = usbHID_DataReceived; usbHID.DeviceRemoved = usbHID_DeviceRemoved; } void usbHID_DeviceRemoved(object sender, EventArgs e) { report myRP = (report)e; if (InvokeRequired) { Invoke(new EventHandler(usbHID_DeviceRemoved), new object[] { sender, e }); } else { tb_information.Text = "设备连接"; } } void usbHID_DataReceived(object sender, EventArgs e) { report myRP = (report)e; if (InvokeRequired) { Invoke(new EventHandler(usbHID_DataReceived), new object[] { sender, e }); } else { tb_information.Text = "\r\n" USBHID.ByteToHexString(myRP.reportBuff); } } /// <summary> /// open USB HID /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_connect_Click(object sender, EventArgs e) { if (list_UsbHID.SelectedItem == null) { tb_information.Text = "\r\n vendorID和productID不能为空"; return; } if (usbHID.OpenUSBHid(list_UsbHID.SelectedItem.ToString())) tb_information.Text = "\r\n open success"; else tb_information.Text = "\r\n open fail"; } private void btn_send_Click(object sender, EventArgs e) { tb_information.Text ="\r\n w: " usbHID.WriteUSBHID(tb_send.Text); } private void btn_clear_Click(object sender, EventArgs e) { tb_information.Text = ""; } }}

下载声明:

本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。
相关推荐:

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复