static uint8_t ESP_PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[48]; CLS1_SendStatusStr("ESP8266", "\r\n", io->stdOut); CLS1_SendStatusStr(" Webserver", ESP_WebServerIsOn?"ON\r\n":"OFF\r\n", io->stdOut); if (ESP_GetFirmwareVersionString(buf, sizeof(buf)) != ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "FAILED\r\n"); } else { /* 00160901: 0016 is SDK version, 0901 is the AT version */ UTIL1_strcat(buf, sizeof(buf), "\r\n"); } CLS1_SendStatusStr(" AT+GMR", buf, io->stdOut); if (ESP_GetModeString(buf, sizeof(buf)) != ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "FAILED\r\n"); } else { if (UTIL1_strcmp(buf, "1")==0) { UTIL1_strcat(buf, sizeof(buf), " (device)"); } else if (UTIL1_strcmp(buf, "2")==0) { UTIL1_strcat(buf, sizeof(buf), " (AP)"); } else if (UTIL1_strcmp(buf, "3")==0) { UTIL1_strcat(buf, sizeof(buf), " (device+AP)"); } else { UTIL1_strcat(buf, sizeof(buf), " (ERROR)"); } UTIL1_strcat(buf, sizeof(buf), "\r\n"); } CLS1_SendStatusStr(" AT+CWMODE?", buf, io->stdOut); if (ESP_GetIPAddrString(buf, sizeof(buf)) != ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "FAILED\r\n"); } else { UTIL1_strcat(buf, sizeof(buf), "\r\n"); } CLS1_SendStatusStr(" AT+CIFSR", buf, io->stdOut); if (ESP_GetConnectedAPString(buf, sizeof(buf)) != ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "FAILED\r\n"); } else { UTIL1_strcat(buf, sizeof(buf), "\r\n"); } CLS1_SendStatusStr(" AT+CWJAP?", buf, io->stdOut); if (ESP_GetCIPMUXString(buf, sizeof(buf)) != ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "FAILED\r\n"); } else { if (UTIL1_strcmp(buf, "0")==0) { UTIL1_strcat(buf, sizeof(buf), " (single connection)"); } else if (UTIL1_strcmp(buf, "1")==0) { UTIL1_strcat(buf, sizeof(buf), " (multiple connections)"); } else { UTIL1_strcat(buf, sizeof(buf), " (ERROR)"); } UTIL1_strcat(buf, sizeof(buf), "\r\n"); } CLS1_SendStatusStr(" CIPMUX", buf, io->stdOut); return ERR_OK; }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { uint8_t data[2*3*4]; if (MPC4728_Read(data, sizeof(data))==ERR_OK) { CLS1_SendStatusStr((unsigned char*)"MPC4728", (unsigned char*)"\r\n", io->stdOut); DecodeChannelDACInputRegister((unsigned char*)" A DAC Reg", &data[0], io); DecodeChannelDACInputRegister((unsigned char*)" A EEPROM", &data[3], io); DecodeChannelDACInputRegister((unsigned char*)" B DAC Reg", &data[6], io); DecodeChannelDACInputRegister((unsigned char*)" B EEPROM", &data[9], io); DecodeChannelDACInputRegister((unsigned char*)" C DAC Reg", &data[12], io); DecodeChannelDACInputRegister((unsigned char*)" C EEPROM", &data[15], io); DecodeChannelDACInputRegister((unsigned char*)" D DAC Reg", &data[18], io); DecodeChannelDACInputRegister((unsigned char*)" D EEPROM", &data[21], io); } else { CLS1_SendStatusStr((unsigned char*)"MPC4728", (unsigned char*)"ERROR!\r\n", 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 APP_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { /* handling our own commands */ uint8_t res=ERR_OK; if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0) { CLS1_SendHelpStr((unsigned char*)"walking on|off", (unsigned char*)"Turn walking on or off\r\n", io->stdOut); } else if (UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) { CLS1_SendStatusStr((unsigned char*)"Application:", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" Walking", enabledWalking?(unsigned char*)"on\r\n":(const unsigned char*)"off\r\n", io->stdOut); } else if (UTIL1_strcmp((char*)cmd, "walking off")==0) { enabledWalking = FALSE; *handled = TRUE; } else if (UTIL1_strcmp((char*)cmd, "walking on")==0) { enabledWalking = TRUE; *handled = TRUE; } return res; }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[24]; uint16_t val; CLS1_SendStatusStr((unsigned char*)"VS1053", (unsigned char*)"\r\n", io->stdOut); if (VS_ReadRegister(VS_MODE, &val)==ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), val); UTIL1_strcat(buf, sizeof(buf), "\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), "ERROR\r\n"); } CLS1_SendStatusStr((unsigned char*)" MODE", buf, io->stdOut); if (VS_ReadRegister(VS_STATUS, &val)==ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), val); UTIL1_strcat(buf, sizeof(buf), "\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), "ERROR\r\n"); } CLS1_SendStatusStr((unsigned char*)" STATUS", buf, io->stdOut); if (VS_ReadRegister(VS_CLOCKF, &val)==ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), val); UTIL1_strcat(buf, sizeof(buf), "\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), "ERROR\r\n"); } CLS1_SendStatusStr((unsigned char*)" CLOCKF", buf, io->stdOut); if (VS_ReadRegister(VS_VOL, &val)==ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), "0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), val); UTIL1_strcat(buf, sizeof(buf), "\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), "ERROR\r\n"); } CLS1_SendStatusStr((unsigned char*)" VOLUME", buf, io->stdOut); return ERR_OK; }
static void PrintPIDstatus(PID_Config *config, const unsigned char *kindStr, const CLS1_StdIOType *io) { unsigned char buf[48]; unsigned char kindBuf[16]; UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" PID"); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"p: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->pFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" i: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->iFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" d: "); UTIL1_strcatNum32s(buf, sizeof(buf), config->dFactor100); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" windup"); UTIL1_Num32sToStr(buf, sizeof(buf), config->iAntiWindup); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" error"); UTIL1_Num32sToStr(buf, sizeof(buf), config->lastError); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" integral"); UTIL1_Num32sToStr(buf, sizeof(buf), config->integral); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); UTIL1_strcpy(kindBuf, sizeof(buf), (unsigned char*)" "); UTIL1_strcat(kindBuf, sizeof(buf), kindStr); UTIL1_strcat(kindBuf, sizeof(buf), (unsigned char*)" speed"); UTIL1_Num8uToStr(buf, sizeof(buf), config->maxSpeedPercent); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"%\r\n"); CLS1_SendStatusStr(kindBuf, buf, io->stdOut); }
static void MAZE_PrintStatus(const CLS1_StdIOType *io) { int i; CLS1_SendStatusStr((unsigned char*) "maze", (unsigned char*) "\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*) " solved", MAZE_IsSolved() ? (unsigned char*) "yes\r\n" : (unsigned char*) "no\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*) " path", (unsigned char*) "(", io->stdOut); CLS1_SendNum8u(pathLength, io->stdOut); CLS1_SendStr((unsigned char*) ") ", io->stdOut); for (i = 0; i < pathLength; i++) { CLS1_SendStr(TURN_TurnKindStr(path[i]), io->stdOut); CLS1_SendStr((unsigned char*) " ", io->stdOut); } CLS1_SendStr((unsigned char*) "\r\n", io->stdOut); }
static void PID_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"pid", (unsigned char*)"\r\n", io->stdOut); PrintPIDstatus(&lineFwConfig, (unsigned char*)"fw", io); #if PL_GO_DEADEND_BW PrintPIDstatus(&lineBwConfig, (unsigned char*)"bw", io); #endif #if PL_HAS_QUADRATURE PrintPIDstatus(&posConfig, (unsigned char*)"pos", io); #endif }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[32]; CLS1_SendStatusStr((unsigned char*)"app", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" state", StringForState(appState), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0x"); #if RNWK_SHORT_ADDR_SIZE==1 UTIL1_strcatNum8Hex(buf, sizeof(buf), APP_dstAddr); #else UTIL1_strcatNum16Hex(buf, sizeof(buf), APP_dstAddr); #endif UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr((unsigned char*)" dest addr", buf, io->stdOut); return ERR_OK; }
static void TURN_PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[32]; CLS1_SendStatusStr((unsigned char*)"turn", (unsigned char*)"\r\n", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16u(buf, sizeof(buf), TURN_StepMs); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n"); CLS1_SendStatusStr((unsigned char*)" step time", buf, io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16u(buf, sizeof(buf), TURN_TimeMs); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n"); CLS1_SendStatusStr((unsigned char*)" turn time", buf, io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16u(buf, sizeof(buf), TURN_DutyPercent); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"%\r\n"); CLS1_SendStatusStr((unsigned char*)" duty", buf, io->stdOut); }
static void BL_PrintStatus(CLS1_ConstStdIOType *io) { unsigned char buf[32]; CLS1_SendStatusStr((unsigned char*)"BL", (const unsigned char*)"\r\n", io->stdOut); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0x"); UTIL1_strcatNum32Hex(buf, sizeof(buf), MIN_APP_FLASH_ADDRESS); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"..0x"); UTIL1_strcatNum32Hex(buf, sizeof(buf), MAX_APP_FLASH_ADDRESS); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr((unsigned char*)" App Flash", buf, io->stdOut); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)" @0x"); UTIL1_strcatNum32Hex(buf, sizeof(buf), MIN_APP_FLASH_ADDRESS); CLS1_SendStatusStr(buf, (unsigned char*)"", io->stdOut); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0x"); UTIL1_strcatNum32Hex(buf, sizeof(buf), *((uint32_t*)MIN_APP_FLASH_ADDRESS)); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" 0x"); UTIL1_strcatNum32Hex(buf, sizeof(buf), *((uint32_t*)MIN_APP_FLASH_ADDRESS+4)); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStr(buf, io->stdOut); }
static void DecodeChannelDACInputRegister(uint8_t *info, uint8_t data[3], const CLS1_StdIOType *io) { uint8_t buf[16]; UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0x"); UTIL1_strcatNum8Hex(buf, sizeof(buf), data[0]); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" 0x"); UTIL1_strcatNum8Hex(buf, sizeof(buf), data[1]); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" 0x"); UTIL1_strcatNum8Hex(buf, sizeof(buf), data[2]); CLS1_SendStatusStr(info, buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); }
static void TRACE_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"Trace", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" channel", (unsigned char*)"", io->stdOut); if (traceChannel==TRACE_TO_NONE) { CLS1_SendStr((unsigned char*)"NONE\r\n", io->stdOut); } else if (traceChannel==TRACE_TO_SHELL) { CLS1_SendStr((unsigned char*)"SHELL\r\n", io->stdOut); } CLS1_SendStatusStr((unsigned char*)" options", (unsigned char*)"", io->stdOut); if (traceAccel) { CLS1_SendStr((unsigned char*)"accel(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"accel(off) ", io->stdOut); } if (traceMagnetometer) { CLS1_SendStr((unsigned char*)"magnetometer(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"magnetometer(off) ", io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); }
static void TRACE_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"Trace", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" channel", (unsigned char*)"", io->stdOut); if (traceChannel==TRACE_TO_NONE) { CLS1_SendStr((unsigned char*)"NONE\r\n", io->stdOut); } else if (traceChannel==TRACE_TO_SHELL) { CLS1_SendStr((unsigned char*)"SHELL\r\n", io->stdOut); } CLS1_SendStatusStr((unsigned char*)" options", (unsigned char*)"", io->stdOut); /*! \todo Extend with motor option */ #if PL_HAS_MOTOR if (traceMotor) { CLS1_SendStr((unsigned char*)"motor(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"motor(off) ", io->stdOut); } #endif #if PL_HAS_MOTOR_TACHO if (traceTacho) { CLS1_SendStr((unsigned char*)"tacho(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"tacho(off) ", io->stdOut); } #endif #if PL_HAS_QUADRATURE if (traceQuad) { CLS1_SendStr((unsigned char*)"quad(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"quad(off) ", io->stdOut); } #endif #if PL_HAS_ACCEL if (traceAccel) { CLS1_SendStr((unsigned char*)"accel(on) ", io->stdOut); } else { CLS1_SendStr((unsigned char*)"accel(off) ", io->stdOut); } #endif CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); }
static void RADIO_PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[24]; uint8_t val0, val1; CLS1_SendStatusStr((unsigned char*)"Radio", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" state", RadioStateStr(RADIO_AppStatus), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" sniff", RADIO_isSniffing?(unsigned char*)"yes\r\n":(unsigned char*)"no\r\n", io->stdOut); UTIL1_Num8uToStr(buf, sizeof(buf), RADIO_channel); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr((unsigned char*)" channel", buf, io->stdOut); (void)RF1_ReadObserveTxRegister(&val0, &val1); UTIL1_Num8uToStr(buf, sizeof(buf), val0); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" lost, "); UTIL1_strcatNum8u(buf, sizeof(buf), val1); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" retry\r\n"); CLS1_SendStatusStr((unsigned char*)" OBSERVE_TX", buf, io->stdOut); #if 0 /* The RPD status will get reset very fast by another (e.g. WLAN) packet. So this is not really a useful feature :-( */ (void)RF1_ReadReceivedPowerDetector(&val0); /*! \todo only works in RX mode, but somehow this still does not work? */ if (val0&1) { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"1, > -64 dBm\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0, < -64 dBm\r\n"); } CLS1_SendStatusStr((unsigned char*)" RPD", buf, io->stdOut); #endif }
static void DRV_PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[48]; CLS1_SendStatusStr((unsigned char*)"drive", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" mode", DRV_GetModeStr(DRV_Status.mode), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); UTIL1_Num32sToStr(buf, sizeof(buf), DRV_Status.speed.left); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps/sec (curr: "); UTIL1_strcatNum32s(buf, sizeof(buf), TACHO_GetSpeed(TRUE)); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n"); CLS1_SendStatusStr((unsigned char*)" speed left", buf, io->stdOut); UTIL1_Num32sToStr(buf, sizeof(buf), DRV_Status.speed.right); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps/sec (curr: "); UTIL1_strcatNum32s(buf, sizeof(buf), TACHO_GetSpeed(FALSE)); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n"); CLS1_SendStatusStr((unsigned char*)" speed right", buf, io->stdOut); UTIL1_Num32sToStr(buf, sizeof(buf), DRV_Status.pos.left); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" (curr: "); UTIL1_strcatNum32s(buf, sizeof(buf), (int32_t)Q4CLeft_GetPos()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n"); CLS1_SendStatusStr((unsigned char*)" pos left", buf, io->stdOut); UTIL1_Num32sToStr(buf, sizeof(buf), DRV_Status.pos.right); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" (curr: "); UTIL1_strcatNum32s(buf, sizeof(buf), (int32_t)Q4CRight_GetPos()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n"); CLS1_SendStatusStr((unsigned char*)" pos right", buf, io->stdOut); }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { uint8_t buf[48]; int i; CLS1_SendStatusStr((unsigned char*)"rfid", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" card", RFID_uid!=NULL?(uint8_t*)"yes\r\n":(uint8_t*)"no\r\n", io->stdOut); if (RFID_uid!=NULL) { buf[0] = '\0'; for (i=0; i<RFID_uid->size; i++) { UTIL1_strcatNum8Hex(buf, sizeof(buf), RFID_uid->uidByte[i]); UTIL1_strcat(buf, sizeof(buf), " "); } UTIL1_strcat(buf, sizeof(buf), "\r\n"); CLS1_SendStatusStr((unsigned char*)" UID", buf, io->stdOut); UTIL1_strcpy(buf, sizeof(buf), MFRC522_PICC_GetTypeName(MFRC522_PICC_GetType(RFID_uid->sak))); UTIL1_strcat(buf, sizeof(buf), "\r\n"); CLS1_SendStatusStr((unsigned char*)" type", buf, io->stdOut); } CLS1_SendStatusStr((unsigned char*)" dump", RFID_dumpNewCardInformation?(uint8_t*)"on\r\n":(uint8_t*)"off\r\n", io->stdOut); return ERR_OK; }
/* ** =================================================================== ** Method : CLS1_PrintStatus (component Shell) ** Description : ** Prints various available system status information ** Parameters : ** NAME - DESCRIPTION ** * io - Pointer to I/O callbacks ** Returns : ** --- - Error code ** =================================================================== */ uint8_t CLS1_PrintStatus(CLS1_ConstStdIOType *io) { CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\nSYSTEM STATUS\r\n", io->stdOut); CLS1_SendStr((unsigned char*)CLS1_DASH_LINE, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((const unsigned char*)"Firmware", (const unsigned char*)__DATE__, io->stdOut); CLS1_SendStr((unsigned char*)" ", io->stdOut); CLS1_SendStr((unsigned char*)__TIME__, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); return ERR_OK; }
uint8_t APP_ParseCommand(const unsigned char *cmd, bool *handled, CLS1_ConstStdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "app help")==0) { CLS1_SendHelpStr((unsigned char*)"app", (const unsigned char*)"Group of app 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*)" mount|unmount", (const unsigned char*)"mount or unmount file system\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if (UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0 || UTIL1_strcmp((char*)cmd, "app status")==0) { CLS1_SendStatusStr((unsigned char*)"app", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" mounted", cardMounted?(unsigned char*)"yes\r\n":(unsigned char*)"no\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if (UTIL1_strcmp((char*)cmd, "app mount")==0) { *handled = TRUE; if (cardMounted) { CLS1_SendStr((unsigned char*)"card already mounted!\r\n", io->stdErr); return ERR_FAILED; } if (FAT1_MountFileSystem(&fileSystemObject, 0, io)!=ERR_OK) { CLS1_SendStr((unsigned char*)"failed!\r\n", io->stdErr); return ERR_FAILED; } else { cardMounted = TRUE; } } else if (UTIL1_strcmp((char*)cmd, "app unmount")==0) { *handled = TRUE; if (!cardMounted) { CLS1_SendStr((unsigned char*)"card not mounted!\r\n", io->stdErr); return ERR_FAILED; } if (FAT1_UnMountFileSystem(0, io)!=ERR_OK) { CLS1_SendStr((unsigned char*)"failed!\r\n", io->stdErr); return ERR_FAILED; } else { cardMounted = FALSE; } } return ERR_OK; /* no error */ }
static void MOT_PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[32]; CLS1_SendStatusStr((unsigned char*)"Motor", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" on/off", isMotorOn?(unsigned char*)"on\r\n":(unsigned char*)"off\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" motor L", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_Num16sToStrFormatted(buf, sizeof(buf), (int16_t)motorL.currSpeedPercent, ' ', 4); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"% 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), MOT_GetVal(&motorL)); UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetDirection(&motorL)==MOT_DIR_FORWARD?", fw":", bw")); #if PL_HAS_MOTOR_BRAKE UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetBrake(&motorL)?", brake on":", brake off")); #endif CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" motor R", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_Num16sToStrFormatted(buf, sizeof(buf), (int16_t)motorR.currSpeedPercent, ' ', 4); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"% 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), MOT_GetVal(&motorR)); UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetDirection(&motorR)==MOT_DIR_FORWARD?", fw":", bw")); #if PL_HAS_MOTOR_BRAKE UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetBrake(&motorR)?", brake on":", brake off")); #endif CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); #if PL_HAS_MOTOR_CURRENT_SENSE WriteCurrent(&motorA, io); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); WriteCurrent(&motorB, io); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); #endif }
static void MOT_PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[32]; CLS1_SendStatusStr((unsigned char*)"Motor", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" motor L", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_Num16sToStrFormatted(buf, sizeof(buf), (int16_t)motorL.currSpeedPercent, ' ', 4); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"% 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), MOT_GetVal(&motorL)); UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetDirection(&motorL)==MOT_DIR_FORWARD?", fw":", bw")); CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" motor R", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_Num16sToStrFormatted(buf, sizeof(buf), (int16_t)motorR.currSpeedPercent, ' ', 4); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"% 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), MOT_GetVal(&motorR)); UTIL1_strcat(buf, sizeof(buf),(unsigned char*)(MOT_GetDirection(&motorR)==MOT_DIR_FORWARD?", fw":", bw")); CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[24]; int i; CLS1_SendStatusStr((unsigned char*)"reflectance", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" state", REF_GetStateString(), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" raw val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorRaw[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" min val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibMinMax.minVal[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" max val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibMinMax.maxVal[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" calib val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibrated[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); return ERR_OK; }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { int i; uint8_t buf[16], buf2[32]; CLS1_SendStatusStr((uint8_t*)"Floppy", (uint8_t*)"\r\n", io->stdOut); UTIL1_Num32sToStr(buf, sizeof(buf), FLOPPY_NoteOffset); UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"\r\n"); CLS1_SendStatusStr((uint8_t*)" note offset", buf, io->stdOut); for(i=0;i<FLOPPY_NOF_DRIVES;i++) { UTIL1_strcpy(buf, sizeof(buf), (uint8_t*)" drive "); UTIL1_strcatNum16u(buf, sizeof(buf), (uint16_t)i); UTIL1_chcat(buf, sizeof(buf), ':'); buf2[0] = '\0'; if (FLOPPY_Drives[i].forward) { UTIL1_strcat(buf2, sizeof(buf2), (uint8_t*)"fw "); } else { UTIL1_strcat(buf2, sizeof(buf2), (uint8_t*)"bw "); } UTIL1_strcatNum16s(buf2, sizeof(buf2), FLOPPY_Drives[i].pos); UTIL1_strcat(buf2, sizeof(buf2), (uint8_t*)"\r\n"); CLS1_SendStatusStr(buf, buf2, io->stdOut); } return ERR_OK; }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[15]; int i; CLS1_SendStatusStr((unsigned char*)"Reflectance", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" led", ledON?(unsigned char*)"on\r\n":(unsigned char*)"off\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" calibrated", isCalibrated?(unsigned char*)"yes\r\n":(unsigned char*)"no\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" raw", (unsigned char*)"", io->stdOut); for (i=0;i<NOF_SENSORS;i++) { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorRaw[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" white", (unsigned char*)"", io->stdOut); for (i=0;i<NOF_SENSORS;i++) { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorWhite[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" black", (unsigned char*)"", io->stdOut); for (i=0;i<NOF_SENSORS;i++) { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorBlack[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" calibrated", (unsigned char*)"", io->stdOut); for (i=0;i<NOF_SENSORS;i++) { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibrated[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" line", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16s(buf, sizeof(buf), refLine); CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); return ERR_OK; }
static void StatusPrintXY(CLS1_ConstStdIOType *io) { uint16_t x, y; int8_t x8, y8; uint8_t buf[64]; if (APP_GetXY(&x, &y, &x8, &y8)==ERR_OK) { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"X: 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), x); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"("); UTIL1_strcatNum8s(buf, sizeof(buf), x8); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)") Y: 0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), y); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"("); UTIL1_strcatNum8s(buf, sizeof(buf), y8); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)")\r\n"); } else { UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"GetXY() failed!\r\n"); } CLS1_SendStatusStr((unsigned char*)" analog", buf, io->stdOut); }
static void TURN_PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[32]; CLS1_SendStatusStr((unsigned char*)"turn", (unsigned char*)"\r\n", io->stdOut); #if PL_HAS_QUADRATURE UTIL1_Num16uToStr(buf, sizeof(buf), TURN_Steps90); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps\r\n"); CLS1_SendStatusStr((unsigned char*)" steps90", buf, io->stdOut); UTIL1_Num16uToStr(buf, sizeof(buf), TURN_StepsFwBw); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps\r\n"); CLS1_SendStatusStr((unsigned char*)" stepsfw", buf, io->stdOut); UTIL1_Num16sToStr(buf, sizeof(buf), Q4CLeft_GetPos()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)", "); UTIL1_strcatNum16u(buf, sizeof(buf), Q4CLeft_NofErrors()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" errors\r\n"); CLS1_SendStatusStr((unsigned char*)" left pos", buf, io->stdOut); UTIL1_Num16sToStr(buf, sizeof(buf), Q4CRight_GetPos()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)", "); UTIL1_strcatNum16u(buf, sizeof(buf), Q4CRight_NofErrors()); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" errors\r\n"); CLS1_SendStatusStr((unsigned char*)" right pos", buf, io->stdOut); #else UTIL1_Num16uToStr(buf, sizeof(buf), TURN_DutyPercent); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"%\r\n"); CLS1_SendStatusStr((unsigned char*)" duty", buf, io->stdOut); UTIL1_Num16uToStr(buf, sizeof(buf), TURN_Time90ms); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n"); CLS1_SendStatusStr((unsigned char*)" time90", buf, io->stdOut); UTIL1_Num16uToStr(buf, sizeof(buf), TURN_StepFwBwMs); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n"); CLS1_SendStatusStr((unsigned char*)" timefw", buf, io->stdOut); #endif }
static void LF_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"line follow", (unsigned char*)"\r\n", io->stdOut); switch (LF_currState) { case STATE_IDLE: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"IDLE\r\n", io->stdOut); break; case STATE_FOLLOW_SEGMENT: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"FOLLOW_SEGMENT\r\n", io->stdOut); break; case STATE_STOP: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"STOP\r\n", io->stdOut); break; case STATE_TURN: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"TURN\r\n", io->stdOut); break; case STATE_FINISHED: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"FINISHED\r\n", io->stdOut); break; default: CLS1_SendStatusStr((unsigned char*)" state", (unsigned char*)"UNKNOWN\r\n", io->stdOut); break; } /* switch */ }
static uint8_t PrintStatus(CLS1_ConstStdIOType *io) { CLS1_SendStatusStr((unsigned char*)"midi", (const unsigned char*)"\r\n", io->stdOut); return ERR_OK; }
static void PID_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"pid", (unsigned char*)"\r\n", io->stdOut); PrintPIDstatus(&speedLeftConfig, (unsigned char*)"speed L", io); PrintPIDstatus(&speedRightConfig, (unsigned char*)"speed R", io); }
static uint8_t PrintStatus(const CLS1_StdIOType *io) { unsigned char buf[24]; int i; CLS1_SendStatusStr((unsigned char*)"reflectance", (unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" state", REF_GetStateString(), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"0x"); UTIL1_strcatNum16Hex(buf, sizeof(buf), REF_MIN_NOISE_VAL); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); CLS1_SendStatusStr((unsigned char*)" min noise", buf, io->stdOut); CLS1_SendStatusStr((unsigned char*)" raw val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorRaw[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" min val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibMinMax.minVal[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" max val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibMinMax.maxVal[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" calib val", (unsigned char*)"", io->stdOut); for (i=0;i<REF_NOF_SENSORS;i++) { if (i==0) { CLS1_SendStr((unsigned char*)"0x", io->stdOut); } else { CLS1_SendStr((unsigned char*)" 0x", io->stdOut); } buf[0] = '\0'; UTIL1_strcatNum16Hex(buf, sizeof(buf), SensorCalibrated[i]); CLS1_SendStr(buf, io->stdOut); } CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); CLS1_SendStatusStr((unsigned char*)" line val", (unsigned char*)"", io->stdOut); buf[0] = '\0'; UTIL1_strcatNum16s(buf, sizeof(buf), refCenterLineVal); CLS1_SendStr(buf, io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); #if PL_CONFIG_HAS_LINE_FOLLOW CLS1_SendStatusStr((unsigned char*)" line kind", REF_LineKindStr(refLineKind), io->stdOut); CLS1_SendStr((unsigned char*)"\r\n", io->stdOut); #endif return ERR_OK; }
static void APP_PrintStatus(const CLS1_StdIOType *io) { CLS1_SendStatusStr((unsigned char*)"app", (unsigned char*)"\r\n", io->stdOut); #if PL_APP_FOLLOW_OBSTACLE CLS1_SendStatusStr((unsigned char*)" follow", followObstacle?(unsigned char*)"on\r\n":(unsigned char*)"off\r\n", io->stdOut); #endif }