示例#1
0
文件: AD9958.cs 项目: labJunky/DDS
        /// <summary>
        /// Create a ADD9958 by looking up a specific connected device by serial number.
        /// </summary>
        /// <param name="DeviceNumber">Device number.</param>
        public AD9958(string SerialNumber)
        {
            // A list of the serial numbers of all currently connected
            // boards is already implemented in CyLabviewHelper, so we are going to use that one
            CyLabviewHelper helper        = new CyLabviewHelper();
            List <string>   serialNumbers = helper.ConnectedDDSBoards();

            // Find device number by serial
            int  deviceNumber = 0;
            bool found        = false;

            for (int i = 0; i < serialNumbers.Count; i++)
            {
                if (String.Equals(SerialNumber, serialNumbers[i], StringComparison.CurrentCultureIgnoreCase))
                {
                    found        = true;
                    deviceNumber = i;
                    break;
                }
            }

            // Check whether the serial number was found, if not then throw exception
            // Otherwise the device with deviceNumber 0 would be returned.
            if (!found)
            {
                throw new System.ArgumentException("Invalid serial number, no such device connected", "SerialNumber");
            }

            USBDeviceList deviceList = new USBDeviceList(CyConst.DEVICES_CYUSB);

            device = (new DDSUSBChip(deviceList[deviceNumber] as CyUSBDevice));
            initializeAD9958();
        }
示例#2
0
        // ##############################################################################
        static private int Init(byte InterfaceNum)
        {
            int Result;

            // string s;
            // CyUSBDevice myDevice;

            try
            {
                usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            //myDevice = usbDevices[0x0BE7, 0x0006] as CyUSBDevice;
            //if (myDevice != null)
            //    s = myDevice.FriendlyName + " connected.";

            //Adding event handlers for device attachment and device removal
            //usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);  left here for reference
            //usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved);

            //The below function sets the device with particular VID and PId and searches for the device with the same VID and PID.
            Result = setDevice(InterfaceNum);

            return(Result);
        }
示例#3
0
文件: Form1.cs 项目: salehjg/AINGF2
        private void Form1_Load(object sender, EventArgs e)
        {
            string tmp_folder = "C:\\tmp\\AINGF_V2\\";

            try
            {
                if (!Directory.Exists(tmp_folder))
                {
                    Directory.CreateDirectory(tmp_folder);
                }
                string[] filePaths = Directory.GetFiles(tmp_folder);
                foreach (string filePath in filePaths)
                {
                    File.Delete(filePath);
                }
            }
            catch
            {
                MessageBox.Show("Temp Folder flush error.");
            }

            //Thread th1 = new Thread(new ThreadStart(prepareEX));
            //th1.Start();
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            MyDevice   = usbDevices[0x04B4, 0x1003] as CyUSBDevice;
        }
示例#4
0
        public Form1()
        {
            InitializeComponent();

            USBDeviceList usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            MyDevice = usbDevices[0] as CyUSBDevice;

            if (MyDevice != null)
            {
                CtrlEndPt = MyDevice.ControlEndPt;
            }
            else
            {
                labelCardStatus.Text = "No acquisition card was found";
                buttonStart.Enabled  = false;
            }

            resolutionCombo.SelectedIndex = 2;

            listView1.View      = View.Details;
            listView1.GridLines = true;

            listView1.Columns.Add("SN");
            listView1.Columns.Add("CH_A");
            listView1.Columns.Add("CH_B");
        }
示例#5
0
        public ESeekM280Api()

        {
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            handleException = new ExceptionCallback(ThreadException);

            Img_View = new Image_View(ImageView);

            SetDevice();

            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);

            this.bInitM280 = false;
            this.bSysBusy  = false;
        }
示例#6
0
文件: AD9958.cs 项目: labJunky/DDS
        /// <summary>
        /// Create a ADD9958 by looking up a specific connected device by number. This is not a particularly
        /// reliable method since the order of the devices depends on the order in which they have been plugged in
        /// </summary>
        /// <param name="DeviceNumber">Device number.</param>
        public AD9958(int DeviceNumber)
        {
            USBDeviceList deviceList = new USBDeviceList(CyConst.DEVICES_CYUSB);

            device = (new DDSUSBChip(deviceList[DeviceNumber] as CyUSBDevice));
            initializeAD9958();
        }
