<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Own Shell Commands? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165504#M1553</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK - that's what I found out so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Example code for my own command (i.e. entry in SHELL_COMMAND_STRUCT is&amp;nbsp;{ "debug", my_command })&lt;/LI&gt;&lt;/UL&gt;&lt;UL&gt;&lt;LI&gt;my_command function defined like below&lt;/LI&gt;&lt;LI&gt;Shell_check_help_request returns true if&amp;nbsp;argc=3 &amp;amp;&amp;amp; argv[1]== "help" and sets shorthelp to TRUE if&amp;nbsp;argc=3 &amp;amp;&amp;amp; argv[1]== "help" &amp;amp;&amp;amp; argv[2]=="short" - but this is just a detail&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int_32 my_command(int_32 argc, char_ptr argv[])&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; boolean print_usage = FALSE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; boolean shorthelp = FALSE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; int_32&amp;nbsp; return_code = MQX_OK;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print_usage = Shell_check_help_request(argc, argv, &amp;amp;shorthelp);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (!print_usage)&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int_32 idx = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (idx = 0; idx &amp;lt; argc; idx++) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("argv[%d] = %s\n", idx, argv[idx]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // add here implementation of this command&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("G3_debug has been called!\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; } else if (print_usage) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (shorthelp)&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%s &amp;lt;arg1&amp;gt; [&amp;lt;arg2&amp;gt;]\n", argv[0]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Usage: %s &amp;lt;arg1&amp;gt; [&amp;lt;arg2&amp;gt;]\n", argv[0]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return return_code;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I guess I found out myself how to use this function - nonetheless: If somebody could point me to some documentation, that could be of value for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;NeraPhil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 May 2012 20:35:03 GMT</pubDate>
    <dc:creator>NeraPhil</dc:creator>
    <dc:date>2012-05-22T20:35:03Z</dc:date>
    <item>
      <title>Own Shell Commands?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165503#M1552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a description on how to implement my own shell commands:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;the standard shell commands (like Shell_cd etc.) work fine (based on the rtcs shell demo application)&lt;/LI&gt;&lt;LI&gt;I now want to provide my own shell commands&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I have added my command to the SHELL_COMMAND_STRUCT. But now:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;How can I access the shell attributes for my command?&lt;/LI&gt;&lt;LI&gt;How and where can I define the help text for my command?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;My MQX version is 3.8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice?&lt;/P&gt;&lt;P&gt;Cheers NeraPhil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 19:32:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165503#M1552</guid>
      <dc:creator>NeraPhil</dc:creator>
      <dc:date>2012-05-22T19:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Own Shell Commands?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165504#M1553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK - that's what I found out so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Example code for my own command (i.e. entry in SHELL_COMMAND_STRUCT is&amp;nbsp;{ "debug", my_command })&lt;/LI&gt;&lt;/UL&gt;&lt;UL&gt;&lt;LI&gt;my_command function defined like below&lt;/LI&gt;&lt;LI&gt;Shell_check_help_request returns true if&amp;nbsp;argc=3 &amp;amp;&amp;amp; argv[1]== "help" and sets shorthelp to TRUE if&amp;nbsp;argc=3 &amp;amp;&amp;amp; argv[1]== "help" &amp;amp;&amp;amp; argv[2]=="short" - but this is just a detail&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int_32 my_command(int_32 argc, char_ptr argv[])&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; boolean print_usage = FALSE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; boolean shorthelp = FALSE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; int_32&amp;nbsp; return_code = MQX_OK;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print_usage = Shell_check_help_request(argc, argv, &amp;amp;shorthelp);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (!print_usage)&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int_32 idx = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (idx = 0; idx &amp;lt; argc; idx++) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("argv[%d] = %s\n", idx, argv[idx]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // add here implementation of this command&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("G3_debug has been called!\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; } else if (print_usage) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (shorthelp)&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%s &amp;lt;arg1&amp;gt; [&amp;lt;arg2&amp;gt;]\n", argv[0]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Usage: %s &amp;lt;arg1&amp;gt; [&amp;lt;arg2&amp;gt;]\n", argv[0]);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return return_code;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I guess I found out myself how to use this function - nonetheless: If somebody could point me to some documentation, that could be of value for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;NeraPhil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 20:35:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165504#M1553</guid>
      <dc:creator>NeraPhil</dc:creator>
      <dc:date>2012-05-22T20:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Own Shell Commands?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165505#M1554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi NeraPhil,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just as a recap, the structure with new command my_command and function to be invoked if this command is typed on the shell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;const SHELL_COMMAND_STRUCT Shell_commands[] = {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {"my_command", my_command_function},&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {"exit", Shell_exit},&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {"help", Shell_help},&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {NULL, NULL}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Explanation how the shell is used in application:&lt;/P&gt;&lt;P&gt;print_usage purpose is to represent boolean value to print the help or to execute the command. If it's FALSE, then command was typed, otherwise (TRUE) help was requested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If help is typed without any following argument , number of arguments argc = 1 and argv[0] is help command. Value TRUE is stored in shorthelp.&lt;/P&gt;&lt;P&gt;Help with more arguments (help my_command), shorthelp holds FALSE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check an example which is using shell like HVAC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MartinK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 18:26:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Own-Shell-Commands/m-p/165505#M1554</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2012-05-23T18:26:45Z</dc:date>
    </item>
  </channel>
</rss>

