Skip to content
nyannkov edited this page Jul 1, 2020 · 4 revisions

mshell is a module to help you create a simple shell.This module is useful if you want to interact with a target device using a UART or CDC, for example.
There are two modes described below in mshell.

1. Hex mode

This mode is effective when you want to directly talk to an IC such as YMF825 that has SPI communication interface.
If you send <LF> after sending the hexadecimal string, the receiving device will parse the value. If parsing is successful, call the registered callback process. Numerical information after conversion is passed to the argument of the callback process. Callback functions can be registered by the following functions:

void mshell_register_hexmode_recv_callback(const pf_mshell_hexmode_recv_callback_t callback); 

For example, if you send a 4-byte hexadecimal string "073A" and <LF>, the converted numeric array will be {0x07, 0x3A}(2 Byte). Note that the hexadecimal character string part to be sent is a multiple of 2 bytes. For example, if you send a 3-byte hexadecimal character string "012" and <LF>, a parse error will occur and the callback process will not be executed.

2. Command mode

Entering a colon (:) at startup or after sending <LF> switches to command mode. The character string is decomposed with spaces and tabs as delimiters and arranged into an array. The array of strings and the number of arrays are passed to the function:

int mshell_execute_command(int argc, char *argv[]);

This function should be defined by the user according to the purpose. A sample of mshell_execute_command () function is defined in mshell_cmd_sample.c, so please refer to it.

Clone this wiki locally