示例#7
0
        public bool ReadFWCommand(ref byte[] inBuffer)
        {
            bool retValue = false;

            try
            {
                int buffCnt = 512;
                m_USBDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
                FxDev        = m_USBDevices[0] as CyUSBDevice;
                bulkEpt      = FxDev.BulkOutEndPt;
                retValue     = bulkEpt.XferData(ref inBuffer, ref buffCnt, false);

                Thread.Sleep(50);

                bulkEpt = FxDev.BulkInEndPt;
                if (bulkEpt != null)
                {
                    inBuffer = new byte[512];
                    retValue = bulkEpt.XferData(ref inBuffer, ref buffCnt, false);
                }
            }
            catch (Exception ex)
            {
                retValue = false;
            }
            return(retValue);
        }
示例#8
0
        public static bool Initialize()
        {
            bool retVal = true;

            m_USBDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            m_USBDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            m_USBDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);
            // Get the first device having VendorID == 0x04B4 and ProductID == 0x8613

            for (int i = 0; i < m_USBDevices.Count; i++)
            {
                m_CyUSBDevice = m_USBDevices[i] as CyFX3Device;
                if ((m_CyUSBDevice != null) && (m_CyUSBDevice.ProductID == 0x4720))
                {
                    //Fr.BootProgrammerDeviceFound();
                    break;
                }
            }
            //m_CyUSBDevice = m_USBDevices[0x04B4, 0x00F0] as CyUSBDevice;

            if (m_CyUSBDevice != null)
            {
                Status     = m_CyUSBDevice.FriendlyName + " connected.";
                m_EndPoint = m_CyUSBDevice.EndPoints[0];
            }
            else
            {
                m_EndPoint = null;
            }

            return(retVal);
        }
        static void GetNumberOfCards(ref USBDeviceList USBdevList)
        {
            //cout << endl << TE0300_ScanCards() << endl;
            int NumberOfCardAttached = TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_ScanCards(ref USBdevList);

            Console.WriteLine("The number of card is {0} ", NumberOfCardAttached);
        }
示例#10
0
 public bool findDevices()
 {
     this.usbDevices = new USBDeviceList((byte)1);
     this.usbDevices = this.listDevices();
     this.device     = this.usbDevices[this.vendorId, this.productId] as CyUSBDevice;
     return(true);
 }
示例#11
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;
        }
示例#12
0
        /// <summary>
        /// //This class contain all the function used as C# DLL
        /// //In the application you can call these functions in the following way
        /// //TE_USB_FX2.TE_USB_FX2.FunctionName()
        /// </summary>
        /// <returns></returns>

        /// <summary>
        /// 3.1   TE_USB_FX2_ScanCards()
        ///
        ///3.1.1   Declaration
        ///public static int TE_USB_FX2_ScanCards(ref USBDeviceList USBdevList)
        ///
        ///3.1.2   Function Call
        ///Your application program shall call this function like this:
        ///TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_ScanCards( ref USBdevList);
        ///
        ///3.1.3   Description
        ///This function takes (a null initialized or an already initialized) USB device list, (re-)creates a USB device list,
        ///searches for Trenz Electronic USB FX2 devices (Cypress driver derivative and VID = 0xbd0, PID=0x0300) devices and counts them.
        ///This function returns the number of Trenz Electronic USB FX2 devices attached to the USB bus of the host computer.
        ///
        ///3.1.4   Parameters
        ///1. ref USBDeviceList USBdevList
        ///USBDeviceList is a type defined in CyUSB.dll.
        ///USBdevList is the list of devices served by the CyUSB.sys driver (or a derivative like TE_USB_FX2.sys). This parameter is
        ///passed by reference (ref). See page 139-140 of CyUSB.NET.pdf (Cypress CyUSB .NET DLL Programmer's Reference).
        ///
        ///3.1.5   Return Value
        ///1. int : integer type.
        ///This function returns the number of USB devices attached to the host computer USB bus.
        /// </summary>
        /// <param name="USBdevList"></param>
        /// <returns = int></returns>

        public static int TE_USB_FX2_ScanCards(ref USBDeviceList USBdevList)
        {
            int    CardCount = 0;
            UInt16 PID       = 0x0000;
            UInt16 VID       = 0x0000;

            //Creation of a list of USB device that use the CYUSB.SYS driver
            USBdevList = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //USBdevList.Count : this parameter give the number of card that use CyUSB.sys and its derivative
            //(like TE_USB_FX2_64.sys and TE_USB_FX2_32.sys used by Trenz Electronic)

            //If exist at least an USB device that use the CYUSB.SYS driver,
            //I search and count the number of these devices that are of Trenz Electronic
            if (USBdevList.Count != 0)
            {
                // Look for a device having VID = 0bd0, PID = 0300
                foreach (USBDevice dev in USBdevList)
                {
                    PID = dev.ProductID;
                    VID = dev.VendorID;
                    if ((((PID == 0x0300) && (VID == 0x0bd0)) == true))
                    {
                        CardCount++;
                    }
                }
                USBdevList.Dispose();
                return(CardCount);
            }
            else
            {
                USBdevList.Dispose();
                return(0);
            }
        }
