Ejemplo n.º 1
0
 internal Ports()
 {
     DataPersistor = new PortDataPersistor {
         PortInfoList = _portInfoList
     };
     _portFilter = new PortFilter();
 }
Ejemplo n.º 2
0
			private DebugPort DebugPortFromPortFilter (PortFilter portFilter)
			{
				foreach (DebugPort port in m_ports) {
					if (port.PortFilter == portFilter)
						return port;
				}

				return null;
			}
Ejemplo n.º 3
0
 public DebugPort(PortFilter portFilter, DebugPortSupplier portSupplier)
 {
     m_name = NameFromPortFilter(portFilter);
     m_portSupplier = portSupplier;
     m_portFilter = portFilter;
     m_cpDebugPortEvents2 = new ConnectionPoint(this, typeof(IDebugPortEvents2).GUID);
     m_alProcesses = ArrayList.Synchronized(new ArrayList(1));
     m_pidNext = 1;
     m_guid = Guid.NewGuid();
 }
Ejemplo n.º 4
0
 public DebugPort(PortFilter portFilter, DebugPortSupplier portSupplier)
 {
     m_name               = NameFromPortFilter(portFilter);
     m_portSupplier       = portSupplier;
     m_portFilter         = portFilter;
     m_cpDebugPortEvents2 = new ConnectionPoint(this, typeof(IDebugPortEvents2).GUID);
     m_alProcesses        = ArrayList.Synchronized(new ArrayList(1));
     m_pidNext            = 1;
     m_guid               = Guid.NewGuid();
 }
            private DebugPort DebugPortFromPortFilter(PortFilter portFilter)
            {
                foreach (DebugPort port in _ports)
                {
                    if (port.PortFilter == portFilter)
                    {
                        return(port);
                    }
                }

                return(null);
            }
Ejemplo n.º 6
0
        public static string NameFromPortFilter(PortFilter portFilter)
        {
            switch (portFilter)
            {
            case PortFilter.Serial:
                return("Serial");

            //case Debugger.PortFilter.Usb:
            //    return "USB";
            //case Debugger.PortFilter.TcpIp:
            //    return "TCP/IP";
            default:
                Debug.Assert(false);
                return("");
            }
        }
Ejemplo n.º 7
0
        public static string NameFromPortFilter(PortFilter portFilter)
        {
            switch (portFilter)
            {
            case PortFilter.Serial:
                return("Serial");

            case PortFilter.Emulator:
                return("Emulator");

            case PortFilter.Usb:
                return("USB");

            case PortFilter.TcpIp:
                return("TCP/IP");

            default:
                Debug.Assert(false);
                return("");
            }
        }
 public TransportTypeItem(PortFilter id, string text)
 {
     m_id = id;
     m_text = text;
 }
Ejemplo n.º 9
0
 public static string NameFromPortFilter(PortFilter portFilter)
 {
     switch (portFilter)
     {
         case PortFilter.Serial:
             return "Serial";
         case PortFilter.Emulator:
             return "Emulator";
         case PortFilter.Usb:
             return "USB";
         case PortFilter.TcpIp:
             return "TCP/IP";
         default:
             Debug.Assert(false);
             return "";
     }
 }
Ejemplo n.º 10
0
            private bool RebootDevice(Engine.RebootOption option)
            {
                PortFilter[] args = { };
                switch (this.Transport.ToLower())
                {
                    case "emulator":
                        args = new PortFilter[] { PortFilter.Emulator };
                        break;
                    case "serial":
                        args = new PortFilter[] { PortFilter.Serial };
                        break;
                    case "tcpip":
                        args = new PortFilter[] { PortFilter.TcpIp };
                        break;
                    case "usb":
                        args = new PortFilter[] { PortFilter.Usb };
                        break;
                }

                ArrayList list = PortDefinition.Enumerate(args);
                PortDefinition port = null;
                foreach (object prt in list)
                {
                    port = (PortDefinition)prt;
                    if (port.DisplayName.ToLower().Contains(this.Device.ToLower()))
                    {
                        break;
                    }
                    else
                    {
                        port = null;
                    }
                }

                if (null == port)
                {
                    return false;
                }

                using (Engine engine = new Engine(port))
                {
                    engine.Start();
                    bool connect = false;

                    connect = engine.TryToConnect(200, 500, true, ConnectionSource.TinyCLR);

                    if (!connect)
                    {
                        return false;
                    }
                    engine.RebootDevice(option);
                }

                return true;
            }
