Beispiel #1
0
        //--//

        static public PortDefinition[] EnumeratePorts()
        {
            SortedList lst = new SortedList();

            try
            {
                RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DEVICEMAP\SERIALCOMM");

                foreach (string name in key.GetValueNames())
                {
                    string val = (string)key.GetValue(name);
                    int idx = val.Length - 1;
                    while (val[idx] < '0' || val[idx] > '9')
                    {
                        idx--;
                    }
                    val = val.Substring(0, idx + 1);
                    PortDefinition pd = PortDefinition.CreateInstanceForSerial(val + ":", @"\\.\" + val, 115200);

                    lst.Add(val, pd);
                }
            }
            catch
            {
            }

            ICollection col = lst.Values;
            PortDefinition[] res = new PortDefinition[col.Count];

            col.CopyTo(res, 0);

            return res;
        }
Beispiel #2
0
        private static void RetrieveProperties(string hash, ref PortDefinition pd, AsyncUsbStream s)
        {
            IDictionaryEnumerator dict;

            dict = s_textProperties.GetEnumerator();

            while (dict.MoveNext())
            {
                pd.Properties.Add(dict.Key, s.RetrieveStringFromDevice((int)dict.Value));
            }

            dict = s_digitProperties.GetEnumerator();

            while (dict.MoveNext())
            {
                pd.Properties.Add(dict.Key, s.RetrieveIntegerFromDevice((int)dict.Value));
            }
        }
Beispiel #3
0
        //--//

        // /// <include file='doc\Engine.uex' path='docs/doc[@for="Emulator.EnumeratePipes"]/*' />
        public static PortDefinition[] EnumeratePipes()
        {
            SortedList lst = new SortedList();
            Regex re = new Regex("^TinyCLR_([0-9]+)_Port1$");

            try
            {
                DirectoryInfo di = new DirectoryInfo(@"\\.\pipe");

                foreach (FileInfo fi in di.GetFiles())
                {
                    try
                    {
                        if (re.IsMatch(fi.Name))
                        {
                            int pid = Int32.Parse(re.Match(fi.Name).Groups[1].Value);
                            PortDefinition pd = PortDefinition.CreateInstanceForEmulator("Emulator - pid " + pid, fi.FullName, pid);

                            lst.Add(pd.DisplayName, pd);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }

            ICollection col = lst.Values;
            PortDefinition[] res = new PortDefinition[col.Count];

            col.CopyTo(res, 0);

            return res;
        }
Beispiel #4
0
        //--//

        public static PortDefinition[] EnumeratePorts()
        {
            SortedList lst = new SortedList();

            // enumerate each guid under the discovery key
            RegistryKey driverParametersKey = Registry.LocalMachine.OpenSubKey(SpotGuidKeyPath);

            // if no parameters key is found, it means that no USB device has ever been plugged into the host 
            // or no driver was installed
            if (driverParametersKey != null)
            {
                string inquiriesInterfaceGuid = (string)driverParametersKey.GetValue(InquiriesInterface);
                string driverVersion = (string)driverParametersKey.GetValue(DriverVersion);

                if ((inquiriesInterfaceGuid != null) && (driverVersion != null))
                {
                    EnumeratePorts(new Guid(inquiriesInterfaceGuid), driverVersion, lst);
                }
            }

            ICollection col = lst.Values;
            PortDefinition[] res = new PortDefinition[col.Count];

            col.CopyTo(res, 0);

            return res;
        }