示例#13
0
        private CyFX3Device FindCyDevice(short vid, short pid)
        {
            CyFX3Device device = null;

            for (int i = 0; i < 5; i++)
            {
                usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
                if (0 != usbDevices.Count)
                {
                    break;
                }
            }

            if (0 == usbDevices.Count)
            {
                return(device);
            }

            usbDevices.DeviceRemoved += UsbDevices_DeviceRemoved;

            foreach (var item in usbDevices)
            {
                device = item as CyFX3Device;
                if (null != device)
                {
                    if (device.VendorID == vid && device.ProductID == pid)
                    {
                        return(device);
                    }
                }
            }
            return(device);
        }
示例#14
0
        public Form1()
        {
            bVista = (Environment.OSVersion.Version.Major == 6);

            // Required for Windows Form Designer support
            InitializeComponent();

            // Late setup of the CPU monitor - (Bails-out if in Vista)
            InitializePeformanceMonitor();

            // Hide the CPU load monitor if running in Windows Vista
            // Detecting the CPU load is a security violation in Vista
            CPULoadBox.Visible = !bVista;

            // Setup the callback routine for updating the UI
            updateUI = new UpdateUICallback(StatusUpdate);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Create the list of USB devices attached to the CyUSB3.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();
        }
示例#15
0
        public override bool Recover()
        {
            try
            {
                if (loopDevice != null)
                {
                    loopDevice.Dispose();
                    loopDevice = null;
                }

                if (usbDevices != null)
                {
                    usbDevices.DeviceRemoved  -= usbDevices_DeviceRemoved;
                    usbDevices.DeviceAttached -= usbDevices_DeviceAttached;
                    usbDevices.Dispose();
                    usbDevices = null;
                }
            }
            catch (System.Exception ex)
            {
            }


            inEndpoint  = null;
            outEndpoint = null;

            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            return(intDevice());
        }
示例#16
0
        public DeviceServer()
        {
            usbDeviceList = new USBDeviceList(CyConst.DEVICES_CYUSB);
            usbDeviceList.DeviceAttached += (s, evt) => SetDevice();
            usbDeviceList.DeviceRemoved  += (s, evt) => SetDevice();

            SetDevice();
        }
示例#17
0
 public void initDevice()
 {
     usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
     Console.WriteLine("usbDevices : " + usbDevices);
     //Adding event handlers for device attachment and device removal
     usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
     usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);
     setDevice();
 }
示例#18
0
        public void Start()
        {
            //string url = "http://localhost:9000";
            //server = WebApp.Start(url);

            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Setup the callback routine for Image view from M280 board
            Img_View = new Image_View(ImageView);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Associate handler with DataReceived Event - Sachin
            serPort.DataReceived += serPort_DataReceived;

            // Set Form name
            //ST: Comment as we move the code to service
            //this.Text = M280DEF.ProName + " - V" + M280DEF.SWver;


            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();

            //Initialize value
            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0)
            {
                //TODO: Write in event viewer
                //MessageBox.Show("Please check pixel size!");
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);

            //ST: Comment as we move the code to service
            //this.timCheckStatus.Tick += new EventHandler(CheckState_Tick);

            //ST: Comment as we move the code to service
            //this.timCheckStatus.Interval = M280DEF.StatusGetInterval;
            this.bInitM280 = false;
            this.bSysBusy  = false;

            openPort();
        }
