当前位置: 首页>>代码示例>>C#>>正文


C# Engine.Start方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Debugger.Engine.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.Start方法的具体用法?C# Engine.Start怎么用?C# Engine.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Debugger.Engine的用法示例。


在下文中一共展示了Engine.Start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnRun

		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var mfStartInfo = startInfo as MicroFrameworkDebuggerStartInfo;
			if (mfStartInfo == null)//This should never happen...
				throw new InvalidOperationException ();
			var command = mfStartInfo.MFCommand;
			var portDefinition = ((MicroFrameworkExecutionTarget)command.Target).PortDefinition;
			using (var deployEngine = new Engine (portDefinition)) {
				deployEngine.Start ();

				string newCommand = "/CorDebug_DeployDeviceName:" + portDefinition.PersistName;

				var listOfAseemblies = new ArrayList ();

				//TODO: Check if this is robust enough will "be" and "le" really always be in output folder?
				OutputDirectory = command.OutputDirectory;
				string dir = command.OutputDirectory;
				if (deployEngine.IsTargetBigEndian)
					dir = Path.Combine (dir, "be");
				else
					dir = Path.Combine (dir, "le");

				string[] files = Directory.GetFiles (dir, "*.pe");
				foreach (var file in files) {
					newCommand = "/load:" + file + " " + newCommand;
					using (var fs = new FileStream (file, FileMode.Open)) {
						byte[] data = new byte[fs.Length];
						fs.Read (data, 0, data.Length);
						listOfAseemblies.Add (data);
					}
				}
				startInfo.Command = newCommand;
				deployEngine.Deployment_Execute (listOfAseemblies, false, (str) => OnDebuggerOutput (false, "Deploy: " + str + Environment.NewLine));
				deployEngine.RebootDevice (Engine.RebootOption.RebootClrWaitForDebugger);
			}
			VsPackage.MessageCentre.Session = this;
			try {
				CorDebugProcess process = CorDebugProcess.CreateProcess (new DebugPortSupplier ().FindPort ("USB"), startInfo.Command);
				process.StartDebugging (this, false);
				// StartDebugging() will either get a connected device into a debuggable state and start the dispatch thread, or throw.
			} catch (ProcessExitException) {
				VsPackage.MessageCentre.DeploymentMsg (DiagnosticStrings.InitializeProcessFailedProcessDied);
			} catch (Exception ex) {
				VsPackage.MessageCentre.DeploymentMsg (DiagnosticStrings.InitializeProcessFailed);
				VsPackage.MessageCentre.InternalErrorMsg (false, ex.Message);
			}
		}
开发者ID:Roddoric,项目名称:Monkey.Robotics,代码行数:47,代码来源:MicroFrameworkDebuggerSession.cs

