Difference between revisions of "Shell"

From Embedded Xinu
Jump to navigation Jump to search
(→‎How it works: - Grammar change)
(→‎Running commands: - formatting; added clear command)
Line 9: Line 9:
 
The current distribution of the XINU shell is equipped with some basic commands.  The majority of the commands provide information about the current state of the system including its processes, memory, and hardware.  A full list of commands can be obtained from the shell by using the <code>help</code> command.  Help on a specific command can be obtained using <code>COMMAND --help</code> or <code>help COMMAND</code>.
 
The current distribution of the XINU shell is equipped with some basic commands.  The majority of the commands provide information about the current state of the system including its processes, memory, and hardware.  A full list of commands can be obtained from the shell by using the <code>help</code> command.  Help on a specific command can be obtained using <code>COMMAND --help</code> or <code>help COMMAND</code>.
  
* '''exit''': quits the XINU shell
+
* <code>clear</code>: clears the shell
* '''gpiostat''': displays the current status of the [[GPIO]] pins
+
* <code>exit</code>: quits the XINU shell
* '''help''': displays a list of commands in the XINU shell
+
* <code>gpiostat</code>: displays the current status of the [[GPIO]] pins
* '''kill PID''': kills a process number PID
+
* <code>help</code>: displays a list of commands in the XINU shell
* '''memstat''': displays the current memory usage and prints the free list
+
* <code>kill PID</code>: kills a process number <code>PID</code>
* '''memdump''': dumps a region of memory
+
* <code>led DESCRIPTOR STATUS</code>: turns an led on or off
* '''led DESCRIPTOR STATUS''': turns an led on or off
+
* <code>memstat</code>: displays the current memory usage and prints the free list
* '''ps''': displays a table of running processes
+
* <code>memdump</code>: dumps a region of memory
* '''reset''': soft powercycles the backend
+
* <code>ps</code>: displays a table of running processes
* '''sleep DELAY''': sleep for DELAY seconds
+
* <code>reset</code>: soft powercycles the backend
* '''uartstat UARTNUM''': displays statistics for [[UART | uart]] UARTNUM
+
* <code>sleep DELAY</code>: sleep for <code>DELAY</code> seconds
* '''test''': can be used for building test programs, all builds should simply return OK
+
* <code>test</code>: can be used for building test programs, all builds should simply return <code>OK</code>
* '''testsuite''': run a series of tests to see if the system is functioning properly
+
* <code>testsuite</code>: run a series of tests to see if the system is functioning properly
 +
* <code>uartstat UARTNUM</code>: displays statistics for [[UART | uart]] <code>UARTNUM</code>

Revision as of 20:36, 20 September 2007

The XINU shell is a subsystem designed as an interface for interacting with the operating system.

How it works

The shell relies on the TTY driver to receive user input and provide output to the user. When XINU starts, a shell process is spawned on each serial port (or TTY). When a user enters a command the lexan function divides the string of input into tokens. Command name, arguments, quoted strings, backgrounding, and redirection tokens are all recognized and divided by lexan.

After the command is parsed, the shell uses the tokens to properly execute the given command. The shell first checks for the backgrounding ampersand ('&'), which should only appear as the last token. The shell is designed to handle redirection, but does not currently do so since XINU's file system is in development. Next, the command is looked up in the command table defined at the top of shell.c. Each entry in the command table follows the format of command name, is the command built-in (ie can the command run in the background), and the function that executes the command: {"command_name", TRUE / FALSE, xsh_function},. Built-in commands are executed by calling the function that implements the command. All other commands are executed by creating a new process. If the user did not include the backgrounding flag in the input, the shell waits until the command process has completed before asking for more input.

Running commands

The current distribution of the XINU shell is equipped with some basic commands. The majority of the commands provide information about the current state of the system including its processes, memory, and hardware. A full list of commands can be obtained from the shell by using the help command. Help on a specific command can be obtained using COMMAND --help or help COMMAND.

  • clear: clears the shell
  • exit: quits the XINU shell
  • gpiostat: displays the current status of the GPIO pins
  • help: displays a list of commands in the XINU shell
  • kill PID: kills a process number PID
  • led DESCRIPTOR STATUS: turns an led on or off
  • memstat: displays the current memory usage and prints the free list
  • memdump: dumps a region of memory
  • ps: displays a table of running processes
  • reset: soft powercycles the backend
  • sleep DELAY: sleep for DELAY seconds
  • test: can be used for building test programs, all builds should simply return OK
  • testsuite: run a series of tests to see if the system is functioning properly
  • uartstat UARTNUM: displays statistics for uart UARTNUM