public void prepareEX() { USBDeviceList usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); CyUSBDevice MyDevice = usbDevices[0x04B4, 0x1003] as CyUSBDevice; if (MyDevice != null) { MyDevice.Reset(); Thread.Sleep(1000); MyDevice.ReConnect(); Thread.Sleep(1000); if (MyDevice.BulkInEndPt != null) { MyDevice.BulkInEndPt.Reset(); } if (MyDevice.BulkOutEndPt != null) { MyDevice.BulkInEndPt.TimeOut = 500; for (int i = 0; i < 640 * 480 * 2 / 512; i++) { int len = 512; byte[] buf = new byte[len]; if (false == MyDevice.BulkInEndPt.XferData(ref buf, ref len, true)) { ready = true; break; } } } } return; }
private void mitResetDevice_Click(object sender, RoutedEventArgs e) { if (MyDevice != null) { MyDevice.Reset(); mitResetDevice.IsEnabled = false; mitConfigDevice.IsEnabled = true; mitConfigDevice.Header = "_Config"; } else { MessageBox.Show("Please select the USB device", "Device ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }