Add correct handling of sd card, add reset command, add ls command
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stm32/stm32f4xx.h>
|
||||
#include <cmsis/core_cm4.h>
|
||||
#include <reflow-controller/shell.h>
|
||||
#include <stm-periph/uart.h>
|
||||
#include <string.h>
|
||||
@@ -30,7 +32,7 @@
|
||||
#include <stm-periph/unique-id.h>
|
||||
#include <reflow-controller/calibration.h>
|
||||
#include <reflow-controller/temp-converter.h>
|
||||
|
||||
#include <fatfs/ff.h>
|
||||
#include <reflow-controller/stack-check.h>
|
||||
#include <reflow-controller/rotary-encoder.h>
|
||||
|
||||
@@ -290,6 +292,43 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)length;
|
||||
(void)arguments;
|
||||
DIR dir;
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
|
||||
res = f_opendir(&dir, "/");
|
||||
if (res != FR_OK) {
|
||||
shellmatta_printf(handle, "Filesystem inaccessible. Is an SD Card inserted?\r\n");
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
while (f_readdir(&dir, &fno) == FR_OK) {
|
||||
if (fno.fname[0] == 0)
|
||||
break;
|
||||
shellmatta_printf(handle, "%c\t%s\r\n", (fno.fattrib & AM_DIR ? 'd' : 'f'), fno.fname);
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)handle;
|
||||
(void)length;
|
||||
(void)arguments;
|
||||
|
||||
NVIC_SystemReset();
|
||||
|
||||
return SHELLMATTA_BUSY;
|
||||
}
|
||||
//typedef struct shellmatta_cmd
|
||||
//{
|
||||
// char *cmd; /**< command name */
|
||||
@@ -300,7 +339,7 @@ static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t
|
||||
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
||||
//} shellmatta_cmd_t;
|
||||
|
||||
static shellmatta_cmd_t cmd[10] = {
|
||||
static shellmatta_cmd_t cmd[12] = {
|
||||
{
|
||||
.cmd = "version",
|
||||
.cmdAlias = "ver",
|
||||
@@ -379,8 +418,25 @@ static shellmatta_cmd_t cmd[10] = {
|
||||
.helpText = "Get current rotary encoder value",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_rot,
|
||||
.next = &cmd[10],
|
||||
},
|
||||
{
|
||||
.cmd = "ls",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "List filesystem contents",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_ls,
|
||||
.next = &cmd[11],
|
||||
},
|
||||
{
|
||||
.cmd = "reset",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "Reset controller",
|
||||
.usageText = "Resets the controller",
|
||||
.cmdFct = shell_cmd_reset,
|
||||
.next = NULL,
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
||||
@@ -396,6 +452,12 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
||||
return handle;
|
||||
}
|
||||
|
||||
void shell_print_motd(shellmatta_handle_t shell)
|
||||
{
|
||||
shellmatta_printf(shell, "\r\nShimatta 仕舞った Reflow Controller ready\r\n\r\n");
|
||||
shell_cmd_ver(shell, NULL, 0UL);
|
||||
shell_handle_input(shell, "\r\n", 2UL);
|
||||
}
|
||||
|
||||
void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len)
|
||||
{
|
||||
|
Reference in New Issue
Block a user