Exemplo n.º 1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            HwndSource source = PresentationSource.FromVisual(this) as HwndSource;

            source.AddHook(WndProc);

            //USB Connection
            usb.RegisterHandle(source.Handle);
        }
Exemplo n.º 2
0
        private void Begin()
        {
            _usb = new UsbLibrary.UsbHidPort();
            _usb.OnSpecifiedDeviceRemoved += new EventHandler(USB_OnSpecifiedDeviceRemoved);
            _usb.OnDataRecieved += new DataRecievedEventHandler(USB_OnDataRecieved);
            _usb.OnSpecifiedDeviceArrived += new EventHandler(USB_OnSpecifiedDeviceArrived);
            _usb.VID_List[0] = 7476;
            _usb.PID_List[0] = 13; //18
            _usb.ID_List_Cnt = 1;
            _usb.RegisterHandle(Process.GetCurrentProcess().MainWindowHandle);

            _timer = new Timer(50);
            _timer.Elapsed += TimerOnElapsed;
            _timer.Start();

            for (; ;) //ever
            {
            }
        }
        public void Connect()
        {
            var container = new Container();
            _usb = new UsbHidPort(container);
            _usb.ProductId = 0;
            _usb.VendorId = 0;

            _usb.SpecifiedDevice = null;
            _usb.OnSpecifiedDeviceRemoved += OnSpecifiedDeviceRemoved;
            _usb.OnDataRecieved += OnDataRecieved;
            _usb.OnSpecifiedDeviceArrived += OnSpecifiedDeviceArrived;

            _usb.VID_List[0] = 2689;
            _usb.PID_List[0] = 1793;
            _usb.VID_List[1] = 8483;
            _usb.PID_List[1] = 4112;
            _usb.ID_List_Cnt = 2;
            _usb.RegisterHandle(Process.GetCurrentProcess().MainWindowHandle);
            _isConnected = true;
        }