Initial public release.
This commit is contained in:
parent
7b169e8116
commit
dac4af8d25
255 changed files with 68595 additions and 2 deletions
|
@ -0,0 +1,78 @@
|
|||
/** \file
|
||||
* \brief This file defines the serial console commands for the Bluetooth Low Energy subsystem.
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED) && (CONFIG__FEATURE_BLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Private Function Prototypes */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Private Variables */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
/* Private Functions */
|
||||
|
||||
//! Console command handler for subcommands of the 'ble' command.
|
||||
COMM_Console_Command_Result_T COMM_HandleBLECommand(char8 * data, uint32_t size)
|
||||
{
|
||||
// data[0] through data[3] is 'ble '.
|
||||
|
||||
if (data[4] == '?')
|
||||
{
|
||||
COMM_Console_Print_String("ble ? Display this help.\n");
|
||||
COMM_Console_Print_String("ble cmd <id> Inject the BLE command with ID <id>.\n");
|
||||
}
|
||||
else if ( (data[4] == 'c') &&
|
||||
(data[5] == 'm') &&
|
||||
(data[6] == 'd') )
|
||||
|
||||
{
|
||||
if (COMM_Console_IsEndOfMessage(data[7]))
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: missing BLE command ID!\n");
|
||||
}
|
||||
else if (data[7] == ' ')
|
||||
{
|
||||
uint16_t id = 0;
|
||||
|
||||
if (COMM_Console_DecodeParameterUInt16(&(data[8]), &id) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
if ((id > COMM_BLE_COMMAND_NO_OP) && (id < COMM_BLE_COMMAND_IS_OUT_OF_RANGE))
|
||||
{
|
||||
COMM_BLE_Command_T command = {.ID = id, .Data = (void *)0x00};
|
||||
xQueueSend(COMM_BLE_CommandQueue, &command, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: specified BLE command ID (");
|
||||
COMM_Console_Print_UInt16(id);
|
||||
COMM_Console_Print_String(") is invalid!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: could not comprehend BLE command ID!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Unknown BLE command!\n");
|
||||
}
|
||||
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED) && (CONFIG__FEATURE_BLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
|||
/** \file
|
||||
* \brief This file declares the serial console commands for the Bluetooth Low Energy subsystem.
|
||||
*/
|
||||
|
||||
#ifndef COMM_BLE_CONSOLECOMMANDS_H
|
||||
#define COMM_BLE_CONSOLECOMMANDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Include Files */
|
||||
|
||||
/* Preprocessor and Type Definitions */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Public Functions */
|
||||
COMM_Console_Command_Result_T COMM_HandleBLECommand(char8 * data, uint32_t size);
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMM_BLE_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,73 @@
|
|||
/** \file
|
||||
* \brief This file defines the serial console commands for this CPU.
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Private Function Prototypes */
|
||||
static COMM_Console_Command_Result_T HandleConsoleHelp(char8 * data, uint32_t size);
|
||||
static COMM_Console_Command_Result_T HandleConsoleComment(char8 * data, uint32_t size);
|
||||
static COMM_Console_Command_Result_T HandleConsoleUptime(char8 * data, uint32_t size);
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
const COMM_Console_Command_Table_Entry_T COMM_Console_Command_Table[] =
|
||||
{
|
||||
{"?", " Show this help.", HandleConsoleHelp},
|
||||
{"#", " Comment (Do not omit the space after the #.)", HandleConsoleComment},
|
||||
{"event", " Generate an event in the high-level state machine (\'event ?\' for help).", COMM_HandleEventCommand},
|
||||
{"ble", " Interact with the Bluetooth Low Energy subsystem (try \'ble ?\').", COMM_HandleBLECommand},
|
||||
{"up", " Display uptime.", HandleConsoleUptime},
|
||||
{"cpu (r)", " Display CPU usage ('r' to reset maximum).", COMM_RTOS_HandleConsoleCPU},
|
||||
{"stack", " Display stack usage.", COMM_RTOS_HandleConsoleStack},
|
||||
{"version", " Display RTOS version.", COMM_RTOS_HandleConsoleVersion},
|
||||
{"reboot", " Performs a software reset on both cores.", COMM_RTOS_HandleConsoleReboot},
|
||||
{"nvm", " Interact with the Nonvolatile Memory (try \'nvm ?\').", COMM_NVM_HandleConsoleNVMCommand},
|
||||
{"reprogram", " Loads the KTag bootloader for OTA reprogramming.", COMM_RTOS_HandleConsoleReprogram},
|
||||
};
|
||||
|
||||
//! Size of the #COMM_Console_Command_Table array (i.e. the number of console commands).
|
||||
const uint_fast16_t COMM_N_CONSOLE_COMMANDS = (uint_fast16_t) (sizeof(COMM_Console_Command_Table) / sizeof(COMM_Console_Command_Table_Entry_T));
|
||||
|
||||
/* Private Variables */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
/* Private Functions */
|
||||
|
||||
static COMM_Console_Command_Result_T HandleConsoleHelp(char8 * data, uint32_t size)
|
||||
{
|
||||
for (uint_fast16_t i = 0; i < COMM_N_CONSOLE_COMMANDS; i++)
|
||||
{
|
||||
COMM_Console_Print_String(COMM_Console_Command_Table[i].Command_Name);
|
||||
COMM_Console_Print_String(" ");
|
||||
COMM_Console_Print_String(COMM_Console_Command_Table[i].Help);
|
||||
COMM_Console_Print_String("\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static COMM_Console_Command_Result_T HandleConsoleComment(char8 * data, uint32_t size)
|
||||
{
|
||||
COMM_Console_Print_String("Comment.\n");
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static COMM_Console_Command_Result_T HandleConsoleUptime(char8 * data, uint32_t size)
|
||||
{
|
||||
#if (configTICK_RATE_HZ != 1000)
|
||||
#error This code assumes configTICK_RATE_HZ is set to 1000 (== 1ms ticks)!
|
||||
#endif // (configTICK_RATE_HZ != 1000)
|
||||
COMM_Console_Print_String("Up ");
|
||||
COMM_Console_Print_UInt32(xTaskGetTickCount());
|
||||
COMM_Console_Print_String(" milliseconds.\n");
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,30 @@
|
|||
/** \file
|
||||
* \brief This file configures the serial console commands on this CPU.
|
||||
*/
|
||||
|
||||
#ifndef COMM_CONSOLECOMMANDS_H
|
||||
#define COMM_CONSOLECOMMANDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Include Files */
|
||||
|
||||
/* Preprocessor and Type Definitions */
|
||||
|
||||
/* Public Variables */
|
||||
extern const COMM_Console_Command_Table_Entry_T COMM_Console_Command_Table[];
|
||||
extern const uint_fast16_t COMM_N_CONSOLE_COMMANDS;
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMM_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,207 @@
|
|||
/** \file
|
||||
* \brief This file defines the serial console commands for the Nonvolatile Memory.
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Private Function Prototypes */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Private Variables */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
/* Private Functions */
|
||||
|
||||
//! Console command handler for subcommands of the 'nvm' command.
|
||||
COMM_Console_Command_Result_T COMM_NVM_HandleConsoleNVMCommand(char8 * data, uint32_t size)
|
||||
{
|
||||
// data[0] through data[3] is 'nvm '.
|
||||
if (data[4] == '?')
|
||||
{
|
||||
COMM_Console_Print_String("nvm ? Display this help.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("nvm dump Display the entire Nonvolatile Memory.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("nvm names Display the NVM parameter names.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("nvm get <parameter> Display an individual parameter from NVM.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("nvm set <parameter> <value> Assign a value to an individual parameter in NVM (be careful!).\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
else if ((data[4] == 'd') && (data[5] == 'u') && (data[6] == 'm') && (data[7] == 'p'))
|
||||
{
|
||||
for (uint8_t i = 0; i < NVM_N_ONCHIP_EEPROM_ENTRIES; i++)
|
||||
{
|
||||
COMM_Console_Print_String("NVM[");
|
||||
COMM_Console_Print_UInt16(i);
|
||||
COMM_Console_Print_String("]: ");
|
||||
|
||||
for (uint8_t j = 0; j < NVM_OnChipEEPROMEntries[i]->Size; j++)
|
||||
{
|
||||
char8 buffer[3];
|
||||
|
||||
COMM_Console_ByteToHex(buffer, *(NVM_OnChipEEPROMEntries[i]->Value + j));
|
||||
COMM_Console_Print_String("0x");
|
||||
COMM_Console_Print_String(buffer);
|
||||
COMM_Console_Print_String(" ");
|
||||
}
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
}
|
||||
else if ((data[4] == 'n') && (data[5] == 'a') && (data[6] == 'm') && (data[7] == 'e') && (data[8] == 's'))
|
||||
{
|
||||
COMM_Console_Print_String("Valid NVM parameters:\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String(" test_1\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String(" test_2\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String(" volume\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
else if ((data[4] == 'g') && (data[5] == 'e') && (data[6] == 't') && (data[7] == ' '))
|
||||
{
|
||||
if (strncmp(&data[8], "volume", 6) == 0)
|
||||
{
|
||||
COMM_Console_Print_String("Volume: ");
|
||||
COMM_Console_Print_UInt8(NVM_VOLUME);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else if (strncmp(&data[8], "test_1", 6) == 0)
|
||||
{
|
||||
COMM_Console_Print_String("Test 1: ");
|
||||
COMM_Console_Print_UInt16(NVM_ONCHIP_TEST_1);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else if (strncmp(&data[8], "test_2", 6) == 0)
|
||||
{
|
||||
COMM_Console_Print_String("Test 2: ");
|
||||
COMM_Console_Print_UInt32(NVM_ONCHIP_TEST_2);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else if (strncmp(&data[8], "test_3", 6) == 0)
|
||||
{
|
||||
COMM_Console_Print_String("Test 3: ");
|
||||
COMM_Console_Print_UInt16(NVM_EXTERNAL_TEST_3);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else if (strncmp(&data[8], "test_4", 6) == 0)
|
||||
{
|
||||
COMM_Console_Print_String("Test 4: ");
|
||||
COMM_Console_Print_UInt32(NVM_EXTERNAL_TEST_4);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Unknown NVM parameter!\n");
|
||||
}
|
||||
}
|
||||
else if ((data[4] == 's') && (data[5] == 'e') && (data[6] == 't') && (data[7] == ' '))
|
||||
{
|
||||
if (strncmp(&data[8], "volume", 6) == 0)
|
||||
{
|
||||
uint8_t volume = 0;
|
||||
if (COMM_Console_DecodeParameterUInt8(&(data[15]), &volume) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
NVM_VOLUME = volume;
|
||||
NVM_SaveExternalEEPROMEntry(NVM_VOLUME_ENTRY_PTR);
|
||||
|
||||
COMM_Console_Print_String("Volume changed to ");
|
||||
COMM_Console_Print_UInt8(NVM_VOLUME);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||
}
|
||||
}
|
||||
else if (strncmp(&data[8], "test_1", 6) == 0)
|
||||
{
|
||||
uint16_t test_value = 0;
|
||||
if (COMM_Console_DecodeParameterUInt16(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
NVM_ONCHIP_TEST_1 = test_value;
|
||||
NVM_SaveOnChipEEPROMEntry(NVM_ONCHIP_TEST_1_ENTRY_PTR);
|
||||
|
||||
COMM_Console_Print_String("Test 1 value changed to ");
|
||||
COMM_Console_Print_UInt16(NVM_ONCHIP_TEST_1);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||
}
|
||||
}
|
||||
else if (strncmp(&data[8], "test_2", 6) == 0)
|
||||
{
|
||||
uint32_t test_value = 0;
|
||||
if (COMM_Console_DecodeParameterUInt32(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
NVM_ONCHIP_TEST_2 = test_value;
|
||||
NVM_SaveOnChipEEPROMEntry(NVM_ONCHIP_TEST_2_ENTRY_PTR);
|
||||
|
||||
COMM_Console_Print_String("Test 2 value changed to ");
|
||||
COMM_Console_Print_UInt32(NVM_ONCHIP_TEST_2);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||
}
|
||||
}
|
||||
else if (strncmp(&data[8], "test_3", 6) == 0)
|
||||
{
|
||||
uint16_t test_value = 0;
|
||||
if (COMM_Console_DecodeParameterUInt16(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
NVM_EXTERNAL_TEST_3 = test_value;
|
||||
NVM_SaveExternalEEPROMEntry(NVM_EXTERNAL_TEST_3_ENTRY_PTR);
|
||||
|
||||
COMM_Console_Print_String("Test 3 value changed to ");
|
||||
COMM_Console_Print_UInt16(NVM_EXTERNAL_TEST_3);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||
}
|
||||
}
|
||||
else if (strncmp(&data[8], "test_4", 6) == 0)
|
||||
{
|
||||
uint32_t test_value = 0;
|
||||
if (COMM_Console_DecodeParameterUInt32(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
NVM_EXTERNAL_TEST_4 = test_value;
|
||||
NVM_SaveExternalEEPROMEntry(NVM_EXTERNAL_TEST_4_ENTRY_PTR);
|
||||
|
||||
COMM_Console_Print_String("Test 4 value changed to ");
|
||||
COMM_Console_Print_UInt32(NVM_EXTERNAL_TEST_4);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Unknown NVM parameter!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Unknown NVM command!\n");
|
||||
}
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
|||
/** \file
|
||||
* \brief This file declares the serial console commands for the Nonvolatile Memory.
|
||||
*/
|
||||
|
||||
#ifndef COMM_NVM_CONSOLECOMMANDS_H
|
||||
#define COMM_NVM_CONSOLECOMMANDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Include Files */
|
||||
|
||||
/* Preprocessor and Type Definitions */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Public Functions */
|
||||
COMM_Console_Command_Result_T COMM_NVM_HandleConsoleNVMCommand(char8 * data, uint32_t size);
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMM_NVM_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,120 @@
|
|||
/** \file
|
||||
* \brief This file defines the serial console commands for the RTOS package.
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Private Function Prototypes */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Private Variables */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
/* Private Functions */
|
||||
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleVersion(char8 * data, uint32_t size)
|
||||
{
|
||||
COMM_Console_Print_String("PSoC 6 running FreeRTOS ");
|
||||
|
||||
COMM_Console_Print_String(tskKERNEL_VERSION_NUMBER);
|
||||
|
||||
#ifdef NDEBUG
|
||||
COMM_Console_Print_String(" (Release, compiled ");
|
||||
#else
|
||||
COMM_Console_Print_String(" (Debug, compiled ");
|
||||
#endif // NDEBUG
|
||||
|
||||
COMM_Console_Print_String(__DATE__);
|
||||
COMM_Console_Print_String(" ");
|
||||
COMM_Console_Print_String(__TIME__);
|
||||
COMM_Console_Print_String(").\n");
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleStack(char8 * data, uint32_t size)
|
||||
{
|
||||
for (uint_fast8_t i = 0; i < CONFIG_N_TASK_HANDLES; i++)
|
||||
{
|
||||
TaskStatus_t status;
|
||||
vTaskGetInfo(*CONFIG_TaskHandles[i], &status, pdTRUE, eInvalid);
|
||||
COMM_Console_Print_String(status.pcTaskName);
|
||||
COMM_Console_Print_String(": ");
|
||||
COMM_Console_Print_UInt16(status.usStackHighWaterMark);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
|
||||
// Repeat for the Idle Task.
|
||||
{
|
||||
TaskStatus_t status;
|
||||
vTaskGetInfo(xTaskGetIdleTaskHandle(), &status, pdTRUE, eInvalid);
|
||||
COMM_Console_Print_String(status.pcTaskName);
|
||||
COMM_Console_Print_String(": ");
|
||||
COMM_Console_Print_UInt16(status.usStackHighWaterMark);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleCPU(char8 * data, uint32_t size)
|
||||
{
|
||||
// data[0] through data[3] is 'cpu '.
|
||||
if (data[4] == 'r')
|
||||
{
|
||||
//COMM_Console_Print_String("Max CPU reset.\n");
|
||||
COMM_Console_Print_String("(Not yet implemented.)\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint_fast8_t i = 0; i < CONFIG_N_TASK_HANDLES; i++)
|
||||
{
|
||||
TaskStatus_t status;
|
||||
vTaskGetInfo(*CONFIG_TaskHandles[i], &status, pdTRUE, eInvalid);
|
||||
COMM_Console_Print_String(status.pcTaskName);
|
||||
COMM_Console_Print_String(": ");
|
||||
COMM_Console_Print_UInt32(status.ulRunTimeCounter);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
|
||||
// Repeat for the Idle Task.
|
||||
{
|
||||
TaskStatus_t status;
|
||||
vTaskGetInfo(xTaskGetIdleTaskHandle(), &status, pdTRUE, eInvalid);
|
||||
COMM_Console_Print_String(status.pcTaskName);
|
||||
COMM_Console_Print_String(": ");
|
||||
COMM_Console_Print_UInt16(status.ulRunTimeCounter);
|
||||
COMM_Console_Print_String("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReboot(char8 * data, uint32_t size)
|
||||
{
|
||||
(void) COMM_SendMessageToOtherCore(COMM_SMM_RebootImmediately, NULL);
|
||||
|
||||
// Not that it matters...
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReprogram(char8 * data, uint32_t size)
|
||||
{
|
||||
COMM_Console_Print_String("Entering bootloader for BLE reprogramming.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
|
||||
Cy_DFU_ExecuteApp(0u);
|
||||
|
||||
// Not that it matters...
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,33 @@
|
|||
/** \file
|
||||
* \brief This file declares the serial console commands for the RTOS package.
|
||||
*/
|
||||
|
||||
#ifndef COMM_RTOS_CONSOLECOMMANDS_H
|
||||
#define COMM_RTOS_CONSOLECOMMANDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Include Files */
|
||||
|
||||
/* Preprocessor and Type Definitions */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Public Functions */
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleVersion(char8 * data, uint32_t size);
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleStack(char8 * data, uint32_t size);
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleCPU(char8 * data, uint32_t size);
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReboot(char8 * data, uint32_t size);
|
||||
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReprogram(char8 * data, uint32_t size);
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMM_RTOS_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,189 @@
|
|||
/** \file
|
||||
* \brief This file defines the serial console commands for the high-level state machine.
|
||||
*/
|
||||
|
||||
/* Include Files */
|
||||
#include "KTag.h"
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Local Definitions and Constants */
|
||||
|
||||
/* Private Function Prototypes */
|
||||
static void Simulate_Hit(uint8_t team_ID, uint16_t damage);
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Private Variables */
|
||||
|
||||
/* Public Functions */
|
||||
|
||||
//! Console command handler for the 'event' command.
|
||||
COMM_Console_Command_Result_T COMM_HandleEventCommand(char8 * data, uint32_t size)
|
||||
{
|
||||
// data[0] through data[5] is 'event '.
|
||||
|
||||
if (data[6] == '?')
|
||||
{
|
||||
COMM_Console_Print_String("event ? Display this help.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("event raw <id> Inject the event with ID <id>.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("event tag <n> Send <n> tag(s).\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
COMM_Console_Print_String("event hit <t> <d> Simulate a hit from team <t> for <d> damage.\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
else if ( (data[6] == 'r') &&
|
||||
(data[7] == 'a') &&
|
||||
(data[8] == 'w') )
|
||||
|
||||
{
|
||||
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: missing event ID!\n");
|
||||
}
|
||||
else if (data[9] == ' ')
|
||||
{
|
||||
uint16_t id = 0;
|
||||
|
||||
if (COMM_Console_DecodeParameterUInt16(&(data[10]), &id) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
if ((id > KEVENT_NO_EVENT) && (id < KEVENT_IS_OUT_OF_RANGE))
|
||||
{
|
||||
KEvent_T raw_event = { .ID = id, .Data = (void *)0x00 };
|
||||
Post_KEvent(&raw_event);
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: specified event ID (");
|
||||
COMM_Console_Print_UInt16(id);
|
||||
COMM_Console_Print_String(") is invalid!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: could not comprehend event ID!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||
}
|
||||
}
|
||||
else if ( (data[6] == 't') &&
|
||||
(data[7] == 'a') &&
|
||||
(data[8] == 'g') )
|
||||
|
||||
{
|
||||
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||
{
|
||||
if (Send_Tag() == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
COMM_Console_Print_String("Tag sent.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("Error: Couldn't send tag!\n");
|
||||
}
|
||||
}
|
||||
else if (data[9] == ' ')
|
||||
{
|
||||
uint16_t times = 0;
|
||||
|
||||
if (COMM_Console_DecodeParameterUInt16(&(data[10]), ×) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
while (times > 0)
|
||||
{
|
||||
if (Send_Tag() == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
COMM_Console_Print_String("Tag sent.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("Error: Couldn't send tag!\n");
|
||||
}
|
||||
//! \todo Why can't the console command 'event tag <n>' send tags faster than once per second?
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
times--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: could not comprehend tag repetitions!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||
}
|
||||
}
|
||||
else if ( (data[6] == 'h') &&
|
||||
(data[7] == 'i') &&
|
||||
(data[8] == 't') )
|
||||
|
||||
{
|
||||
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||
{
|
||||
Simulate_Hit(1, 10);
|
||||
COMM_Console_Print_String("Hit!\n");
|
||||
}
|
||||
else if (data[9] == ' ')
|
||||
{
|
||||
uint8_t team_ID = 0;
|
||||
uint16_t damage = 10;
|
||||
|
||||
if (COMM_Console_DecodeParameterUInt8(&(data[10]), &team_ID) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
const char * damage_location;
|
||||
|
||||
// Damage is the first parameter after team ID.
|
||||
if (COMM_Console_FindNthParameter(&(data[10]), 1, &damage_location) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
if (COMM_Console_DecodeParameterUInt16(damage_location, &damage) != COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: could not comprehend damage--using default.\n");
|
||||
damage = 10;
|
||||
}
|
||||
}
|
||||
Simulate_Hit(team_ID, damage);
|
||||
COMM_Console_Print_String("Hit!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: could not comprehend team ID!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
COMM_Console_Print_String("ERROR: Unknown event command!\n");
|
||||
}
|
||||
|
||||
|
||||
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private Functions */
|
||||
|
||||
static void Simulate_Hit(uint8_t team_ID, uint16_t damage)
|
||||
{
|
||||
static DecodedPacket_T Simulated_Tag_Rx_Buffer;
|
||||
static KEvent_T tag_received_event;
|
||||
|
||||
Simulated_Tag_Rx_Buffer.Tag.type = DECODED_PACKET_TYPE_TAG_RECEIVED;
|
||||
Simulated_Tag_Rx_Buffer.Tag.protocol = LASER_X_PROTOCOL;
|
||||
Simulated_Tag_Rx_Buffer.Tag.player_ID = 0x00;
|
||||
Simulated_Tag_Rx_Buffer.Tag.team_ID = team_ID;
|
||||
Simulated_Tag_Rx_Buffer.Tag.damage = damage;
|
||||
Simulated_Tag_Rx_Buffer.Tag.color = GetColorFromTeamID(team_ID);
|
||||
tag_received_event.ID = KEVENT_TAG_RECEIVED;
|
||||
tag_received_event.Data = &Simulated_Tag_Rx_Buffer;
|
||||
Post_KEvent(&tag_received_event);
|
||||
}
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
|||
/** \file
|
||||
* \brief This file declares the serial console commands for the high-level state machine.
|
||||
*/
|
||||
|
||||
#ifndef COMM_STATE_CONSOLECOMMANDS_H
|
||||
#define COMM_STATE_CONSOLECOMMANDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
/* Include Files */
|
||||
|
||||
/* Preprocessor and Type Definitions */
|
||||
|
||||
/* Public Variables */
|
||||
|
||||
/* Public Functions */
|
||||
COMM_Console_Command_Result_T COMM_HandleEventCommand(char8 * data, uint32_t size);
|
||||
|
||||
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMM_STATE_CONSOLECOMMANDS_H
|
Loading…
Add table
Add a link
Reference in a new issue