I'm looking at the "help" command in the shell, and I keep getting the following output:
Code: Select all
Shell
>
>
>
> help
Commands: help exit info echo systime mem threads test clear led system profiles profile brew steam pump auto time x▒ READY WTSTART QUEUED WTMTX SLEEPING WTOREVT SNDMSGQ WTMSG ▒▒ X▒ ▒ ▒▒ ▒▒ ▒
>
Everything you see as pixel boxes is what I see in PuTTY as well. It looks like the
Code: Select all
static void list_commands(BaseSequentialStream *chp, const ShellCommand *scp)
I think I might be using the shell incorrectly - but I went off the shell examples. And it looks safe to me.
Nevermind the cmd_ function prototypes. I did not include the definitions since they are empty functions with the following body so far.
I do have CH_CFG_USE_REGISTRY enabled in chconf.h
Code: Select all
static void cmd_timeSet(BaseSequentialStream *chp, int argc, char *argv[])
{
(void)argv;
chprintf((BaseSequentialStream *)&SD3, "\tsetting time..\r\n");
}
Code: Select all
#include "ch.h"
#include "hal.h"
#include "ch_test.h"
#include "chprintf.h"
#include "string.h"
#include "shell.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
static THD_WORKING_AREA(waShell, 1024);
static void cmd_led(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_sysMon(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_profileList(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_profSet(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_brewSet(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_steamSet(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_pumpSet(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_autoSet(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_timeSet(BaseSequentialStream *chp, int argc, char *argv[]);
static const ShellCommand commands[] = {
{"led", cmd_led},
{"system", cmd_sysMon},
{"profiles", cmd_profileList},
{"profile", cmd_profSet},
{"brew", cmd_brewSet},
{"steam", cmd_steamSet},
{"pump", cmd_pumpSet},
{"auto", cmd_autoSet},
{"time", cmd_timeSet},
};
static const ShellConfig shell_cfg1 = {(BaseSequentialStream *)&SD3, commands};
static THD_WORKING_AREA(waBlinkerTHD, 128);
static THD_FUNCTION(BlinkerTHD, arg)
{
(void)arg;
chRegSetThreadName("blinker");
while(true)
{
palTogglePad(GPIOA, GPIOA_LED_GREEN);
chThdSleepMilliseconds(500);
}
}
int main(void)
{
halInit();
chSysInit();
chThdCreateStatic(waBlinkerTHD, sizeof(waBlinkerTHD), NORMALPRIO, BlinkerTHD, NULL);
/* Start the shell interface */
sdStart(&SD3, NULL);
shellInit();
chThdCreateStatic(waShell, sizeof(waShell), NORMALPRIO, shellThread, (void*)&shell_cfg1);
while(true)
{
/*
thread_t *shelltp = chThdCreateFromHeap(NULL,
SHELL_WA_SIZE,
"shell",
NORMALPRIO + 1,
shellThread,
(void *)&shell_cfg1);
chThdWait(shelltp);*/
if(!palReadPad(GPIOC, GPIOC_BUTTON))
{
test_execute((BaseSequentialStream *)&SD3);
}
chThdSleepMilliseconds(500);
}
}
/*******************************************************************************************************************
* SHELL COMMANDS
*******************************************************************************************************************/
static void cmd_led(BaseSequentialStream *chp, int argc, char *argv[])
{
(void)argv;
chprintf((BaseSequentialStream *)&SD3, "\ttoggling LED thread..\r\n");
if(argc != 1)
{
chprintf((BaseSequentialStream *)&SD3, "\tUsage: 1\r\n");
}
else if(!strcmp(argv[0], "1"))
{
// Give a semaphore to the LED thread
}
else if(!strcmp(argv[0], "0"))
{
// Raise a flag to cause the led thread to wait on the semaphore again
}
else
{
chprintf((BaseSequentialStream *)&SD3, "\tUsage: 1\r\n");
}
}
It's very unclear what I'm doing wrong. Do I need to provide a NUM_CMDS macro to the ShellConfig object?