public bool OpenDevice(ref BuzzHandsetDevice oDevice, int nVid, int nPid) { oDevice = BuzzHandsetDevice.FindBuzzHandset(nVid, nPid); if (oDevice != null) // did we find it? { // Yes! So wire into its events and update the UI oDevice.OnReadBuffer += new BuzzReadBufferEventHandler(OnGetReadBuffer); oDevice.OnDeviceRemoved += new EventHandler(oDevice_OnDeviceRemoved); return(true); } else { return(false); } }
public void WriteData(ref BuzzHandsetDevice oDevice, Byte[] writebuffer) { if (oDevice != null) // did we find it? { if (writebuffer.Length >= oDevice.OutputReportLength - 1) { oDevice.WriteReport(writebuffer); } else { Console.WriteLine(String.Format("请输入 {0} 个数据", oDevice.OutputReportLength - 1)); } } else { Console.WriteLine(String.Format("设备未找到!")); } }