Remove cat command from shell

This commit is contained in:
Mario Hüttel 2021-02-15 20:35:54 +01:00
parent 694a78982a
commit 8a764f599b

View File

@ -334,57 +334,6 @@ static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, co
return SHELLMATTA_BUSY; return SHELLMATTA_BUSY;
} }
static shellmatta_retCode_t shell_cmd_cat(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
#ifdef IMPLEMENT_SHELL_CAT
FIL file;
char path_buff[256];
const char *path;
UINT bytes_read;
FRESULT res;
strncpy(path_buff, arguments, MIN(sizeof(path_buff), length));
path_buff[MIN(length, sizeof(path_buff)-1)] = 0;
path = strtok(path_buff, " ");
path = strtok(NULL, " ");
if (strlen(path) == 0) {
shellmatta_printf(handle, "Specify path!\r\n");
return SHELLMATTA_OK;
}
res = f_open(&file, path, FA_READ);
if (res == FR_OK) {
shellmatta_write(handle, "\r\n", 2U);
do {
res = f_read(&file, path_buff, sizeof(path_buff), &bytes_read);
if (bytes_read > 0)
shellmatta_write(handle, path_buff, bytes_read);
else
break;
} while (res == FR_OK);
shellmatta_write(handle, "\r\n", 2U);
}
if (res != FR_OK) {
shellmatta_printf(handle, "Error reading file\r\n");
}
f_close(&file);
#else
(void)length;
(void)arguments;
shellmatta_printf(handle, "cat not implemented!\r\n");
#endif
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handle, const char *arguments, static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handle, const char *arguments,
uint32_t length) uint32_t length)
{ {
@ -701,7 +650,7 @@ shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const ch
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */ // shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */ // struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t; //} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[20] = { static shellmatta_cmd_t cmd[19] = {
{ {
.cmd = "version", .cmd = "version",
.cmdAlias = "ver", .cmdAlias = "ver",
@ -790,21 +739,13 @@ static shellmatta_cmd_t cmd[20] = {
.cmdFct = shell_cmd_reset, .cmdFct = shell_cmd_reset,
.next = &cmd[11], .next = &cmd[11],
}, },
{
.cmd = "cat",
.cmdAlias = NULL,
.helpText = "Print file contents",
.usageText = "cat <path>",
.cmdFct = shell_cmd_cat,
.next = &cmd[12],
},
{ {
.cmd = "safety-flags", .cmd = "safety-flags",
.cmdAlias = "flags", .cmdAlias = "flags",
.helpText = "Reads and may clear safety flags", .helpText = "Reads and may clear safety flags",
.usageText = "flags [--ack]", .usageText = "flags [--ack]",
.cmdFct = shell_cmd_read_flags, .cmdFct = shell_cmd_read_flags,
.next = &cmd[13], .next = &cmd[12],
}, },
{ {
.cmd = "save-calibration", .cmd = "save-calibration",
@ -812,7 +753,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "", .helpText = "",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_save_cal, .cmdFct = shell_cmd_save_cal,
.next = &cmd[14], .next = &cmd[13],
}, },
{ {
.cmd = "hang", .cmd = "hang",
@ -820,7 +761,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "", .helpText = "",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_hang, .cmdFct = shell_cmd_hang,
.next = &cmd[15], .next = &cmd[14],
}, },
{ {
.cmd = "ui-emulate", .cmd = "ui-emulate",
@ -828,7 +769,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "", .helpText = "",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_ui_emulation, .cmdFct = shell_cmd_ui_emulation,
.next = &cmd[16], .next = &cmd[15],
}, },
{ {
.cmd = "panic", .cmd = "panic",
@ -836,7 +777,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "Panic Mode!", .helpText = "Panic Mode!",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_panic, .cmdFct = shell_cmd_panic,
.next = &cmd[17], .next = &cmd[16],
}, },
{ {
.cmd = "safety-mem-dump", .cmd = "safety-mem-dump",
@ -844,7 +785,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "", .helpText = "",
.usageText = "safety-mem-dump [output-file]", .usageText = "safety-mem-dump [output-file]",
.cmdFct = shell_cmd_dump_safety_mem, .cmdFct = shell_cmd_dump_safety_mem,
.next = &cmd[18], .next = &cmd[17],
}, },
{ {
.cmd = "reset-cal", .cmd = "reset-cal",
@ -852,7 +793,7 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "Reset Calibration", .helpText = "Reset Calibration",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_reset_cal, .cmdFct = shell_cmd_reset_cal,
.next = &cmd[19], .next = &cmd[18],
}, },
{ {
.cmd = "update", .cmd = "update",