示例#19
0
 public JLusb()
 {
     mUSBDevList = new USBDeviceList(CyConst.DEVICES_CYUSB);
     mUSBDevList.DeviceAttached += new EventHandler(mUSBDevList_Attached);
     mUSBDevList.DeviceRemoved += new EventHandler(mUSBDevList_Removed);
     if (mUSBDevList.Count > 0)
     {
         USBDetected();
     }
 } // end public JLusb()
示例#20
0
 public USBComm(int vid = 0x04b4, int pid = 0x00f1, int ppx = 16)
 {
     _USBVid = vid;
     _USBPid = pid;
     // Create the list of USB devices attached to the CyUSB.sys driver.
     _USBDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
     //Assign event handlers for device attachment and device removal.
     _USBDevices.DeviceAttached += _USBDevices_DeviceAttached;
     _USBDevices.DeviceRemoved  += _USBDevices_DeviceRemoved;
     //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
 }
示例#21
0
        public List <string> ConnectedDDSBoards()
        {
            List <string> connectedDDSBoards = new List <string>();
            USBDeviceList deviceList         = new USBDeviceList(CyConst.DEVICES_CYUSB);

            foreach (USBDevice device in deviceList)
            {
                connectedDDSBoards.Add(device.SerialNumber);
            }
            return(connectedDDSBoards);
        }
示例#22
0
文件: MainGUI.cs 项目: labJunky/DDS
        private void initializeDeviceList()
        {
            // Chose all USB Devices with the generic CyUSB driver
            // The argument of the constructor is a mask saying
            // just that.
            deviceList = new USBDeviceList(CyConst.DEVICES_CYUSB);
            ddsList    = new List <AD9958>();

            deviceList.DeviceAttached += new EventHandler(deviceAttached);
            deviceList.DeviceRemoved  += new EventHandler(deviceRemoved);
        }
示例#23
0
        /*
         * 3.3   TE_USB_FX2_Close()
         *
         * 3.3.1   Declaration
         * public static bool TE_USB_FX2_Close(ref USBDeviceList USBdevList)
         *
         * 3.3.2   Function Call
         * Your application program shall call this function like this:
         * TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_Close(ref USBdevList);
         *
         * 3.3.3   Description
         * This function takes an already initialized USB device list and disposes it.
         * Due to the fact that we are coding C# here, the device list can or cannot be erased; this is in the scope of the garbage
         * collector and it cannot be forced by the user. Sometimes it is erased instantly, some other times it is never erased,
         * until the user closes the application program that uses this data.
         * Use of TE_USB_FX2_Close() function is NOT recommended for new software projects. Users may use this function only just before
         * exiting their applications. If users use this function anywhere else, they shall
         * manage System.ObjectDisposedException exceptions (try – catch) or
         * avoid using disposed resources.
         * Note: USBdevList is disposed, not set to null.
         * try
         * {
         *   Application Code
         * }
         * catch (System.ObjectDisposedException)
         * {
         *   Console.WriteLine("TE_USB_FX2_USBDevice disposed: you have used the wrong procedure!");
         * }
         *
         * If you want to close the current USB device (card) without opening another one, you shall use TE_USB_FX2_Open() with a device
         * number (CardNumber) that certainly does not exist (e.g. CardNumber = 200, because there can be a maximum of 127 USB devices
         * connected to a single host controller). The reason of this behavior is due to the CyUSB.dll as explained by Cypress document
         * CyUSB.NET.pdf, pages 132-133 and pages 139-140: “You should never invoke the Dispose method of a USBDevice directly. Rather,
         * the appropriate technique is to call the Dispose method of the USBDeviceList object that contains the USBDevice objects”
         * This function differs from its homonym of the previous TE0300DLL.dll in that it does not close a Handle but disposes (erases)
         * all USB devices in the list.
         * A more intuitive name for this function would have been TE_USB_FX2_CloseAll or TE_USB_FX2_Dispose.
         *
         * 3.3.4   Parameters
         * 1. ref USBDeviceList USBdevList
         * USBDeviceList is a type defined in CyUSB.dll. USBdevList is the list of Trenz Electronic USB FX2 devices attached to the USB bus
         * host computer. This parameter is passed by reference (ref). See page 139-140 of CyUSB.NET.pdf (Cypress CyUSB .NET DLL Programmer's
         * Reference).
         * 3.3.5   Return Value
         * 1. bool : logical type
         * This function returns true if it is able to dispose the list. If unable to do so, it returns false.
         */

        /// <summary>
        /// //////
        /// </summary>
        /// <param name="USBdevList"></param>
        /// <returns></returns>

        public static bool TE_USB_FX2_Close(ref USBDeviceList USBdevList)
        {
            if (USBdevList != null)
            {
                USBdevList.Dispose();
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#24
0
        /// <summary>
        /// The main Form
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            //
            usbHIDDevices = new USBDeviceList(CyConst.DEVICES_HID);

            //Adding event handlers for device attachment and device removal
            usbHIDDevices.DeviceAttached += new EventHandler(usbHIDDevices_DeviceAttached);
            usbHIDDevices.DeviceRemoved  += new EventHandler(usbHIDDevices_DeviceRemoved);
            GetHidDevice();
        }
示例#25
0
        public void initDevice()
        {
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            if (usbDevices.Count != 0)
            {
                LogListBox.AppendText("Found " + usbDevices.Count + " USB Devices\n\n");
                setDevice();
            }

            //Adding event handlers for device attachment and device removal
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);
        }
