예제 #1
0
파일: Form1.cs 프로젝트: salehjg/AINGF2
        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;
        }
 public bool ReConnect()
 {
     MyUsb = MyUsbList[0x04B4, 0x1004] as CyUSBDevice;
     if (MyUsb != null)
     {
         MyUsb.ReConnect();
         MyUsb = MyUsbList[0x04B4, 0x00F1] as CyUSBDevice;
     }
     else
     {
         MyUsb = MyUsbList[0x04B4, 0x00F1] as CyUSBDevice;
     }
     if (MyUsb != null)
     {
         MyOutPoint     = MyUsb.EndPointOf(0x02);
         MyInPoint      = MyUsb.EndPointOf(0x86);
         MyControlPoint = MyUsb.ControlEndPt;
         Reset();
         return(true);
     }
     else
     {
         return(false);
     }
 }