示例2: StartOrStop

        private void StartOrStop( bool fStart ) 
        {
            bool fButtonState;

            if(fStart)
            {
                if(m_eng != null) return;

                m_blocks      = new ArrayList();
                m_fWait       = checkBoxWait.Checked;
                m_fDisconnect = checkBoxDisconnect.Checked;

                listViewFiles.SelectedIndices.Clear();

                try
                {
                    _DBG.PortDefinition pd = GetSelectedPortDefinition();
                    
                    m_eng = new _DBG.Engine( pd );

                    m_eng.Silent = true;

                    m_eng.OnNoise   += new _DBG.NoiseEventHandler  ( OnNoise   );
                    m_eng.OnMessage += new _DBG.MessageEventHandler( OnMessage );

                    m_eng.Start();

                    if (m_eng.TryToConnect(5, 100))
                    {
                        if (m_fWait)
                        {
                            // if w are talking to the booter, have it to stop and wait for upload
                            // PortBooter will wait to secs no matter what
                            m_eng.RebootDevice(radioButtonPortBooter.Checked ? _DBG.Engine.RebootOption.EnterBootloader : _DBG.Engine.RebootOption.NormalReboot);
                        }
                    }
                    


                    foreach(ListViewItem item in this.listViewFiles.CheckedItems)
                    {
                        m_blocks.Add( item.Tag );
                    }

                    if(m_blocks.Count > 0)
                    {
                        if(radioButtonPortBooter.Checked)
                        {   
                            m_fl = new _DBG.PortBooter( m_eng );

                            m_fl.OnProgress += new _DBG.PortBooter.ProgressEventHandler( this.OnProgress );

                            m_fl.Start();

                            m_worker = new Thread( new ThreadStart( this.UploadWithPortBooter ) );
                        }
                        else
                        {
                            m_worker = new Thread( new ThreadStart( this.UploadWithTinyBooter ) );
                        }

                        m_worker.Start();
                    }

                    buttonAction.Text = "Stop";
                    richTextBox1.Focus();
                }
                catch(Exception ex)
                {
                    MessageBox.Show( ex.Message );
                    return;
                }

                fButtonState = false;
            }
            else
            {
                if(m_eng == null) return;

                Stop();

                buttonAction.Text = "Start";

                fButtonState = true;
            }

            buttonReload         .Enabled = fButtonState;
            buttonRemove         .Enabled = fButtonState;
            buttonRemoveAll      .Enabled = fButtonState;
            buttonBrowse         .Enabled = fButtonState;
            comboBoxPort         .Enabled = fButtonState;
            comboBoxBaud         .Enabled = fButtonState;
            listViewFiles        .Enabled = fButtonState;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:94,代码来源:portBooterClient.cs

示例3: EnsureDebuggerConnection

        /// <summary>
        /// 
        /// </summary>
        /// <returns>Returns the previous conneciton state of the debugger engine</returns>
        private bool EnsureDebuggerConnection()
        {
            if( m_eng == null )
            {
                _DBG.PortDefinition pd = GetSelectedPortDefinition();

                m_eng = new _DBG.Engine( pd );

                m_eng.OnNoise += new _DBG.NoiseEventHandler( OnNoise );
                m_eng.OnMessage += new _DBG.MessageEventHandler( OnMessage );

                m_eng.Start();

                m_eng.TryToConnect(5, 100);

                return false;
            }

            // TryToConnect calls GetCLRCapabilities which prevents a bunch of asserts
            m_eng.TryToConnect(5, 100);

            return true;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:27,代码来源:portBooterClient.cs

示例4: RebootDevice

            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;
            }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:55,代码来源:TestSystem.cs

示例5: ConnectToTinyBooter

        /// <summary>
        /// Attempt to establish a connection with TinyBooter (with reboot if necessary)
        /// </summary>
        /// <returns>true connection was made, false otherwise</returns>
        public bool ConnectToTinyBooter()
        {
            bool ret = false;

            if (m_eng == null)
            {
                _DBG.PortDefinition pd = m_portTinyBooter;

                try
                {
                    if (m_eng == null)
                    {
                        m_eng = new _DBG.Engine(pd);

                        m_eng.OnNoise += new _DBG.NoiseEventHandler(OnNoiseHandler);
                        m_eng.OnMessage += new _DBG.MessageEventHandler(OnMessage);

                        m_eng.Start();
                        m_eng.TryToConnect(5, 100, true, _DBG.ConnectionSource.Unknown);
                    }
                }
                catch
                {
                }
            }


            if (m_eng != null)
            {
                if (m_eng.ConnectionSource == _DBG.ConnectionSource.TinyBooter) return true;

                m_eng.RebootDevice(_DBG.Engine.RebootOption.EnterBootloader);

                // tinyBooter is only com port so
                if (m_port is _DBG.PortDefinition_Tcp)
                {
                    Disconnect();

                    m_port = m_portTinyBooter;

                    // digi takes forever to reset
                    if (!Connect(60000, true))
                    {
                        Console.WriteLine(Properties.Resources.ErrorUnableToConnectToTinyBooterSerial);
                        return false;
                    }
                }
                bool fConnected = false;
                for(int i = 0; i<40; i++)
                {
                    if (EventCancel.WaitOne(0, false)) throw new MFUserExitException();

                    if (fConnected = m_eng.TryToConnect(0, 500, true, _DBG.ConnectionSource.Unknown))
                    {
                        _WP.Commands.Monitor_Ping.Reply reply = m_eng.GetConnectionSource();
                        ret = (reply.m_source == _WP.Commands.Monitor_Ping.c_Ping_Source_TinyBooter);

                        break;
                    }
                }
                if(!fConnected)
                {
                    Console.WriteLine(Properties.Resources.ErrorUnableToConnectToTinyBooter);
                }
            }
            return ret;
        }
开发者ID:prabby,项目名称:miniclr,代码行数:71,代码来源:MFDevice.cs

示例6: Connect

        internal bool Connect( int timeout_ms, bool tryConnect )
        {
            // to use user cancel event, so that cancel button is more responsive
            int retries = m_port is _DBG.PortDefinition_Tcp ? 2 : timeout_ms/100;
            int loops = 1;
            
            if (retries == 0) retries = 1;

            if (m_portTinyBooter != null && m_port.UniqueId != m_portTinyBooter.UniqueId)
            {
                retries /= 2;
                loops   =  2;
            }
            for (int i = 0; i < loops; i++)
            {
                _DBG.PortDefinition pd = i == 0 ? m_port : m_portTinyBooter;

                if (EventCancel.WaitOne(0, false)) throw new MFUserExitException();

                try
                {
                    if (m_eng == null)
                    {
                        m_eng = new _DBG.Engine(pd);

                        m_eng.OnNoise += new _DBG.NoiseEventHandler(OnNoiseHandler);
                        m_eng.OnMessage += new _DBG.MessageEventHandler(OnMessage);

                        m_eng.Start();
                    }

                    if (tryConnect)
                    {
                        if (CheckForMicroBooter())
                            return true;

                        for (int j = retries; j > 0; j--)
                        {
                            if (m_eng.TryToConnect(0, timeout_ms / retries, true, _DBG.ConnectionSource.Unknown))
                            {
                                //UNLOCK DEVICE in secure way?
                                m_eng.UnlockDevice(m_data);
                                break;
                            }

                            if (EventCancel.WaitOne(0, false)) throw new MFUserExitException();
                        }
                        if (m_eng.IsConnected)
                        {
                            /*
                            if (m_serverCert != null && m_eng.UpgradeConnectionToSsl(0, m_serverCert, m_requireClientCert))
                            {
                                if (OnDebugText != null)
                                {
                                    OnDebugText(this, new DebugOutputEventArgs("Using SSL Connection!!!"));
                                }
                            }
                            */

                            break;
                        }
                        else
                        {
                            Disconnect();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (MFUserExitException)
                {
                    Disconnect();
                    throw;
                }
                catch
                {
                    Disconnect();
                }
            }
            return (m_eng != null && (!tryConnect || m_eng.IsConnected));
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:86,代码来源:MFDevice.cs

示例7: ConnectTo

        internal bool ConnectTo(int timeout_ms, bool tryToConnect, _DBG.ConnectionSource target)
        {
            int retries = m_port is _DBG.PortDefinition_Tcp ? 2 : timeout_ms / 300;
            if (retries == 0) retries = 1;

            try
            {
                if (m_eng == null)
                {
                    m_eng = new _DBG.Engine(m_port);

                    m_eng.OnNoise += new _DBG.NoiseEventHandler(OnNoiseHandler);
                    m_eng.OnMessage += new _DBG.MessageEventHandler(OnMessage);

                    m_eng.Start();
                }

                if (tryToConnect)
                {
                    for (int j = retries; j > 0; j--)
                    {
                        switch (target)
                        {
                            case _DBG.ConnectionSource.MicroBooter:
                                if (CheckForMicroBooter()) return true;
                                Thread.Sleep(timeout_ms / retries);
                                break;

                            default:
                                if (m_eng.TryToConnect(0, timeout_ms / retries, true, _DBG.ConnectionSource.Unknown))
                                {
                                    if (m_eng.ConnectionSource == _DBG.ConnectionSource.TinyCLR)
                                    {
                                        m_eng.UnlockDevice(m_data);
                                    }
                                    else if (m_eng.ConnectionSource == _DBG.ConnectionSource.TinyBooter)
                                    {
                                        if (target == _DBG.ConnectionSource.TinyCLR)
                                        {
                                            m_eng.ExecuteMemory(0);
                                            Thread.Sleep(100);
                                        }
                                    }
                                    break;
                                }

                                if (EventCancel.WaitOne(0, false)) throw new MFUserExitException();
                                break;
                        }
                        if (m_eng.IsConnected && target == m_eng.ConnectionSource)
                        {
                            break;
                        }
                    }

                    if (target != m_eng.ConnectionSource)
                    {
                        Disconnect();
                    }
                }

            }
            catch (ThreadAbortException)
            {
            }
            catch (MFUserExitException)
            {
                Disconnect();
                throw;
            }
            catch
            {
                Disconnect();
            }

            return (m_eng != null && (!tryToConnect || m_eng.IsConnected));
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:77,代码来源:MFDevice.cs

示例8: StartProfiler

        internal void StartProfiler(string device, string logFile, string transport, 
            string exePath, string buildPath, ArrayList referenceList, bool isDevEnvironment, string assemblyName )
        {
            try
            {
                PortDefinition port = Utils.GetPort(device, transport, exePath);

                m_engine = new Engine(port);
                m_session = new ProfilerSession(m_engine);

#if DEBUG
                m_exporter = new Exporter_OffProf(m_session, logFile);
#endif

                lock (m_engine)
                {
                    m_engine.StopDebuggerOnConnect = true;
                    m_engine.Start();

                    bool connected = false;

                    connected = m_engine.TryToConnect(20, 500, true, ConnectionSource.TinyCLR);

                    if (connected)
                    {
                        if (m_engine.Capabilities.Profiling == false)
                        {
                            throw new ApplicationException("This device is not running a version of TinyCLR that supports profiling.");
                        }

                        // Deploy the test files to the device.                    
                        Utils.DeployToDevice(buildPath, referenceList, m_engine, transport, isDevEnvironment, assemblyName);

                        // Move IsDeviceInInitializeState(), IsDeviceInExitedState(), 
                        // GetDeviceState(),EnsureProcessIsInInitializedState() to Debugger.dll?

                        m_engine.RebootDevice(Engine.RebootOption.RebootClrWaitForDebugger);

                        if (!m_engine.TryToConnect(100, 500))
                        {
                            throw new ApplicationException("Connection Failed");
                        }

                        m_engine.ThrowOnCommunicationFailure = true;
                        m_session.EnableProfiling();

                        m_session.SetProfilingOptions(true, false);
                        m_engine.OnCommand += new CommandEventHandler(OnWPCommand);
                        m_engine.ResumeExecution();
                    }
                    else
                    {
                        throw new ApplicationException("Connection failed");
                    }
                }
            }
            catch (Exception ex)
            {
                SoftDisconnectDone(null, null);
                throw ex;
            }            
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:62,代码来源:Profile.cs

示例9: Connect

        private bool Connect()
        {
            Disconnect();

            try
            {
                _DBG.PortDefinition pd = (_DBG.PortDefinition)comboBoxPort.SelectedItem;

                string port     =                      pd.Port;
                uint   baudrate = uint.Parse( ((string)comboBoxBaud.SelectedItem) );

                using(_DBG.AsyncSerialStream stream = new _DBG.AsyncSerialStream( port, baudrate ))
                {
                    stream.Close();
                }

                m_eng = new _DBG.Engine( new Microsoft.SPOT.Debugger.PortDefinition_Serial( port, port, baudrate ) );

                m_eng.Silent = true;

                m_eng.Start();

                if(m_eng.TryToConnect( 4, 250 ))
                {
                    m_deviceRunning = true;

                    m_eng.PauseExecution();

                    m_ranges = m_eng.MemoryMap();
                    if(m_ranges == null)
                    {
                        //
                        // Fallback to some defaults.
                        //
                        m_ranges = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range[2];

                        m_ranges[0] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[0].m_address = 0x00000000;
                        m_ranges[0].m_length  = 0x00060000;
                        m_ranges[0].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_RAM;

                        m_ranges[1] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range();
                        m_ranges[1].m_address = 0x10000000;
                        m_ranges[1].m_length  = 1024*1024;
                        m_ranges[1].m_flags   = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_FLASH;
                    }
                }
                else
                {
                    m_deviceRunning = false;
                }


                m_ah = new _DBG.AbortHandler( m_eng, m_deviceRunning );

                m_ah.Start();

                
                bool connected = false;

                for(int tries=0; tries < 5; tries++)
                {
                    if(m_ah.ReadRegisters( m_snapshot.m_registers, out m_snapshot.m_cpsr, out m_snapshot.m_BWA, out m_snapshot.m_BWC ))
                    {
                        connected = true; break;
                    }

                    Thread.Sleep( 1000 );
                }

                if(connected)
                {
                    for(int tries=0; tries < 5; tries++)
                    {
                        if(m_ah.ReadLayout( out m_snapshot.m_flashBase, out m_snapshot.m_flashSize, out m_snapshot.m_ramBase, out m_snapshot.m_ramSize ))
                        {
                            break;
                        }

                        Thread.Sleep( 1000 );
                    }

                    return true;
                }

                if(!connected)
                {
                    MessageBox.Show( "Cannot connect to device" );
                }

                return connected;
            }
            catch(Exception ex)
            {
                MessageBox.Show( ex.Message );

                return false;
            }
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:99,代码来源:Settings.cs

示例10: AttachToEngine

        public Engine AttachToEngine()
        {
            int c_maxRetries     = 30;
            int c_retrySleepTime = 300;

            for(int retry=0; retry<c_maxRetries; retry++)
            {
                if(ShuttingDown) break;
                
                try
                {
                    lock(this)
                    {
                        if (m_engine == null)
                        {
#if USE_CONNECTION_MANAGER
                            m_engine = m_port.DebugPortSupplier.Manager.Connect(m_portDefinition);
#else
                            m_engine = new Engine(m_portDefinition);
#endif
                            m_engine.StopDebuggerOnConnect = true;
                            m_engine.Start();

                            m_engine.OnMessage += new MessageEventHandler(OnMessage);
                            m_engine.OnCommand += new CommandEventHandler(OnCommand);
                            m_engine.OnNoise   += new NoiseEventHandler(OnNoise);
                            m_engine.OnProcessExit += new EventHandler(OnProcessExit);
                        }
                        else
                        {
                            m_engine.ThrowOnCommunicationFailure = false;
                            m_engine.StopDebuggerOnConnect = true;                        
                        }
                    }
                    if( m_engine.TryToConnect( 3, c_retrySleepTime, true, ConnectionSource.Unknown ) )
                    {
                        if(m_engine.ConnectionSource == ConnectionSource.TinyBooter)
                        {
                            m_engine.ExecuteMemory(0);
                            Thread.Yield();
                        }
                        m_engine.ThrowOnCommunicationFailure = true;
                        m_engine.SetExecutionMode( WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_SourceLevelDebugging, 0 );
                        break;
                    }

                    // only detach-reattach after 10 retries (10 seconds)
                    if((retry % 10) == 9) 
                        DetachFromEngine();

                    Thread.Yield();
                }
                catch
                {
                    DetachFromEngine();

                    if(!ShuttingDown)
                    {
                        Thread.Yield();
                    }
                }
            }

            if(m_engine != null && !m_engine.IsConnected)
            {
                DetachFromEngine();
            }

            return m_engine;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:70,代码来源:CorDebugProcess.cs

示例11: ConnectToDevice

        private void ConnectToDevice(string buildPath, string exePath, ArrayList referenceList)
        {
            TestSystem.IncludesDeviceTest = true;
            PortDefinition port = Utils.GetPort(m_device, m_transport, exePath);

            try
            {
                for (int retry = 0; retry < 3; retry++)
                {
                    m_engine = new Microsoft.SPOT.Debugger.Engine(port);
                    m_engine.StopDebuggerOnConnect = true;
                    m_engine.Start();

                    bool connected = false;

                    connected = m_engine.TryToConnect(200, 500, true, ConnectionSource.TinyCLR);

                    if (connected)
                    {
                        m_engine.PauseExecution();

                        if (!string.Equals(m_transport.ToLower(), "emulator"))
                        {
                            // Deploy the test files to the device.                    
                            Utils.DeployToDevice(buildPath, referenceList, m_engine, m_transport, m_isDevEnvironment, m_assemblyName);

                            // Connect to the device and execute the deployed test.
                            m_engine.RebootDevice(Microsoft.SPOT.Debugger.Engine.RebootOption.RebootClrWaitForDebugger);

                            // give the device some time to restart (especially for tcp/ip)
                            Thread.Sleep(500);

                            if (m_engine.PortDefinition is PortDefinition_Tcp)
                            {
                                Thread.Sleep(1000);
                            }

                            connected = false;

                            connected = m_engine.TryToConnect(200, 500, true, ConnectionSource.TinyCLR);
                        }


                        if (!connected)
                        {
                            DetachFromEngine();
                            throw new ApplicationException("Reboot Failed");
                        }

                        AttachToProcess();

                        m_engine.ThrowOnCommunicationFailure = true;
                        m_engine.OnMessage += new MessageEventHandler(OnMessage);
                        m_engine.OnCommand += new CommandEventHandler(OnCommand);
                        m_engine.OnNoise += new NoiseEventHandler(OnNoise);

                        Console.WriteLine("\tExecuting the device test..");
                        m_initialTime = DateTime.Now;
                        m_engine.ResumeExecution();

                        m_deviceDone.WaitOne();
                        break;
                    }
                    else
                    {
                        DetachFromEngine();
                        //throw new ApplicationException("Connection failed");
                    }
                }
            }
            catch(Exception ex)
            {
                DetachFromEngine();
                throw new ApplicationException("Connection failed: " + ex.ToString());
            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:76,代码来源:Harness.cs

示例12: Process

        bool Process( string[] args )
        {
            string port     = null;
            uint   baudrate = 0;
            bool   fWait    = true;
            int    i;

            if(args.Length == 0)
            {
                Usage();
                return false;
            }

            for(i=0; i<args.Length; i++)
            {
                string arg = args[i].ToLower();

                if(arg == "-port"    ) { port     =               args[++i]  ; continue; }
                if(arg == "-baudrate") { baudrate = UInt32.Parse( args[++i] ); continue; }
                if(arg == "-nowait"  ) { fWait    = false                    ; continue; }

                if(arg == "-com1") { port = "COM1"; baudrate = 115200; continue; }
                if(arg == "-com2") { port = "COM2"; baudrate = 115200; continue; }

                if(arg == "-write")
                {
                    try
                    {
                        string file = args[++i];

                        Console.WriteLine( "Loading {0}...", file );

                        Microsoft.SPOT.Debugger.SRecordFile.Parse( file, m_blocks, null );

                        Console.WriteLine( "Loaded." );
                    }
                    catch(Exception e)
                    {
                        Console.WriteLine( "{0}", e.ToString() );
                        return false;
                    }

                    continue;
                }

                if(arg == "-writeandexecute")
                {
                    try
                    {
                        string file = args[++i];

                        Console.WriteLine( "Loading {0}...", file );

                        m_entrypoint = Microsoft.SPOT.Debugger.SRecordFile.Parse( file, m_blocks, null );

                        Console.WriteLine( "Loaded." );
                    }
                    catch(Exception e)
                    {
                        Console.WriteLine( "{0}", e.ToString() );
                        return false;
                    }

                    continue;
                }

                if(arg == "-entrypoint")
                {
                    m_entrypoint = ParseHex( args[++i] );

                    continue;
                }

                Usage();
                return false;
            }

            if(port == null || baudrate == 0)
            {
                Console.WriteLine( "No serial port specified!" );
                return false;
            }

            m_eng = new _DBG.Engine( new Microsoft.SPOT.Debugger.PortDefinition_Serial( port, port, baudrate ) );

            m_eng.Silent = true;

            m_eng.OnMessage += new _DBG.MessageEventHandler( OnMessage );

            m_eng.Start();

            if(fWait)
            {
                if(m_eng.TryToConnect( 5, 100 ))
                {
                    m_eng.RebootDevice();
                }
            }

            m_fl = new _DBG.PortBooter( m_eng );
//.........这里部分代码省略.........
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:101,代码来源:Main.cs

示例13: bwConnecter_DoWork

        private void bwConnecter_DoWork(System.Object sender, DoWorkEventArgs e)
        {
            BackgroundConnectorArguments bca = (BackgroundConnectorArguments)e.Argument;
            _DBG.PortDefinition port = bca.connectPort;

            Debug.Assert(m_engine == null);

            e.Result = false;

#if USE_CONNECTION_MANAGER
            m_engine = m_port.DebugPortSupplier.Manager.Connect(port);
#else
            m_engine = new _DBG.Engine(port);
#endif

            m_killEmulator = false;

            lock (m_engine)
            {
                m_engine.StopDebuggerOnConnect = true;
                m_engine.OnCommand += new _DBG.CommandEventHandler(OnWPCommand);
                m_engine.OnMessage += new _DBG.MessageEventHandler(OnWPMessage);
                m_engine.Start();

                const int retries = 50;
                bool connected = false;
                for (int i = 0; connected == false && i < retries; i++)
                {
                    if (bwConnecter.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    connected = m_engine.TryToConnect(1, 100, false, _DBG.ConnectionSource.TinyCLR);
                }

                if (connected)
                {
                    if (m_engine.Capabilities.Profiling == false)
                    {
                        throw new ApplicationException("This device is not running a version of TinyCLR that supports profiling.");
                    }

                    //Move IsDeviceInInitializeState(), IsDeviceInExitedState(), GetDeviceState(),EnsureProcessIsInInitializedState() to Debugger.dll?
                    uint executionMode = 0;
                    m_engine.SetExecutionMode(0, 0, out executionMode);
                    if (bca.reboot || (executionMode & _WP.Commands.Debugging_Execution_ChangeConditions.c_State_Mask) != _WP.Commands.Debugging_Execution_ChangeConditions.c_State_Initialize)
                    {
                        m_engine.RebootDevice(_DBG.Engine.RebootOption.RebootClrWaitForDebugger);
                        m_engine.TryToConnect(10, 1000);
                        m_engine.SetExecutionMode(0, 0, out executionMode);
                        Debug.Assert((executionMode & _WP.Commands.Debugging_Execution_ChangeConditions.c_State_Mask) == _WP.Commands.Debugging_Execution_ChangeConditions.c_State_Initialize);
                    }

                    m_engine.ThrowOnCommunicationFailure = true;
                    m_session = new _PRF.ProfilerSession(m_engine);
                    if (m_exporter != null)
                    {
                        m_exporter.Close();
                    }

                    switch (bca.exporter)
                    {
                        case BackgroundConnectorArguments.ExporterType.CLRProfiler:
                            m_exporter = new _PRF.Exporter_CLRProfiler(m_session, bca.outputFileName);
                            break;
#if DEBUG
                        case BackgroundConnectorArguments.ExporterType.OffProf:
                            m_exporter = new _PRF.Exporter_OffProf(m_session, bca.outputFileName);
                            break;
#endif
                        default:
                            throw new ArgumentException("Unsupported export format");
                    }
                    m_session.EnableProfiling();
                    e.Result = true;
                }
            }
            return;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:80,代码来源:ProfilerLauncherForm.cs


注:本文中的Microsoft.SPOT.Debugger.Engine.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。