Ejemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="callback"></param>
    private USBUIRT(OnRemoteCommand callback)
    {
      try
      {
        Log.Info("USBUIRT:Open");
        _commandsLearned = new Hashtable();
        _jumpToCommands = new Hashtable();
        CreateJumpToCommands();

        _usbUirtHandle = UUIRTOpen();

        if (_usbUirtHandle != _empty)
        {
          IsUsbUirtLoaded = true;
          Log.Info("USBUIRT:Open success:{0}", GetVersions());
        }
        else
        {
          Log.Info("USBUIRT:Unable to open USBUIRT driver");
        }

        if (IsUsbUirtLoaded)
        {
          Initialize();
          //setup callback to receive IR messages
          _urcb = UUIRTReceiveCallback;
          UUIRTSetReceiveCallback(_usbUirtHandle, _urcb, 0);
          RemoteCommandCallback = callback;
        }
      }

      catch (DllNotFoundException)
      {
        //most users don't have the dll on their system so will get a exception here
        Log.Info("USBUIRT:uuirtdrv.dll not found");
      }
      catch (Exception)
      {
        //most users don't have the dll on their system so will get a exception here
      }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public bool Reconnect()
    {
      try
      {
        IsUsbUirtLoaded = false;
        Log.Info("USBUIRT:Re-connecting");

        if (_usbUirtHandle == IntPtr.Zero || _usbUirtHandle == _empty)
        {
          _usbUirtHandle = UUIRTOpen();
          IsUsbUirtLoaded = IsUsbUirtConnected;
        }
        else
        {
          // Release existing handle...
          UUIRTClose(_usbUirtHandle);
          _usbUirtHandle = IntPtr.Zero;
          _usbUirtHandle = UUIRTOpen();
          IsUsbUirtLoaded = IsUsbUirtConnected;
        }

        if (IsUsbUirtLoaded)
        {
          Initialize();
          _urcb = UUIRTReceiveCallback;
          UUIRTSetReceiveCallback(_usbUirtHandle, _urcb, 0);
        }
        else
        {
          Log.Info("USBUIRT:Unable to open USBUIRT driver");
        }
      }

      catch (DllNotFoundException)
      {
        // most users don't have the dll on their system so will get a exception here
        Log.Info("USBUIRT:uuirtdrv.dll not found");
      }

      catch (Exception)
      {
        // most users don't have the dll on their system so will get a exception here
      }

      return IsUsbUirtLoaded;
    }
Ejemplo n.º 3
0
 private static extern bool UUIRTSetReceiveCallback(IntPtr hHandle, UUIRTReceiveCallbackDelegate receiveProc, int none);
Ejemplo n.º 4
0
 private static extern bool UUIRTSetReceiveCallback(
     IntPtr hHandle,
     UUIRTReceiveCallbackDelegate receiveProc,
     int none);