VxWorks Shell is also called the kernel shell, that is, the shell program running on the Development Board, can be connected via serial port or Telnet on the host, the shell input I can see the "Tshell" task (depending on the name of the creation), this is the kernel shell task.
C-language interpreter and command interpreter
The kernel shell contains 2 interpreters, the C language interpreter and the command interpreter.
The shell, preceded by "->", represents the C language interpreter, preceded by "[VxWorks *]#", which represents the command interpreter.)
The C language interpreter can invoke functions in the program via the function name (these functions are in the system symbol table, the system symbol table is explained to another blog post), so you can use it to invoke a function directly in the shell to debug. For example, the input Help will display the aid information, and the end will also output the value = 1 = 0x1, in fact, helps is a function defined in the kernel (see the System symbol table will find a helping function), in the C language interpreter, the input can call the kernel's helper function. The last function returns a value of 1. Common debugging functions under the shell, such as B, TT, and so on, are defined in the Dbglib library, and other commands are similar.
Questions:
C language interpreter for functions that are not in the symbol table, can be called by the NM tool to get the address, this is not known how to use.
The difference between the kernel shell and the host shell
The kernel shell is called, because there is also a host shell, that is, the host shell running on the computer workbench needs to be differentiated.
The difference between the two shells is that one runs on the computer and one runs on the Development Board, so the host shell uses the mainframe resources (such as lkup (), LD () and so on to request memory, and the kernel shell uses the Developer board kernel resources. The host shell on the computer supports more interpreters than the Development Board kernel shell, such as supporting the TCL interpreter (preceded by "tcl>"), the GDB interpreter (preceded by "(GDB)"), and so on. In short, each has its own advantages, can be used.
Also, when you enter x = "Hello there" in the shell, the shell will dynamically request memory instead of automatically releasing it, so in order to prevent memory leaks, it is best to use free (x) after running out. If you enter a string that is not associated with a variable, it will also request memory and will not be released. such as printf ("Hello there") can be released using the Strfree () function.
Questions:
I enter the CD "E:" on the kernel shell of my Development Board, and then enter PWD to display the host:e:, the kernel shell supports access to the host, how it is implemented.
Setting Configuration variables
The shell's configuration variable can be used to set up a different shell (a shell can be used by multiple users with different configuration variables). The shell's configuration variable (shelllib definition) differs from the VxWorks environment variable (envlib definition).? The Shconfig command can view the configuration variables for the current shell.
->? shconfig
Allow_host_path_search = On
Bp_print = On
Cplus_sym_match = Off
C_output_get = Off
Dsm_hex_mode = Off
Exc_print = On
Interpreter = C
Ld_call_xtors = target
Ld_common_match_all = On
Ld_path =.
Ld_send_modules = On
Ld_unload_first = On
......
Some commonly used variables are defined in the configuration variable. If interpreter defines which interpreter (c) to use, Line_edit_mode defines what row-editing mode (vi) to use, line_length how long to set the shell line (256), and so on. The values of these configuration variables are determined by the configuration of the VxWorks kernel and the definitions in the WPJ file, and, of course, by the Shell's commands, such as [vxworks]# set config line_edit_mode= "emacs".
Creating a kernel Shell
program, the Shellgenericinit function can create a shell, such as
result = Shellgenericinit (null, 0x10000, "Tshell", NULL, TRUE, FALSE, Ioglobalstdget (std_in), Ioglobalstdget (std_out), I Oglobalstdget (Std_err));
The above function creates a shell named Tshell, with a stack size of 64k and input output as standard IO. Please refer to the definition in Shelllib for specific parameters.
The control character of the shell
Specific definition please Baidu search "VxWorks operating system shell command and debugging method Summary", you can see.
One of the more useful is ctrl+d, you can complement the full function name, so when you call the function does not need to remember the full function name, Ctrl+d can automatically search the completion.
If the shell dies, press CTRL + C to reboot.
Interpreter conversion:
You can switch between interpreters by entering the following characters (you need to support this interpreter):
CMD: Switch to command interpreter
C: Switch to C language interpreter
。 : Switch to TCL interpreter
GDB: Switch to the GDB interpreter
Of course, you can also not switch direct calls, such as:
Invoke the command interpreter in the-> cmd EMACS:C interpreter
[VxWorks *]# C Moduleshow: Calling the C interpreter in the command interpreter
The shell's automatic printing function dprintf
The dprintf function enables automatic printing of global variables.
Global variables can be printed under the kernel shell, and the dprintf function allows printing to be printed automatically, eliminating the hassle of repetitive typing. Please refer to the test example below for specific usage:
Write a C file:
#include <vxWorks.h>
#include <stdio.h>
#include <sysLib.h>
#include <taskLib.h>
int myintvar = 0;
Long long int mylonglongvar = 0;
char * myString;
void Myloop (void)
{
Myintvar + +;
Mylonglongvar + 10;
sprintf (myString, "%d%lld", Myintvar, Mylonglongvar);
}
void MyTest (void)
{
myString = malloc (100);
Mystring[0] = EOS;
while (1)
{
Myloop ();
Taskdelay (Sysclkrateget ());
}
}
Enter the command to implement the automatic printing of variables:
-> LD < MYTEST.O
Value = 1634729040 = 0X616FFC50 = ' P '
-> dprintf myloop,0,0, "Myintvar =%d\n", &myintvar
Value = 0 = 0x0
-> dprintf myloop,0,0, "Mylonglongvar =%lld\n", &mylonglongvar
Value = 0 = 0x0
-> dprintf myloop,0,0, "string =%s\n", &mystring
Value = 0 = 0x0
-> dprintf myloop,0,0, "int =%d, Llong =%lld, String =%s\n",
&myintvar, &mylonglongvar, &mystring
Value = 0 = 0x0
-> SP MyTest
Task spawned:id = 0x604c1a38, name = T1 value = 1615600184 = 0x604c1a38 = ' 8 ' =
MyString + 0X6C8
-> 0x604c1a38 (t1): Myintvar = 0
0x604c1a38 (t1): Mylonglongvar = 0
0x604c1a38 (t1): string =
0x604c1a38 (t1): int = 0, Llong = 0, String =
0x604c1a38 (t1): Myintvar = 1
0x604c1a38 (t1): Mylonglongvar = 10
0x604c1a38 (t1): string = 1 10
0x604c1a38 (t1): int = 1, Llong = ten, string = 1 10
0x604c1a38 (t1): Myintvar = 2
0x604c1a38 (t1): Mylonglongvar = 20
0x604c1a38 (t1): string = 2 20
0x604c1a38 (t1): int = 2, Llong = m, string = 2 20
0x604c1a38 (t1): Myintvar = 3
0x604c1a38 (t1): Mylonglongvar = 30
0x604c1a38 (t1): string = 3 30
0x604c1a38 (t1): int = 3, Llong =, string = 3 30
0x604c1a38 (t1): Myintvar = 4
0x604c1a38 (t1): Mylonglongvar = 40
0x604c1a38 (t1): string = 4 40
0x604c1a38 (t1): int = 4, Llong =, string = 4 40
0x604c1a38 (t1): Myintvar = 5
0x604c1a38 (t1): Mylonglongvar = 50
0x604c1a38 (t1): string = 5 50
0x604c1a38 (t1): int = 5, Llong = m, string = 5 50
Creating User commands and interpreters
Users can also create their own shell commands and interpreters.
command to create a reference INSTALLDIR/VXWORKS-6.X/TARGET/SRC/DEMO/SHELL/TUTORIALSHELLCMD.C file.
The interpreter creates a reference installdir/vxworks-6.x/target/src/demo/shell/shellinterpdemo.c file.
This article refers to the official document "VxWorks Kernel Shell Users Guide 6.9" chapter II kernel shell, for their own summary, may be misunderstood, for reference only.