Compare commits

...

5 Commits

Author SHA1 Message Date
fe51c80248 Merge branch 'dev' into ui 2020-04-27 21:53:27 +02:00
e7106b54c4 Add cat command 2020-04-27 21:52:52 +02:00
119aa1b0ff Add main loop counter 2020-04-27 21:08:53 +02:00
415979e211 Merge branch 'dev' into ui 2020-04-27 20:20:03 +02:00
d91463c458 Make MOTD clear the screen 2020-04-27 20:19:49 +02:00
2 changed files with 67 additions and 5 deletions

View File

@ -132,7 +132,7 @@ static bool mount_sd_card_if_avail(bool mounted)
const char *oven_controller_hello_world = "Hello world :)\n";
static volatile enum button_state button;
static volatile uint32_t main_loops_per_ms;
int main()
{
bool sd_card_mounted = false;
@ -142,6 +142,9 @@ int main()
shellmatta_handle_t shell_handle;
int uart_receive_status;
uint32_t main_loop_cnt = 0UL;
uint64_t ms_stamp = 0ULL;
static struct pid_controller pid;
uint64_t pid_timestamp = 0;
@ -173,7 +176,11 @@ int main()
pid_zero(&pid);
while (1) {
if (systick_get_global_tick() - ms_stamp >= 1) {
ms_stamp = systick_get_global_tick();
main_loops_per_ms = main_loop_cnt;
main_loop_cnt = 0UL;
}
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value);
@ -191,6 +198,8 @@ int main()
uart_receive_status = uart_receive_data_with_dma(&shell_uart, &uart_input, &uart_input_len);
if (uart_receive_status >= 1)
shell_handle_input(shell_handle, uart_input, uart_input_len);
main_loop_cnt++;
}
}

View File

@ -330,6 +330,49 @@ static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, co
return SHELLMATTA_BUSY;
}
static shellmatta_retCode_t shell_cmd_cat(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
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);
return SHELLMATTA_OK;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@ -340,7 +383,7 @@ static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, co
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[12] = {
static shellmatta_cmd_t cmd[13] = {
{
.cmd = "version",
.cmdAlias = "ver",
@ -433,8 +476,16 @@ static shellmatta_cmd_t cmd[12] = {
.cmd = "reset",
.cmdAlias = NULL,
.helpText = "Reset controller",
.usageText = "Resets the controller",
.usageText = "reset",
.cmdFct = shell_cmd_reset,
.next = &cmd[12],
},
{
.cmd = "cat",
.cmdAlias = NULL,
.helpText = "Print file contents",
.usageText = "cat <path>",
.cmdFct = shell_cmd_cat,
.next = NULL,
}
@ -455,7 +506,9 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
void shell_print_motd(shellmatta_handle_t shell)
{
shellmatta_printf(shell, "\r\nShimatta 仕舞った Reflow Controller ready\r\n\r\n");
/* Clear display and set cursor to home position */
shellmatta_printf(shell, "\e[2J\e[H");
shellmatta_printf(shell, "Shimatta 仕舞った Reflow Controller ready\r\n\r\n");
shell_cmd_ver(shell, NULL, 0UL);
shell_handle_input(shell, "\r\n", 2UL);
}