private void OpenDevice() { #if MONO usb_port = new USBWrapper_Posix(); usb_report_size = 64; #else usb_port = new USBWrapper_Win32(); usb_report_size = 65; #endif while (usb_fs == null) { usb_fs = usb_port.GetUSBHandle(usb_devicefile, usb_report_size); if (usb_fs == null) { if (this.verbose_mode > 0) { System.Console.WriteLine("No device"); } System.Threading.Thread.Sleep(5000); } else { if (this.verbose_mode > 0) { System.Console.WriteLine("USB device found"); } } } }
private void GetHandle() { usb_fs = null; usb_report_size = 32; /** prebuild ack and nack messages */ nack = new byte[usb_report_size]; ack = new byte[usb_report_size]; nack[0] = 0x2; nack[1] = 0x1; nack[2] = 0x15; ack[0] = 0x2; ack[1] = 0x1; ack[2] = 0x6; for (int i = 3; i < usb_report_size; i++) { nack[i] = 0; ack[i] = 0; } usb_port = new USBWrapper_HidSharp(); while (usb_fs == null) { usb_fs = usb_port.GetUSBHandle(usb_devicefile, usb_report_size); if (usb_fs == null) { if (this.verbose_mode > 0) { System.Console.WriteLine("No device"); } System.Threading.Thread.Sleep(5000); } else { if (this.verbose_mode > 0) { System.Console.WriteLine("USB device found"); } } } //AsyncRead(); }