Example #1
0
        /// <summary>
        /// Write data into device
        /// </summary>
        public bool Write(HIDReport report)
        {
            if (!m_isConnected)
            {
                return(false);
            }

            if (report.Length > m_outputReportLength)
            {
                throw new Exception("Report len must not exceed " +
                                    m_outputReportLength.ToString(CultureInfo.InvariantCulture) +
                                    " bytes");
            }

            try
            {
                m_oFile.Write(report.ToArray(), 0, report.Length);
                HandleDataSend(report);
            }
            catch
            {
                return(false);                // The device was removed!
            }

            return(true);
        }
Example #2
0
        public bool WriteFeature(HIDReport report)
        {
            if (!m_isConnected)
            {
                return(false);
            }

            try
            {
                //HidD_SetFeature(m_hHandle, report.ToArray(), report.Length);
            }
            catch
            {
                return(false); // The device was removed!
            }

            return(true);
        }
Example #3
0
 /// <summary>
 /// virtual handler for any action to be taken when data is received. Override to use.
 /// </summary>
 /// <param name="data">The input report that was received</param>
 protected virtual void HandleDataReceived(HIDReport report)
 {
     // Fire the event handler if assigned
     OnDataRecieved?.Invoke(this, report);
 }
Example #4
0
 /// <summary>
 /// Virtual handler for any action to be taken when a device is removed. Override to use.
 /// </summary>
 protected virtual void HandleDataSend(HIDReport report)
 {
     OnDataSend?.Invoke(this, report);
 }