<ahref="shell_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00037"></a>00037 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00074"></a>00074 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Usage: "</span>);
<aname="l00075"></a>00075 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, p);
<aname="l00081"></a>00081 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, scp-><aclass="code"href="struct_shell_command.html#afb689607842aa2cf6844eebdb8b36236"title="Command name.">sc_name</a>);
<aname="l00082"></a>00082 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">""</span>);
<aname="l00095"></a>00095 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Kernel version: "</span>);
<aname="l00096"></a>00096 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <aclass="code"href="group__kernel__info.html#gaf90f447ef5aa797647cbe5d1a6a958c3"title="Kernel version string.">CH_KERNEL_VERSION</a>);
<aname="l00098"></a>00098 <spanclass="preprocessor"></span><aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"GCC Version: "</span>);
<aname="l00099"></a>00099 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, __VERSION__);
<aname="l00101"></a>00101 <spanclass="preprocessor"></span><aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Architecture: "</span>);
<aname="l00102"></a>00102 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <aclass="code"href="group__core.html#gaee128c531d64d5a635def6857fef3179"title="Name of the implemented architecture.">CH_ARCHITECTURE_NAME</a>);
<aname="l00104"></a>00104 <spanclass="preprocessor"></span><aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Core Variant: "</span>);
<aname="l00105"></a>00105 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <aclass="code"href="group___a_v_r___c_o_r_e.html#gad807bcd87b78f852f9cdf25022c0f11b"title="Name of the architecture variant (optional).">CH_CORE_VARIANT_NAME</a>);
<aname="l00108"></a>00108 <spanclass="preprocessor"></span><aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Platform: "</span>);
<aname="l00109"></a>00109 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <aclass="code"href="group___h_a_l___l_l_d.html#gaa4688daf0f1e6dda714351a6e5a394c2"title="Platform name.">PLATFORM_NAME</a>);
<aname="l00112"></a>00112 <spanclass="preprocessor"></span><aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Board: "</span>);
<aname="l00113"></a>00113 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, BOARD_NAME);
<aname="l00125"></a>00125 sprintf(buf, <spanclass="stringliteral">"%lu"</span>, (<spanclass="keywordtype">unsigned</span><spanclass="keywordtype">long</span>)<aclass="code"href="group__time.html#ga137c8f67c450f34416a786d169be90e2"title="Current system time.">chTimeNow</a>());
<aname="l00126"></a>00126 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, buf);
<aname="l00159"></a>00159 <spanclass="keyword">static</span><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> shell_thread(<spanclass="keywordtype">void</span> *p) {
<aname="l00161"></a>00161 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg = RDY_OK;
<aname="l00165"></a>00165 <spanclass="keywordtype">char</span> *args[<aclass="code"href="group___s_h_e_l_l.html#ga730dd92884d4fce406efb6678aea8062"title="Shell maximum arguments per command.">SHELL_MAX_ARGUMENTS</a> + 1];
<aname="l00166"></a>00166
<aname="l00167"></a>00167 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">""</span>);
<aname="l00168"></a>00168 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">"ChibiOS/RT Shell"</span>);
<aname="l00170"></a>00170 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"ch>"</span>);
<aname="l00171"></a>00171 <spanclass="keywordflow">if</span> (<aclass="code"href="group___s_h_e_l_l.html#ga1c7aadcfefdc616bd8450117b6972274"title="Reads a whole line from the input channel.">shellGetLine</a>(chp, line, <spanclass="keyword">sizeof</span>(line))) {
<aname="l00172"></a>00172 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"\nlogout"</span>);
<aname="l00179"></a>00179 <spanclass="keywordflow">if</span> (n >= <aclass="code"href="group___s_h_e_l_l.html#ga730dd92884d4fce406efb6678aea8062"title="Shell maximum arguments per command.">SHELL_MAX_ARGUMENTS</a>) {
<aname="l00180"></a>00180 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">"too many arguments"</span>);
<aname="l00196"></a>00196 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"Commands: help exit "</span>);
<aname="l00200"></a>00200 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">""</span>);
<aname="l00201"></a>00201 }
<aname="l00202"></a>00202 <spanclass="keywordflow">else</span><spanclass="keywordflow">if</span> (cmdexec(local_commands, chp, cmd, n, args) &&
<aname="l00204"></a>00204 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, cmd);
<aname="l00205"></a>00205 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">" ?"</span>);
<aname="l00206"></a>00206 }
<aname="l00207"></a>00207 }
<aname="l00208"></a>00208 }
<aname="l00209"></a>00209 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00210"></a>00210 <aclass="code"href="group__events.html#gaa24d9bed5b676b577200c4a8ebe3b8a3"title="Signals all the Event Listeners registered on the specified Event Source.">chEvtBroadcastI</a>(&shell_terminated);
<aname="l00219"></a>00219 <aclass="code"href="group__events.html#gab8d0fdc09be629dfb438c32a0523db42"title="Initializes an Event Source.">chEvtInit</a>(&shell_terminated);
<aname="l00232"></a>00232 <aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *<aclass="code"href="group___s_h_e_l_l.html#gaa1ede2e94e6d3eba37cdda717f6c1656"title="Spawns a new shell.">shellCreate</a>(<spanclass="keyword">const</span><aclass="code"href="struct_shell_config.html"title="Shell descriptor type.">ShellConfig</a> *scp, <spanclass="keywordtype">size_t</span> size, <aclass="code"href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee"title="Priority, use the fastest unsigned type.">tprio_t</a> prio) {
<aname="l00233"></a>00233
<aname="l00234"></a>00234 <spanclass="keywordflow">return</span><aclass="code"href="group__threads.html#ga50b84e3e82a4e09c1066e1d422e4c780"title="Creates a new thread allocating the memory from the heap.">chThdCreateFromHeap</a>(NULL, size, prio, shell_thread, (<spanclass="keywordtype">void</span> *)scp);
<aname="l00255"></a>00255 <spanclass="keywordtype">void</span><aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(<aclass="code"href="struct_base_channel.html"title="Base channel class.">BaseChannel</a> *chp, <spanclass="keyword">const</span><spanclass="keywordtype">char</span> *msg) {
<aname="l00256"></a>00256
<aname="l00257"></a>00257 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, msg);
<aname="l00258"></a>00258 <aclass="code"href="group___s_h_e_l_l.html#ga4660b06c861d5506fb35d9844e2d8288"title="Prints a string.">shellPrint</a>(chp, <spanclass="stringliteral">"\r\n"</span>);
<aname="l00272"></a>00272 <aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a><aclass="code"href="group___s_h_e_l_l.html#ga1c7aadcfefdc616bd8450117b6972274"title="Reads a whole line from the input channel.">shellGetLine</a>(<aclass="code"href="struct_base_channel.html"title="Base channel class.">BaseChannel</a> *chp, <spanclass="keywordtype">char</span> *line, <spanclass="keywordtype">unsigned</span> size) {
<aname="l00280"></a>00280 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">"^D"</span>);
<aname="l00293"></a>00293 <aclass="code"href="group___s_h_e_l_l.html#ga7bffb6aa1f0ec1e12dfaa86c3b692330"title="Prints a string with a final newline.">shellPrintLine</a>(chp, <spanclass="stringliteral">""</span>);
Generated on Sun Oct 24 2010 09:40:37 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>