Ejemplo n.º 11
0
        internal static PortDefinition GetPort(string device, string transport, string exePath)
        {
            PortFilter[] args = { };
            switch (transport.ToLower())
            {
                case "emulator":
                    args = new PortFilter[] { PortFilter.Emulator };
                    device = "emulator";
                    PortDefinition pd = 
                        PortDefinition.CreateInstanceForEmulator("Launch 'Microsoft Emulator'", "Microsoft", 0);

                    PlatformInfo pi = new PlatformInfo(null);
                    PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

                    if (emu != null)
                    {
                        string onboardFlash = Path.Combine(Path.GetDirectoryName(emu.application), "OnBoardFlash.dat");

                        if (File.Exists(onboardFlash))
                        {
                            try
                            {
                                File.Delete(onboardFlash);
                            }
                            catch
                            {
                            }
                        }
                    }


                    PortDefinition_Emulator emuport = pd as PortDefinition_Emulator;
                    Console.WriteLine("\tLaunching Emulator..");
                    Process emuProc = EmulatorLauncher.LaunchEmulator(
                        emuport,
                        true, exePath);
                    break;
                case "serial":
                    args = new PortFilter[] { PortFilter.Serial };
                    break;
                case "tcpip":
                    args = new PortFilter[] { PortFilter.TcpIp };
                    break;
                case "usb":
                    args = new PortFilter[] { PortFilter.Usb };
                    break;
            }

            ArrayList list = new ArrayList();
            int nRetries = 20;

            while (list.Count == 0 && nRetries-- > 0)
            {
                list = PortDefinition.Enumerate(args);

                if (list.Count > 0) break;

                System.Threading.Thread.Sleep(500);
            }

            PortDefinition port = null;

            foreach (object prt in list)
            {
                port = (PortDefinition)prt;
                if (port.DisplayName.ToLower().Contains(device.ToLower()))
                {
                    break;
                }
                else
                {
                    port = null;
                }
            }

            if (null != port)
            {
                return port;
            }
            else
            {
                throw new ApplicationException(
                    "Could not find the specified device for the harness to connect to.");
            }
        }
Ejemplo n.º 12
0
        internal static PortDefinition GetPort(string device, string transport, string exePath)
        {
            PortFilter[] args = { };
            switch (transport.ToLower())
            {
            case "emulator":
                args   = new PortFilter[] { PortFilter.Emulator };
                device = "emulator";
                PortDefinition pd =
                    PortDefinition.CreateInstanceForEmulator("Launch 'Microsoft Emulator'", "Microsoft", 0);

                PlatformInfo          pi  = new PlatformInfo(null);
                PlatformInfo.Emulator emu = pi.FindEmulator(pd.Port);

                if (emu != null)
                {
                    string onboardFlash = Path.Combine(Path.GetDirectoryName(emu.application), "OnBoardFlash.dat");

                    if (File.Exists(onboardFlash))
                    {
                        try
                        {
                            File.Delete(onboardFlash);
                        }
                        catch
                        {
                        }
                    }
                }


                PortDefinition_Emulator emuport = pd as PortDefinition_Emulator;
                Console.WriteLine("\tLaunching Emulator..");
                Process emuProc = EmulatorLauncher.LaunchEmulator(
                    emuport,
                    true, exePath);
                break;

            case "serial":
                args = new PortFilter[] { PortFilter.Serial };
                break;

            case "tcpip":
                args = new PortFilter[] { PortFilter.TcpIp };
                break;

            case "usb":
                args = new PortFilter[] { PortFilter.Usb };
                break;
            }

            ArrayList list     = new ArrayList();
            int       nRetries = 20;

            while (list.Count == 0 && nRetries-- > 0)
            {
                list = PortDefinition.Enumerate(args);

                if (list.Count > 0)
                {
                    break;
                }

                System.Threading.Thread.Sleep(500);
            }

            PortDefinition port = null;

            foreach (object prt in list)
            {
                port = (PortDefinition)prt;
                if (port.DisplayName.ToLower().Contains(device.ToLower()))
                {
                    break;
                }
                else
                {
                    port = null;
                }
            }

            if (null != port)
            {
                return(port);
            }
            else
            {
                throw new ApplicationException(
                          "Could not find the specified device for the harness to connect to.");
            }
        }
 public TransportTypeItem(PortFilter id, string text)
 {
     m_id   = id;
     m_text = text;
 }