91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.27MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-09-26
  • 語言: 其他
  • 標簽: lib??真實例子??

資源簡介

結(jié)合實際項目通過libusb 讀取電路板中的數(shù)據(jù)信息。

資源截圖

代碼片段和文件信息

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;
using?System.Windows.Forms.DataVisualization.Charting;
using?LibUsbDotNet;
using?LibUsbDotNet.Main;
using?LibUsbDotNet.Info;
using?System.Threading;
using?System.Collections.objectModel;
using?LibUsbDotNet.DeviceNotify;
using?System.IO;
using?System.Drawing.Drawing2D;
using?System.Runtime.InteropServices;
using?USBHIDControl;

namespace?alt
{
????public?partial?class?Form1?:?Form
????{
????????private?DateTime?LastDataEventDate?=?DateTime.Now;
????????private?int?pId?=?0x5750;
????????private?int?vId?=?0x0483;
????????private?UsbDevice?usbDevice?=?null;
????????private?UsbDeviceFinder?usbFinder?=?null;
????????public?UsbEndpointWriter?writer?=?null;
????????public?UsbEndpointReader?reader?=?null;
????????IDeviceNotifier?deviceNotifier?=?LibUsbDotNet.DeviceNotify.DeviceNotifier.OpenDeviceNotifier();
????????delegate?void?SetTextCallback(string?text);//安全線程訪問txtReadInt的值
????????delegate?void?SetUsbCallback(byte[]?b);
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
?
??
????????
??????
????????/**
?????????*??往設(shè)備發(fā)送信息
?????????*?*/
????????private?void?func_writeToRead(string?msg)
????????{

????????????ErrorCode?ec?=?ErrorCode.None;

????????????try
????????????{
????????????????if?(usbDevice?==?null)
????????????????{
????????????????????FindAndOpenUSB();
????????????????}
????????????????//打開并讀取read?endpoint1
????????????????UsbEndpointReader?reader?=?usbDevice.OpenEndpointReader(ReadEndpointID.Ep02);
????????????????UsbEndpointWriter?writer?=?usbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);

????????????????if?(!String.IsNullOrEmpty(msg))
????????????????{
????????????????????reader.DataReceived?+=?(OnRxEndPointData);
????????????????????reader.DataReceivedEnabled?=?true;

????????????????????int?bytesWritten;
????????????????????ec?=?writer.Write(Encoding.Default.GetBytes(msg)?2000?out?bytesWritten);
????????????????????if?(ec?!=?ErrorCode.None)?{?showMessage(“讀取失敗,重新插拔設(shè)備!“);?}

????????????????????LastDataEventDate?=?DateTime.Now;
????????????????????//如果長時間內(nèi)為收到數(shù)據(jù),則結(jié)束
????????????????????while?((DateTime.Now?-?LastDataEventDate).TotalMilliseconds?????????????????????{

????????????????????}

????????????????????reader.DataReceivedEnabled?=?false;
????????????????????reader.DataReceived?-=?(OnRxEndPointData);

????????????????????Console.WriteLine(“\r\n?Done!?\r\n“);
????????????????}
????????????????else
????????????????????throw?new?Exception(“Nothing?to?do.“);

????????????}
????????????catch?(System.Exception?ex)
????????????{
????????????????Console.WriteLine();
????????????????Console.WriteLine((ec?!=?ErrorCode.None???ec?+?“:“?:?string.Empty)?+?ex.Message);
????????????}
????????????//讀取數(shù)據(jù)后執(zhí)行
????????????finally
????????????{

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????6872??2018-10-12?08:52??Form1.cs

?????文件?????150016??2018-09-12?15:27??LibUsbDotNet.dll

?????文件????2323232??2018-09-12?15:20??LibUsbDotNet_Setup.2.2.8.rar

?????文件????????178??2018-10-12?08:54??說明.txt

-----------?---------??----------?-----??----

??????????????2480298????????????????????4


評論

共有 條評論