示例#26
0
        public MainWindow()
        {
            InitializeComponent();

            // Create the list of USB devices attached to the CyUSB3.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            RefreshUsb();
        }
示例#27
0
        public Form1()
        {
            InitializeComponent();

            // For USB Camera
            // Create the list of USB devices attached to the CyUSB.sys driver.
            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);

            // Setup the callback routine for NullReference exception handling
            handleException = new ExceptionCallback(ThreadException);

            // Setup the callback routine for Image view from M280 board
            Img_View = new Image_View(ImageView);

            //Assign event handlers for device attachment and device removal.
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);

            //Associate handler with DataReceived Event - Sachin
            serPort.DataReceived += serPort_DataReceived;

            // Set Form name
            this.Text = M280DEF.ProName + " - V" + M280DEF.SWver;

            //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point
            SetDevice();

            //Initialize value
            if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2;
            }
            else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb)
            {
                TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3;
            }

            if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0)
            {
                MessageBox.Show("Please check pixel size!");
            }

            this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer);
            this.timCheckStatus.Tick    += new EventHandler(CheckState_Tick);
            this.timCheckStatus.Interval = M280DEF.StatusGetInterval;
            this.bInitM280 = false;
            this.bSysBusy  = false;
            openPort();
        }
 public Usb()
 {
     while (true)
     {
         MyUsbList = new USBDeviceList(CyConst.DEVICES_CYUSB);
         if (MyUsbList.Count == 0)
         {
             MessageBox.Show("把人家插上啦~");
         }
         else
         {
             break;
         }
     }
 }
示例#29
0
        public Form1()
        {
            InitializeComponent();                                                      // All components of the form are initialized
            Refresh();


            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);                      // All devices served by CyUSB.sys is added to the list usbDevices

            GetDevice();                                                                //  check if an EZ-USB device is already connected

            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);   // Eventhandler assigned to DeviceAttached
                                                                                        // to handle the event when a device is attached
            usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved);     // Eventhandler assigned to DeviceRemoved
                                                                                        // to handle the event when a device is removed
            //StatLabel1.Text = "Download the image file into FX3 using Cypress Control Center";
        }
示例#30
0
        private void InitCamera(int item)
        {
            BCam bcam = new BCam(this.usbDevices[item] as CyFX3Device);

            if (bcam.camComLayer.bootLoaderCurrentlyRunning)
            {
                Thread.Sleep(100);
                for (this.usbDevices = new USBDeviceList((byte)1); this.usbDevices.Count == 0; this.usbDevices = new USBDeviceList((byte)1))
                {
                    Thread.Sleep(100);
                }
                bcam = new BCam(this.usbDevices[item] as CyFX3Device);
            }
            bcam.Init(this.usbDevices[item] as CyUSBDevice);
            this.cameras.Add(bcam);
        }