예제 #1
0
        private void cmbDevices_DropDown(object sender, EventArgs e)
        {
            int i;
            int numDevices = ftdi.CreateDeviceList();

            FTDI.DeviceData data = new FTDI.DeviceData();

            cmbDevices.Items.Clear();
            for (i = 0; i < numDevices; i++)
            {
                ftdi.GetDeviceInfoDetail(i, ref data);
                cmbDevices.Items.Add(data.strSerialNo);
            }
        }
예제 #2
0
        // Retrieve an  entry in the device info list
        public unsafe bool GetDeviceInfoDetail(int iIndex, ref FTDI.DeviceData sDeviceData)
        {
            FT_STATUS ftStatus = FT_STATUS.FT_OTHER_ERROR;
            UInt32    u32Flag;
            UInt32    u32Type;
            UInt32    u32DeviceID;
            UInt32    u32LocationID;

            byte[]    abySerialNo    = new byte[256];
            byte[]    abyDescription = new byte[256];
            FT_HANDLE ftHandle;
            int       uCharsToNull = 0;

            fixed(byte *pbySerialNo = abySerialNo)
            fixed(byte *pbyDescription = abyDescription)
            ftStatus = FT_GetDeviceInfoDetail((uint)iIndex, &u32Flag, &u32Type, &u32DeviceID, &u32LocationID, pbySerialNo, pbyDescription, &ftHandle);

            if (ftStatus == FT_STATUS.FT_OK)
            {
                System.Text.Encoding enc = System.Text.Encoding.ASCII;


                sDeviceData.u32Flag       = u32Flag;
                sDeviceData.u32Type       = u32Type;
                sDeviceData.u32DeviceID   = u32DeviceID;
                sDeviceData.u32LocationID = u32LocationID;
                while (abySerialNo[uCharsToNull] != 0)
                {
                    uCharsToNull++;
                }
                sDeviceData.strSerialNo = enc.GetString(abySerialNo, 0, uCharsToNull);
                uCharsToNull            = 0;
                while (abyDescription[uCharsToNull] != 0)
                {
                    uCharsToNull++;
                }
                sDeviceData.strDescription = enc.GetString(abyDescription, 0, uCharsToNull);
                sDeviceData.handle         = ftHandle;
            }
            return(ftStatus == FT_STATUS.FT_OK);
        }