Where do I find information on the shell library used in the demo?
I cannot find the source code, documents etc
Solved! Go to Solution.
Hi,
you will find shell sources in:
<MQX_INSTALL_DIR>\shell\source\..
Using shell is quite easy:
#include <shell.h>
const SHELL_COMMAND_STRUCT Shell_commands[] = { { "command_name", command_ptr}, { "?", Shell_command_list }, { NULL, NULL } };
if "command_name" is typed into shell console (IO_STDIN, IO_STDOUT), command_ptr function is called. You can implement your own command function. There are also prepared functions for working with mfs, rtcs, and mqx (sh_tad) - see sh_mfs.h, sh_rtcs.h in"\shell\source\include" directory.
Shell(Shell_commands, NULL);
For example of usage see web_hvac demo, especially files - Shell_Task.c and Command_Lists.c. Do not forgot to enable DEMOCFG_ENABLE_SERIAL_SHELL in HVAC.h.
Hi,
you will find shell sources in:
<MQX_INSTALL_DIR>\shell\source\..
Using shell is quite easy:
#include <shell.h>
const SHELL_COMMAND_STRUCT Shell_commands[] = { { "command_name", command_ptr}, { "?", Shell_command_list }, { NULL, NULL } };
if "command_name" is typed into shell console (IO_STDIN, IO_STDOUT), command_ptr function is called. You can implement your own command function. There are also prepared functions for working with mfs, rtcs, and mqx (sh_tad) - see sh_mfs.h, sh_rtcs.h in"\shell\source\include" directory.
Shell(Shell_commands, NULL);
For example of usage see web_hvac demo, especially files - Shell_Task.c and Command_Lists.c. Do not forgot to enable DEMOCFG_ENABLE_SERIAL_SHELL in HVAC.h.
Hi,
I'm trying to make my own shell commands, but I can not figure out how to build the files I've created.
I wrote sh_myowncmd.c and sh_myowncmd.h, but I always get the errors:
undefined identifier 'Shell_mycmd'
the file 'sh_myowncmd.h' cannot be opened
I've tried to put the files into the "/Shell" source path but nothing happens
I also tried to edit and rebuild the "Shell source/.project" file, adding my files into it, but didn't work...
where I should put my source files?
Are there some document which explain how the mqx libraries work, and how I can add new ones?
I've checked the hvac example but i do not understand how it works...
best regards
When building an MQX application, compiler searches into /lib directory for the MQX include header files and libraries. For your own shell functions, just simply add them into your application project, not to the MQX library project.
If you used Freescale CodeWarrior for MCU, I would recommend to create a new application using the CW New Project Wizard for MQX. In a new empty workspace, go to File->New->MQX 4.0 Project and then in next steps
-enter the name of your new application
-select the board you will be using
-select New Application
-select Freescale compiler in case of Kinetis (GCC use only with MQX 4.0.1)
-check "Add Shell Support"
-select "Basic Application"
-check "Create shell command structure"
In the generated project, see main.c. There is the following structure defined:
const SHELL_COMMAND_STRUCT Shell_commands[] = {
/* Add your custom shell commands here */
/* { "command_name", Your_function }, */
{ "sh", Shell_sh },
{ "help", Shell_help },
{ "?", Shell_command_list },
{ "exit", Shell_exit },
{ NULL, NULL },
};
and you can start adding your commands, for example:
const SHELL_COMMAND_STRUCT Shell_commands[] = {
/* Add your custom shell commands here */
/* { "command_name", Your_function }, */
{ "mycmd", Shell_mycmd }
{ "sh", Shell_sh },
{ "help", Shell_help },
{ "?", Shell_command_list },
{ "exit", Shell_exit },
{ NULL, NULL },
};
Then you need to define your "Shell_mycmd" function. In may look like this:
int_32 Shell_mycmd (int_32 argc, char_ptr argv[])
{
boolean print_usage, shorthelp = FALSE;
print_usage = Shell_check_help_request(argc, argv, &shorthelp );
if(!print_usage)
{
MyFunc0();
}
if (print_usage)
{
if (shorthelp)
{
printf("%s\n", argv[0]);
}
else
{
printf("Usage: %s\n", argv[0]);
}
}
return SHELL_EXIT_SUCCESS;
}
where "MyFunc0" is the user function to be called and implementataon of "print_usage" conditions you can put your own help text.
Thank you so much...
I tried and it works fine...