public bool Connection() { try { string vid_str = VID; string pid_str = PID; //Supprime le 0x... vid_str = vid_str.Substring(2); pid_str = pid_str.Substring(2); usbPort.VendorId = Int32.Parse(vid_str, System.Globalization.NumberStyles.HexNumber); usbPort.ProductId = Int32.Parse(pid_str, System.Globalization.NumberStyles.HexNumber); //Test si le device est déjà connceté au démarrage de l'application usbPort.CheckDevicePresent(); Connected = true; GetNewValues(); } catch (Exception err) { Connected = false; if (debug > 0) { Console.WriteLine("Connection error : " + err.ToString()); } } return(Connected); }
public void Connect() { if (mConnected) { return; } mDevice.VendorId = mVendorID; mDevice.ProductId = mProductID; mDevice.CheckDevicePresent(); mDevice.SpecifiedDevice.DataRecieved += new DataRecievedEventHandler(this.SpecifiedDevice_DataRecieved); mConnected = true; }
public bool Open() { IsOpen = false; try { usbapi = new UsbHidPort(); usbapi.ProductId = 63; usbapi.VendorId = 1240; usbapi.OnSpecifiedDeviceArrived += usb_OnSpecifiedDeviceArrived; usbapi.OnSpecifiedDeviceRemoved += usb_OnSpecifiedDeviceRemoved; usbapi.OnDeviceArrived += usb_OnDeviceArrived; usbapi.OnDeviceRemoved += usb_OnDeviceRemoved; usbapi.OnDataRecieved += usb_OnDataRecieved; usbapi.OnDataSend += usb_OnDataSend; usbapi.CheckDevicePresent(); Refresh(); Thread.Sleep(500); } catch { } return(IsOpen); }
private void Form1_Load(object sender, EventArgs e) { try { string vid_str = VID; string pid_str = PID; //Supprime le 0x... vid_str = vid_str.Substring(2); pid_str = pid_str.Substring(2); usbPort.VendorId = Int32.Parse(vid_str, System.Globalization.NumberStyles.HexNumber); usbPort.ProductId = Int32.Parse(pid_str, System.Globalization.NumberStyles.HexNumber); //Test si le device est déjà connceté au démarrage de l'application usbPort.CheckDevicePresent(); } catch (Exception err) { MessageBox.Show(err.Message, "Configuration VID/PID", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void InitializeComponent() { usbPort.CheckDevicePresent(); }
private void CheckForDrumsTick(object sender, EventArgs e) { m_UsbDrum.CheckDevicePresent(); }