private void UploadWithPortBooter() { m_eng.OnNoise -= new _DBG.NoiseEventHandler(OnNoise); if (m_fWait) { m_fl.WaitBanner(Int32.MaxValue, 2000); } m_fl.Program(m_blocks); uint address = uint.MaxValue; foreach (_DBG.SRecordFile.Block bl in m_blocks) { if (bl.executable) { address = bl.address; } } if (address != uint.MaxValue) { m_fl.Execute(address); } m_eng.OnNoise += new _DBG.NoiseEventHandler(OnNoise); if (m_fDisconnect) { this.Invoke(new Callback_Bool(this.StartOrStop), new object[] { false }); } }
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); m_fl.OnProgress += new _DBG.PortBooter.ProgressEventHandler(this.OnProgress); m_fl.Start(); if (fWait) { m_fl.WaitBanner(Int32.MaxValue, 2000); } DateTime start = DateTime.Now; m_fl.Program(m_blocks); Console.WriteLine("Execute: {0}", DateTime.Now - start); if (m_entrypoint != 0) { while (true) { m_fl.Execute(m_entrypoint); _DBG.PortBooter.Report r = m_fl.GetReport(2000); if (r != null && r.type == _DBG.PortBooter.Report.State.EntryPoint) { break; } } } m_fl.Stop(); m_eng.Stop(); return(true); }
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 ); m_fl.OnProgress += new _DBG.PortBooter.ProgressEventHandler( this.OnProgress ); m_fl.Start(); if(fWait) { m_fl.WaitBanner( Int32.MaxValue, 2000 ); } DateTime start = DateTime.Now; m_fl.Program( m_blocks ); Console.WriteLine( "Execute: {0}", DateTime.Now - start ); if(m_entrypoint != 0) { while(true) { m_fl.Execute( m_entrypoint ); _DBG.PortBooter.Report r = m_fl.GetReport( 2000 ); if(r != null && r.type == _DBG.PortBooter.Report.State.EntryPoint) { break; } } } m_fl.Stop(); m_eng.Stop(); return true; }