<ahref="menu_8cpp.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-</span>
<aname="l00008"></a>00008 <spanclass="preprocessor">#include <<aclass="code"href="_a_p___common_8h.html"title="Common definitions and utility routines for the ArduPilot libraries.">AP_Common.h</a>></span>
<aname="l00014"></a>00014 <spanclass="preprocessor">#include "<aclass="code"href="menu_8h.html"title="Simple commandline menu subsystem. The Menu class implements a simple CLI that accepts commands type...">include/menu.h</a>"</span>
<aname="l00018"></a>00018 <aclass="code"href="struct_menu_1_1arg.html">Menu::arg</a> Menu::_argv[<aclass="code"href="menu_8h.html#a78a3dfeac59b72f430d58683a06644fe"title="maximum number of arguments">MENU_ARGS_MAX</a> + 1];
<aname="l00049"></a>00049 c = <aclass="code"href="_fast_serial_8h.html#a8e6f49b84135f0158fe250cb7338ddad">Serial</a>.<aclass="code"href="class_fast_serial.html#a6b63b52d3dedb762340675f0dbb29622">read</a>();
<aname="l00050"></a>00050 <spanclass="keywordflow">if</span> (-1 == c)
<aname="l00077"></a>00077 <spanclass="comment">// split the input line into tokens</span>
<aname="l00078"></a>00078 argc = 0;
<aname="l00079"></a>00079 _argv[argc++].<aclass="code"href="struct_menu_1_1arg.html#ad5a8d057d82e7300c34b648c796c8df4"title="string form of the argument">str</a> = strtok_r(_inbuf, <spanclass="stringliteral">""</span>, &s);
<aname="l00080"></a>00080 <spanclass="comment">// XXX should an empty line by itself back out of the current menu?</span>
<aname="l00081"></a>00081 <spanclass="keywordflow">while</span> (argc <= <aclass="code"href="menu_8h.html#a78a3dfeac59b72f430d58683a06644fe"title="maximum number of arguments">MENU_ARGS_MAX</a>) {
<aname="l00082"></a>00082 _argv[argc].<aclass="code"href="struct_menu_1_1arg.html#ad5a8d057d82e7300c34b648c796c8df4"title="string form of the argument">str</a> = strtok_r(NULL, <spanclass="stringliteral">""</span>, &s);
<aname="l00085"></a>00085 _argv[argc].<aclass="code"href="struct_menu_1_1arg.html#ad6913164599db6376da758a0f1a9ee1c"title="integer form of the argument (if a number)">i</a> = atol(_argv[argc].str);
<aname="l00086"></a>00086 _argv[argc].<aclass="code"href="struct_menu_1_1arg.html#aee33499a1cd6a4edfe5c5b8e6cf42766"title="floating point form of the argument (if a number)">f</a> = atof(_argv[argc].str); <spanclass="comment">// calls strtod, > 700B !</span>
<aname="l00087"></a>00087 argc++;
<aname="l00088"></a>00088 }
<aname="l00089"></a>00089
<aname="l00090"></a>00090 <spanclass="comment">// populate arguments that have not been specified with "" and 0</span>
<aname="l00091"></a>00091 <spanclass="comment">// this is safer than NULL in the case where commands may look</span>
<aname="l00092"></a>00092 <spanclass="comment">// without testing argc</span>
<aname="l00093"></a>00093 i = argc;
<aname="l00094"></a>00094 <spanclass="keywordflow">while</span> (i <= <aclass="code"href="menu_8h.html#a78a3dfeac59b72f430d58683a06644fe"title="maximum number of arguments">MENU_ARGS_MAX</a>) {
<aname="l00095"></a>00095 _argv[i].<aclass="code"href="struct_menu_1_1arg.html#ad5a8d057d82e7300c34b648c796c8df4"title="string form of the argument">str</a> = <spanclass="stringliteral">""</span>;
<aname="l00096"></a>00096 _argv[i].<aclass="code"href="struct_menu_1_1arg.html#ad6913164599db6376da758a0f1a9ee1c"title="integer form of the argument (if a number)">i</a> = 0;
<aname="l00097"></a>00097 _argv[i].<aclass="code"href="struct_menu_1_1arg.html#aee33499a1cd6a4edfe5c5b8e6cf42766"title="floating point form of the argument (if a number)">f</a> = 0;
<aname="l00098"></a>00098 i++;
<aname="l00099"></a>00099 }
<aname="l00100"></a>00100
<aname="l00101"></a>00101 <spanclass="comment">// look for a command matching the first word (note that it may be empty)</span>
<aname="l00102"></a>00102 <spanclass="keywordflow">for</span> (i = 0; i < _entries; i++) {
Generated for ArduPilot Libraries by <ahref="http://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.png"alt="doxygen"/></a></small></address>