Exemple #1
0
        public AboutBox()
        {
            Version v;

            InitializeComponent();

            // Dialog title
            this.Text = String.Format("About {0}", AssemblyTitle);

            // Copyright
            this.labelCopyright.Text = AssemblyCopyright;

            // Application name
            v = new Version(AssemblyVersion);
            this.labelProductName.Text = String.Format("{0} v{1}.{2}.{3}", AssemblyProduct, v.Major, v.Minor, v.Build);

            // Assembly version
            v = Assembly.GetAssembly(typeof(QuickUsb)).GetName().Version;
            this.labelAssemblyVersion.Text = String.Format("QuickUSB Assembly v{0}.{1}.{2}", v.Major, v.Minor, v.Build);

            // DLL Version
            ushort major, minor, build;

            QuickUsb.GetDllVersion(out major, out minor, out build);
            this.labelDllVersion.Text = String.Format("QuickUSB DLL v{0}.{1}.{2}", major, minor, build);

            // Driver Version
            QuickUsb.GetDriverVersion(out major, out minor, out build);
            this.labelDriverVersion.Text = String.Format("QuickUSB Driver v{0}.{1}.{2}", major, minor, build);
        }
Exemple #2
0
        public void GetDriverVersionTest()
        {
            Version version         = null;
            Version versionExpected = new Version(2, 15, 0);
            bool    expected        = true;
            bool    actual;

            actual = QuickUsb.GetDriverVersion(out version);
            Assert.AreEqual(versionExpected, version);
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void GetDriverVersionTest1()
        {
            ushort majorVersion         = 0;
            ushort majorVersionExpected = 2;
            ushort minorVersion         = 0;
            ushort minorVersionExpected = 15;
            ushort buildVersion         = 0;
            ushort buildVersionExpected = 0;
            bool   expected             = true;
            bool   actual;

            actual = QuickUsb.GetDriverVersion(out majorVersion, out minorVersion, out buildVersion);
            Assert.AreEqual(majorVersionExpected, majorVersion);
            Assert.AreEqual(minorVersionExpected, minorVersion);
            Assert.AreEqual(buildVersionExpected, buildVersion);
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        private qusbListInfo CreateQLVI(QuickUsb qusb, string devName, out bool alreadyAdded)
        {
            // The name is only passed in when it can't be extract from the info parameter (probably bc the module is not connected)
            if (qusb == null)
            {
                alreadyAdded = false;
                return(null);
            }
            if (qusb.Name == null)
            {
                if (devName == null)
                {
                    throw new Exception("Unable to create item from QuickUSB - Too little information");
                }
            }
            else
            {
                if (devName != null && devName != qusb.Name)
                {
                    throw new Exception("Unable to create item from QuickUSB - Conflicting module information");
                }
                devName = qusb.Name;
            }

            // First, see if this module has already been added
            string[] arr;
            arr = new string[QuickUsbDict.Count];
            QuickUsbDict.Keys.CopyTo(arr, 0);
            for (int k = 0; k < arr.Length; ++k)
            {
                if (QuickUsbDict[arr[k]].qusb.Name == devName)
                {
                    alreadyAdded = true;
                    return(QuickUsbDict[arr[k]]);
                }
            }

            // Create a new qusbListInfo item
            var listInfo = new qusbListInfo();

            listInfo.qusb     = qusb;
            listInfo.attached = false;

            // Variables
            string newSerial;

            newSerial = listInfo.qusb.Serial;
            Version v;

            listInfo.lvi = new ListViewItem(new string[columnData.Count], 0, ModuleGroup);

            //  Read device descriptor
            USB_DEVICE_DESCRIPTOR desc = new USB_DEVICE_DESCRIPTOR();
            IntPtr hDevice;
            int    result;

            result = QuickUsbOpenUtil(out hDevice, listInfo.qusb.Name);
            if (result != 0)
            {
                try
                {
                    result = QuickUsbGetDeviceDesc(listInfo.qusb.Handle, ref desc, 18);
                }
                catch
                {
                    // User is using an older DLL, so we won't be able to read descriptor information
                }
                result = QuickUsbCloseUtil(hDevice);
            }

            // Add data to columns
            for (int k = 0; k < columnData.Count; ++k)
            {
                switch (columnData[k].type)
                {
                case ColumnDataType.Name:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, listInfo.qusb.Name);
                    break;

                case ColumnDataType.Make:
                    if (showUnprogrammedDevices && listInfo.qusb.Make == null && desc.idVendor == 0x04b4 && desc.idProduct == 0x8613)
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, "Bitwise Systems");
                    }
                    else
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, listInfo.qusb.Make);
                    }
                    break;

                case ColumnDataType.Model:
                    if (showUnprogrammedDevices && listInfo.qusb.Make == null)
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, "Unprogrammed");
                    }
                    else
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, listInfo.qusb.Model);
                    }
                    break;

                case ColumnDataType.Serial:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, listInfo.qusb.Serial);
                    break;

                case ColumnDataType.PrivateModel:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, qusb.GetStringDescriptor((QuickUsb.StringDescriptor) 4));
                    break;

                case ColumnDataType.IOModel:
                    string ioModel = qusb.GetStringDescriptor((QuickUsb.StringDescriptor) 4);

                    // The IO Model is in parenthesis in the private model string.  If there are no parentheses, then it's the simple IO model
                    if (ioModel != null)
                    {
                        int start = ioModel.IndexOf('(');
                        int end   = ioModel.IndexOf(')');
                        if (start == -1 || end == -1)
                        {
                            ioModel = "Simple I/O";
                        }
                        else
                        {
                            ioModel = ioModel.Substring(start + 1, (end - start - 1));
                        }
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, ioModel);
                    }
                    break;

                case ColumnDataType.PrivateSerial:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, qusb.GetStringDescriptor((QuickUsb.StringDescriptor) 5));
                    break;

                case ColumnDataType.PrivateMake:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, qusb.GetStringDescriptor((QuickUsb.StringDescriptor) 6));
                    break;

                case ColumnDataType.FirmwareVersion:
                    // Make sure that device contains firmware before trying to communicate with it
                    if (listInfo.qusb.Make != null)
                    {
                        listInfo.qusb.GetFirmwareVersion(out v);
                        if (v != null)
                        {
                            listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, String.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build));
                        }
                    }
                    break;

                case ColumnDataType.DriverVersion:
                    QuickUsb.GetDriverVersion(out v);
                    if (v != null)
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, String.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build));
                    }
                    break;

                case ColumnDataType.LibraryVersion:
                    QuickUsb.GetDllVersion(out v);
                    if (v != null)
                    {
                        listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, String.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build));
                    }
                    break;

                case ColumnDataType.VID:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, "0x" + desc.idVendor.ToString("X4"));
                    break;

                case ColumnDataType.PID:
                    listInfo.lvi.SubItems[k] = new ListViewItem.ListViewSubItem(listInfo.lvi, "0x" + desc.idProduct.ToString("X4"));
                    break;
                }
            }

            listInfo.visible         = true;
            listInfo.lvi.Name        = listInfo.qusb.Make;
            listInfo.lvi.ToolTipText = "Name: " + devName + Environment.NewLine +
                                       "Serial: " + newSerial + Environment.NewLine;
            listInfo.lvi.Tag        = listInfo.qusb;    // NOTE: Tag of LVI contains QuickUSB object (Very convenient)
            listInfo.lvi.ImageIndex = 1;                // Default to unattached icon

            alreadyAdded = false;
            return(listInfo);
        }