Ejemplo n.º 1
0
        private static StringBuilder getDescriptorReport(IUsbDevice usbRegistry)
        {
            StringBuilder sbReport = new StringBuilder();

            if (!usbRegistry.TryOpen())
            {
                return(sbReport);
            }

            sbReport.AppendLine(string.Format("{0} OSVersion:{1} LibUsbDotNet Version:{2} DriverMode:{3}", usbRegistry.Info.SerialNumber, Environment.OSVersion, LibUsbDotNetVersion, null));
            sbReport.AppendLine(usbRegistry.Info.ToString());
            foreach (UsbConfigInfo cfgInfo in usbRegistry.Configs)
            {
                sbReport.AppendLine(string.Format("CONFIG #{1}\r\n{0}", cfgInfo.ToString(), cfgInfo.ConfigurationValue));
                foreach (UsbInterfaceInfo interfaceInfo in cfgInfo.Interfaces)
                {
                    sbReport.AppendLine(string.Format("INTERFACE ({1},{2})\r\n{0}", interfaceInfo.ToString(), interfaceInfo.Number, interfaceInfo.AlternateSetting));

                    foreach (UsbEndpointInfo endpointInfo in interfaceInfo.Endpoints)
                    {
                        sbReport.AppendLine(string.Format("ENDPOINT 0x{1:X2}\r\n{0}", endpointInfo.ToString(), endpointInfo.EndpointAddress));
                    }
                }
            }
            usbRegistry.Close();

            return(sbReport);
        }
Ejemplo n.º 2
0
        private void addDevice(IUsbDevice deviceReg, string display)
        {
            if (!deviceReg.TryOpen())
            {
                return;
            }
            mUsbRegistry = deviceReg;

            TreeNode tvDevice = tvInfo.Nodes.Add(display);

            string[] sDeviceAdd = mUsbDevice.Info.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in sDeviceAdd)
            {
                tvDevice.Nodes.Add(s);
            }


            foreach (UsbConfigInfo cfgInfo in mUsbDevice.Configs)
            {
                TreeNode tvConfig = tvDevice.Nodes.Add("Config " + cfgInfo.ConfigurationValue);
                string[] sCfgAdd  = cfgInfo.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string s in sCfgAdd)
                {
                    tvConfig.Nodes.Add(s);
                }

                TreeNode tvInterfaces = tvConfig; //.Nodes.Add("Interfaces");
                foreach (UsbInterfaceInfo interfaceInfo in cfgInfo.Interfaces)
                {
                    TreeNode tvInterface =
                        tvInterfaces.Nodes.Add("Interface [" + interfaceInfo.Number + "," + interfaceInfo.AlternateSetting + "]");
                    string[] sInterfaceAdd = interfaceInfo.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in sInterfaceAdd)
                    {
                        tvInterface.Nodes.Add(s);
                    }

                    TreeNode tvEndpoints = tvInterface; //.Nodes.Add("Endpoints");
                    foreach (UsbEndpointInfo endpointInfo in interfaceInfo.Endpoints)
                    {
                        TreeNode tvEndpoint   = tvEndpoints.Nodes.Add("Endpoint 0x" + (endpointInfo.EndpointAddress).ToString("X2"));
                        string[] sEndpointAdd = endpointInfo.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in sEndpointAdd)
                        {
                            tvEndpoint.Nodes.Add(s);
                        }
                    }
                }
            }
            mUsbDevice.Close();
        }
Ejemplo n.º 3
0
 public bool TryOpen()
 {
     return(_device.TryOpen());
 }