public bool Connect(HidDevice hidDevice)
        {
            ReusltString result = new ReusltString();

            Hid.HID_RETURN hdrtn = oSp.OpenDevice(hidDevice.vID, hidDevice.pID, hidDevice.serial);

            if (hdrtn == Hid.HID_RETURN.SUCCESS)
            {
                bConnected = true;

                #region 消息通知
                result.Result  = true;
                result.message = "Connect Success!";
                RaiseEventConnectedState(result.Result);
                #endregion


                return(true);
            }

            bConnected = false;

            #region 消息通知
            result.Result  = false;
            result.message = "Device Connect Error";
            RaiseEventConnectedState(result.Result);

            #endregion
            return(false);
        }
 void HidDeviceRemoved(object sender, EventArgs e)
 {
     bConnected = false;
     #region 消息通知
     ReusltString result = new ReusltString();
     result.Result  = false;
     result.message = "Device Remove";
     RaiseEventConnectedState(result.Result);
     #endregion
     if (oSp != null)
     {
         oSp.CloseDevice();
     }
 }
        public void HidDataReceived(object sender, report e)
        {
            try
            {
                //第一个字节为数据长度,因为Device 的HID数据固定长度为64字节,取有效数据
                byte[] buf = new byte[e.reportBuff[0]];
                Array.Copy(e.reportBuff, 1, buf, 0, e.reportBuff[0]);

                //推送数据
                RaiseEventDataReceived(buf);
            }
            catch
            {
                #region 消息通知
                ReusltString result = new ReusltString();
                result.Result  = false;
                result.message = "Receive Error";
                RaiseEventConnectedState(result.Result);
                #endregion
            }
        }
 public ProtocolEventArg(ReusltString Rsp)
 {
     m_oData = Rsp;
 }