Example #1
0
 protected void UnloadDrivers()
 {
     if (_uirtHandle != USBUIRTAPI.UUPTR_EMPTY && _uirtHandle != USBUIRTAPI.UUPTR_NULL)
     {
         USBUIRTAPI.UUIRTClose(_uirtHandle);
         _uirtHandle = USBUIRTAPI.UUPTR_NULL;
     }
 }
Example #2
0
        /// <summary>
        /// Transmit a single IR command
        /// </summary>
        /// <param name="irCode"></param>
        /// <param name="codeFormat"></param>
        /// <param name="repeatCount"></param>
        public void Transmit(string irCode, int codeFormat, int repeatCount)
        {
            bool result = USBUIRTAPI.UUIRTTransmitIR(_uirtHandle,
                                                     irCode,      // IRCode
                                                     codeFormat,  // codeFormat
                                                     repeatCount, // repeatCount
                                                     0,           // inactivityWaitTime
                                                     IntPtr.Zero, // hEvent
                                                     0,           // reserved1
                                                     0            // reserved2
                                                     );

            if (!result)
            {
                _log.Error("USBUIRT: Unable to transmit code");
            }
            // System.Threading.Thread.Sleep(interCommandDelay);
        }
Example #3
0
        /// <summary>
        /// Opens the USB-UIRT driver
        /// </summary>
        /// <returns>true when successfully loaded</returns>
        protected bool LoadDrivers()
        {
            try
            {
                _uirtHandle = USBUIRTAPI.UUIRTOpen();

                if (_uirtHandle != USBUIRTAPI.UUPTR_EMPTY)
                {
                    _log.Info("USBUIRT:Open success:{0}", DriverVersion);
                }
                else
                {
                    _log.Error("USBUIRT:Unable to open USBUIRT driver");
                    _uirtHandle = USBUIRTAPI.UUPTR_NULL;
                    return(false);
                }

                //setup callack to receive IR messages
                //urcb = new USBUIRTAPI.UUIRTReceiveCallbackDelegate(this.USBUIRTReceiveCallback);
                //USBUIRTAPI.UUIRTSetReceiveCallback(UsbUirtHandle, urcb, 0);
                //RemoteCommandCallback = callback;
            }

            catch (DllNotFoundException e)
            {
                _log.Error("USBUIRT: Error loading driver uuirtdrv.dll : ", e.Message);
                _log.Error(e);
            }

            catch (Exception e)
            {
                _log.Error("USBUIRT: Error opening driver uuirtdrv.dll : ", e.Message);
                _log.Error(e);
            }

            return(false);
        }