uint8_t BLEUART_CMDMODE_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { uint8_t res = ERR_OK; if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "uart help")==0) { CLS1_SendHelpStr((unsigned char*)"uart", (const unsigned char*)"Group of Adafruit BLE commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" enable", (unsigned char*)"Enable BLE UART\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" disable", (unsigned char*)"Disable BLE UART\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" tx <string>", (unsigned char*)"Send string\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "uart status")==0)) { *handled = TRUE; return PrintStatus(io); } else if (UTIL1_strcmp((char*)cmd, "uart enable")==0) { isEnabled = TRUE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, "uart disable")==0) { isEnabled = FALSE; *handled = TRUE; } else if (UTIL1_strncmp((char*)cmd, "uart tx ", sizeof("uart tx ") - 1) == 0) { *handled = TRUE; taskENTER_CRITICAL(); UTIL1_strcpy(txBuffer, sizeof(txBuffer), cmd+sizeof("uart tx ")-1); UTIL1_strcat(txBuffer, sizeof(txBuffer), "\\n\n"); /* add newline */ taskEXIT_CRITICAL(); } return res; /* no error */ }
uint8_t MM_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { const uint8_t *p; uint8_t res; int32_t tmp; if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "midi help")==0) { CLS1_SendHelpStr((unsigned char*)"midi", (const unsigned char*)"Group of midi commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" play <number>", (const unsigned char*)"Play midi song (0, 1)\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "midi status")==0)) { *handled = TRUE; return PrintStatus(io); } else if (UTIL1_strncmp((char*)cmd, "midi play", sizeof("midi play")-1)==0) { p = cmd+sizeof("midi play")-1; res = UTIL1_xatoi(&p, &tmp); if (res==ERR_OK && tmp>=0) { *handled = TRUE; if (tmp==0) { MM_Play(); } else if (tmp==1) { MM_PlayPirate(); } } return res; } return ERR_OK; }
static void RADIO_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"radio", (unsigned char*)"Group of radio commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows radio help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" channel <number>", (unsigned char*)"Switches to the given channel. Channel must be in the range 0..127\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" power <number>", (unsigned char*)"Changes output power to 0, -10, -12, -18\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" sniff on|off", (unsigned char*)"Turns sniffing on or off\r\n", io->stdOut); }
static uint8_t BUZ_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"buzzer", (unsigned char*)"Group of buzzer commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows radio help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" buz <freq> <time>", (unsigned char*)"Beep for time (ms) and frequency (kHz)\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" play tune", (unsigned char*)"Play tune\r\n", io->stdOut); return ERR_OK; }
static uint8_t PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"ref", (unsigned char*)"Group of Reflectance commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" calib (on|off)", (unsigned char*)"Calibrate while moving sensor over line\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" led (on|off)", (unsigned char*)"Uses LED or not\r\n", io->stdOut); return ERR_OK; }
static void APP_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"app", (unsigned char*)"Group of app commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows radio help or status\r\n", io->stdOut); #if PL_APP_FOLLOW_OBSTACLE CLS1_SendHelpStr((unsigned char*)" follow (on|off)", (unsigned char*)"Obstacle following on or off\r\n", io->stdOut); #endif }
/*! * \brief Prints the help text to the console * \param io I/O channel to be used */ static void TRACE_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"trace", (unsigned char*)"Group of trace commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows trace help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" none|shell", (unsigned char*)"Sets the trace channel to be used\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" accel on|off", (unsigned char*)"Enables or disables accelerometer trace\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" magnetometer on|off", (unsigned char*)"Enables or disables magnetometer trace\r\n", io->stdOut); }
static uint8_t PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"VS1053", (unsigned char*)"Group of VL1053 commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" volume <number>", (unsigned char*)"Set volume, full: 0x0000, 0xFEFE silence\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" play <file>", (unsigned char*)"Play song file\r\n", io->stdOut); return ERR_OK; }
static void PID_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"pid", (unsigned char*)"Group of PID commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows PID help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" speed (L|R) (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup position value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" pos (L|R) (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup position value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" dis (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup position value\r\n", io->stdOut); }
static void BL_PrintHelp(CLS1_ConstStdIOType *io) { CLS1_SendHelpStr((unsigned char*)"BL", (const unsigned char*)"Group of Bootloader commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" erase", (const unsigned char*)"Erase application flash blocks\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" restart", (const unsigned char*)"Restart application with jump to reset vector\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" load s19", (const unsigned char*)"Load S19 file\r\n", io->stdOut); }
/* ** =================================================================== ** Method : CLS1_ParseCommand (component Shell) ** Description : ** Parses a shell command. Use 'help' to get a list of ** supported commands. ** Parameters : ** NAME - DESCRIPTION ** * cmd - Pointer to command string ** * handled - Pointer to variable to indicate if ** the command has been handled. The caller ** passes this variable to the command scanner ** to find out if the passed command has been ** handled. The variable is initialized by the ** caller. ** * io - Pointer to I/O callbacks ** Returns : ** --- - Error code ** =================================================================== */ uint8_t CLS1_ParseCommand(const uint8_t *cmd, bool *handled, CLS1_ConstStdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "CLS1 help")==0) { CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)"TWR-KV58F220M", io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)"CLS1", (const unsigned char*)"Group of CLS1 commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); #if CLS1_ECHO_ENABLED CLS1_SendHelpStr((unsigned char*)" echo (on|off)", (const unsigned char*)"Turn echo on or off\r\n", io->stdOut); #endif *handled = TRUE; return ERR_OK; #if CLS1_ECHO_ENABLED } else if ((UTIL1_strcmp((char*)cmd, "CLS1 echo on")==0)) { *handled = TRUE; CLS1_EchoEnabled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, "CLS1 echo off")==0)) { *handled = TRUE; CLS1_EchoEnabled = FALSE; return ERR_OK; #endif } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "CLS1 status")==0)) { *handled = TRUE; return CLS1_PrintStatus(io); } return ERR_OK; /* no error */ }
static uint8_t PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"ref", (unsigned char*)"Group of Reflectance commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Print help or status information\r\n", io->stdOut); #if REF_START_STOP_CALIB CLS1_SendHelpStr((unsigned char*)" calib (start|stop)", (unsigned char*)"Start/Stop calibrating while moving sensor over line\r\n", io->stdOut); #endif return ERR_OK; }
/*! * \brief Prints the help text to the console * \param io I/O channel to be used */ static void PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char *)"LowPower", (unsigned char *)"Group of LowPower commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char *)" help|status", (unsigned char *)"Shows help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char *)" mode run|wait|sleep|stop", (unsigned char *)"Set low power mode\r\n", io->stdOut); #if LP_CAN_CHANGE_CLOCK CLS1_SendHelpStr((unsigned char *)" clock fast|medium|slow", (unsigned char *)"Set clock speed mode\r\n", io->stdOut); #endif }
static void REMOTE_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"remote", (unsigned char*)"Group of remote commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows remote help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" on|off", (unsigned char*)"Turns the remote on or off\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" verbose on|off", (unsigned char*)"Turns the verbose mode on or off\r\n", io->stdOut); #if PL_CONFIG_HAS_JOYSTICK CLS1_SendHelpStr((unsigned char*)" joystick on|off", (unsigned char*)"Use joystick\r\n", io->stdOut); #endif }
static void PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"app", (unsigned char*)"Group of application commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help", (unsigned char*)"Shows radio help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" saddr 0x<addr>", (unsigned char*)"Set source node address\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" daddr 0x<addr>", (unsigned char*)"Set destination node address\r\n", io->stdOut); #if PL_HAS_RSTDIO CLS1_SendHelpStr((unsigned char*)" send (in/out/err)", (unsigned char*)"Send a string to stdio using the wireless transceiver\r\n", io->stdOut); #endif }
static void MAZE_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*) "maze", (unsigned char*) "Group of maze following commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " help|status", (unsigned char*) "Shows maze help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " clear", (unsigned char*) "Clear the maze solution\r\n", io->stdOut); }
static void APP_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"app", (unsigned char*)"Group of app commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows radio help or status\r\n", io->stdOut); #if PL_APP_FOLLOW_OBSTACLE CLS1_SendHelpStr((unsigned char*)" follow (on|off)", (unsigned char*)"Obstacle following on or off\r\n", io->stdOut); #endif #if PL_HAS_LINE_SENSOR CLS1_SendHelpStr((unsigned char*)" autocalib", (unsigned char*)"Automatically calibrate line sensor\r\n", io->stdOut); #endif }
static uint8_t ESP_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr("ESP", "ESP8200 commands\r\n", io->stdOut); //CLS1_SendHelpStr(" help|status", "Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr(" send <str>", "Sends a string to the module\r\n", io->stdOut); CLS1_SendHelpStr(" test", "Sends a test AT command\r\n", io->stdOut); CLS1_SendHelpStr(" restart", "Restart module\r\n", io->stdOut); //CLS1_SendHelpStr(" listAP", "List available Access Points\r\n", io->stdOut); //CLS1_SendHelpStr(" connectAP \"ssid\",\"pwd\"", "Connect to an Access Point\r\n", io->stdOut); CLS1_SendHelpStr(" server (start|stop)", "Start or stop web server\r\n", io->stdOut); return ERR_OK; }
uint8_t W5100_ParseCommand(const unsigned char *cmd, bool *handled, CLS1_ConstStdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "w5100 help")==0) { CLS1_SendHelpStr((unsigned char*)"w5100", (const unsigned char*)"Group of w5100 commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if (UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0 || UTIL1_strcmp((char*)cmd, "w5100 status")==0) { *handled = TRUE; return PrintStatus(io); } return ERR_OK; /* no error */ }
uint8_t BUZ_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "BUZ1 help")==0) { *handled = TRUE; CLS1_SendHelpStr((unsigned char*)"BUZ", (unsigned char*)"Group of BUZ commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" beep", (unsigned char*)"Beep with 1kHz for 1 sec\r\n", io->stdOut); return ERR_OK; } else if (UTIL1_strcmp((char*)cmd, "BUZ beep")==0) { *handled = TRUE; return BUZ_Beep(1000, 1000); } return ERR_OK; }
static uint8_t PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*) "player", (unsigned char*) "Group of player commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " help|status", (unsigned char*) "Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " volume <number>", (unsigned char*) "Set volume, full: 0x0000, 0xFEFE silence\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " play <file>", (unsigned char*) "Play song file\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " player pause on", (unsigned char*) "player pause on \r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " player pause off", (unsigned char*) "player pause off \r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " player stop", (unsigned char*) "player stop \r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*) " player setval <val>", (unsigned char*) "Sets time duration of alarmlight ", io->stdOut); return ERR_OK; }
/*! * \brief Parses a command * \param cmd Command string to be parsed * \param handled Sets this variable to TRUE if command was handled * \param io I/O stream to be used for input/output * \return Error code, ERR_OK if everything was fine */ uint8_t Q4CLeft_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { uint8_t res=ERR_OK; if (UTIL1_strcmp((const char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((const char *)cmd, "Q4CLeft help")==0) { CLS1_SendHelpStr((const unsigned char*)"Q4CLeft", (const unsigned char*)"Q4CLeft command group\r\n", io->stdOut); CLS1_SendHelpStr((const unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((const unsigned char*)" reset", (const unsigned char*)"Reset the current position counter\r\n", io->stdOut); *handled = TRUE; } else if (UTIL1_strcmp((const char*)cmd, CLS1_CMD_STATUS)==0 || UTIL1_strcmp((const char*)cmd, "Q4CLeft status")==0) { CLS1_SendStr((const unsigned char*)"Q4CLeft:\r\n", io->stdOut); CLS1_SendStatusStr((const unsigned char*)" pos", (const unsigned char*)"", io->stdOut); #if Q4CLeft_CNTR_BITS==16 CLS1_SendNum16u(Q4CLeft_currPos, io->stdOut); #elif Q4CLeft_CNTR_BITS==32 CLS1_SendNum32u(Q4CLeft_currPos, io->stdOut); #else #error "unknown counter size!" #endif CLS1_SendStr((const unsigned char*)", ", io->stdOut); #if Q4CLeft_CNTR_BITS==16 CLS1_SendNum16s((int16_t)Q4CLeft_currPos, io->stdOut); #elif Q4CLeft_CNTR_BITS==32 CLS1_SendNum32s((int32_t)Q4CLeft_currPos, io->stdOut); #else #error "unknown counter size!" #endif CLS1_SendStr((const unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((const unsigned char*)" C1 C2", (const unsigned char*)"", io->stdOut); if (Q4CLeft_GET_C1_PIN()!=0) { CLS1_SendStr((const unsigned char*)"1 ", io->stdOut); } else { CLS1_SendStr((const unsigned char*)"0 ", io->stdOut); } if (Q4CLeft_GET_C2_PIN()!=0) { CLS1_SendStr((const unsigned char*)"1\r\n", io->stdOut); } else { CLS1_SendStr((const unsigned char*)"0\r\n", io->stdOut); } CLS1_SendStatusStr((const unsigned char*)" errors", (const unsigned char*)"", io->stdOut); CLS1_SendNum16u(Q4CLeft_nofErrors, io->stdOut); CLS1_SendStr((const unsigned char*)"\r\n", io->stdOut); *handled = TRUE; } else if (UTIL1_strcmp((const char*)cmd, "Q4CLeft reset")==0) { Q4CLeft_SetPos(0); Q4CLeft_nofErrors = 0; *handled = TRUE; } return res; }
uint8_t NEO_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { uint8_t res = ERR_OK; uint32_t color; int32_t tmp, x, y; const uint8_t *p; if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "neo help")==0) { CLS1_SendHelpStr((unsigned char*)"neo", (const unsigned char*)"Group of neo commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" clear all", (const unsigned char*)"Clear all pixels\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" set all <rgb>", (const unsigned char*)"Set all pixel with RGB value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" set <x> <y> <rgb>", (const unsigned char*)"Set pixel with RGB value\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "neo status")==0)) { *handled = TRUE; return PrintStatus(io); } else if (UTIL1_strcmp((char*)cmd, "neo clear all")==0) { NEO_ClearAllPixel(); NEO_TransferPixels(); *handled = TRUE; return ERR_OK; } else if (UTIL1_strncmp((char*)cmd, "neo set all", sizeof("neo set all")-1)==0) { p = cmd+sizeof("neo set all")-1; res = UTIL1_xatoi(&p, &tmp); /* read color RGB value */ if (res==ERR_OK && tmp>=0 && tmp<=0xffffff) { /* within RGB value */ color = tmp; NEO_SetAllPixelColor(color); NEO_TransferPixels(); *handled = TRUE; } } else if (UTIL1_strncmp((char*)cmd, "neo set", sizeof("neo set")-1)==0) { p = cmd+sizeof("neo set")-1; res = UTIL1_xatoi(&p, &x); /* read x pixel index */ if (res==ERR_OK && x>=0 && x<NEO_NOF_X) { res = UTIL1_xatoi(&p, &y); /* read y pixel index */ if (res==ERR_OK && y>=0 && y<NEO_NOF_Y) { res = UTIL1_xatoi(&p, &tmp); /* read color RGB value */ if (res==ERR_OK && tmp>=0 && tmp<=0xffffff) { color = tmp; NEO_SetPixelColor((NEO_PixelIdxT)x, (NEO_PixelIdxT)y, color); NEO_TransferPixels(); *handled = TRUE; } } } } return res; }
static void DRV_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"drive", (unsigned char*)"Group of drive commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" speed (on|off)", (unsigned char*)"Turns speed pid on or ff\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" speed (L|R) <value>", (unsigned char*)"Sets speed value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" pos (on|off)", (unsigned char*)"Turns speed pid on or ff\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" pos (L|R) <value>", (unsigned char*)"Sets speed value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" pos LR <value>", (unsigned char*)"Sets speed value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" angle <value>", (unsigned char*)"turns robot\r\n", io->stdOut); }
static void TURN_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"turn", (unsigned char*)"Group of turning commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows turn help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" left|right|around", (unsigned char*)"Turn the robot\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" duty <percent>", (unsigned char*)"Turning motor PWM duty percent\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" time <ms>", (unsigned char*)"Turning time in milli-seconds for 90 degrees\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" step <ms>", (unsigned char*)"Time in milli-seconds for a single step\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" forward", (unsigned char*)"Move one step forward\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" backward", (unsigned char*)"Move one step backward\r\n", io->stdOut); }
static uint8_t PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"MCP4728", (unsigned char*)"Group of MCP4728 commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" reset", (unsigned char*)"General Call Reset\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" wakeup", (unsigned char*)"General Call Wake-Up\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" update", (unsigned char*)"General Call software update\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" fastwrite all 0x...", (unsigned char*)"Fast write all channel DAC values with four 12bit hex values (EEPROM not affected)\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" fastwrite <ch> 0x...", (unsigned char*)"Fast write single channel (0..3) DAC value with a 12bit hex value (EEPROM not affected)\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" write <ch> <val>", (unsigned char*)"Single write EEPROM and DAC value channel (hex 12bit) for channel 0-3\r\n", io->stdOut); return ERR_OK; }
static void MOT_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"motor", (unsigned char*)"Group of motor commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows motor help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" (L|R) forward|backward", (unsigned char*)"Change motor direction\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" (L|R) duty <number>", (unsigned char*)"Change motor PWM (-100..+100)%\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" motor both go", (unsigned char*)"Starts the motors forward with 15% duty\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" motor both (fw|bw)", (unsigned char*)"Sets motors direction\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" motor stop", (unsigned char*)"Stops the motors\r\n", io->stdOut); }
/* ** =================================================================== ** Method : CLS1_ParseCommand (component Shell) ** Description : ** Parses a shell command. Use 'help' to get a list of ** supported commands. ** Parameters : ** NAME - DESCRIPTION ** * cmd - Pointer to command string ** * handled - Pointer to variable to indicate if ** the command has been handled. The caller ** passes this variable to the command scanner ** to find out if the passed command has been ** handled. The variable is initialized by the ** caller. ** * io - Pointer to I/O callbacks ** Returns : ** --- - Error code ** =================================================================== */ uint8_t CLS1_ParseCommand(const uint8_t *cmd, bool *handled, CLS1_ConstStdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "CLS1 help")==0) { CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)"FRDM-KL25Z Master INTRO", io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)"CLS1", (const unsigned char*)"Group of CLS1 commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "CLS1 status")==0)) { *handled = TRUE; return CLS1_PrintStatus(io); } return ERR_OK; /* no error */ }
/*! * \brief Parses a command * \param cmd Command string to be parsed * \param handled Sets this variable to TRUE if command was handled * \param io I/O stream to be used for input/output * \return Error code, ERR_OK if everything was fine */ static uint8_t ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { /* handling our own commands */ if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0) { CLS1_SendHelpStr((const unsigned char*)"run benchmark", (const unsigned char*)"Run FatFS benchmark\r\n", io->stdOut); *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, "run benchmark")==0) { benchmark(io); *handled = TRUE; } return ERR_OK; }
static void PID_PrintHelp(const CLS1_StdIOType *io) { CLS1_SendHelpStr((unsigned char*)"pid", (unsigned char*)"Group of PID commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (unsigned char*)"Shows PID help or status\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" fw (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup line value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" fw speed <value>", (unsigned char*)"Maximum speed % value\r\n", io->stdOut); #if PL_GO_DEADEND_BW CLS1_SendHelpStr((unsigned char*)" bw (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup backward value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" bw speed <value>", (unsigned char*)"Maximum backward speed % value\r\n", io->stdOut); #endif #if PL_HAS_QUADRATURE CLS1_SendHelpStr((unsigned char*)" pos (p|d|i|w) <value>", (unsigned char*)"Sets P, D, I or anti-windup position value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" pos speed <value>", (unsigned char*)"Maximum speed % value\r\n", io->stdOut); #endif }