Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown command in menu, update COMM_xx enums to match bldc #345

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,15 @@ void Commands::reboot()
emitData(vb);
}

void Commands::shutdown()
{
VByteArray vb;
vb.vbAppendInt8(COMM_SHUTDOWN);
vb.vbAppendInt8(0);
vb.vbAppendInt8(0);
emitData(vb);
}

void Commands::sendAlive()
{
VByteArray vb;
Expand Down
1 change: 1 addition & 0 deletions commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public slots:
void setAppConfNoStore();
void detectMotorParam(double current, double min_rpm, double low_duty);
void reboot();
void shutdown();
void sendAlive();
void getDecodedPpm();
void getDecodedAdc();
Expand Down
355 changes: 182 additions & 173 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,179 +883,188 @@ typedef enum {
} debug_sampling_mode;

typedef enum {
COMM_FW_VERSION = 0,
COMM_JUMP_TO_BOOTLOADER,
COMM_ERASE_NEW_APP,
COMM_WRITE_NEW_APP_DATA,
COMM_GET_VALUES,
COMM_SET_DUTY,
COMM_SET_CURRENT,
COMM_SET_CURRENT_BRAKE,
COMM_SET_RPM,
COMM_SET_POS,
COMM_SET_HANDBRAKE,
COMM_SET_DETECT,
COMM_SET_SERVO_POS,
COMM_SET_MCCONF,
COMM_GET_MCCONF,
COMM_GET_MCCONF_DEFAULT,
COMM_SET_APPCONF,
COMM_GET_APPCONF,
COMM_GET_APPCONF_DEFAULT,
COMM_SAMPLE_PRINT,
COMM_TERMINAL_CMD,
COMM_PRINT,
COMM_ROTOR_POSITION,
COMM_EXPERIMENT_SAMPLE,
COMM_DETECT_MOTOR_PARAM,
COMM_DETECT_MOTOR_R_L,
COMM_DETECT_MOTOR_FLUX_LINKAGE,
COMM_DETECT_ENCODER,
COMM_DETECT_HALL_FOC,
COMM_REBOOT,
COMM_ALIVE,
COMM_GET_DECODED_PPM,
COMM_GET_DECODED_ADC,
COMM_GET_DECODED_CHUK,
COMM_FORWARD_CAN,
COMM_SET_CHUCK_DATA,
COMM_CUSTOM_APP_DATA,
COMM_NRF_START_PAIRING,
COMM_GPD_SET_FSW,
COMM_GPD_BUFFER_NOTIFY,
COMM_GPD_BUFFER_SIZE_LEFT,
COMM_GPD_FILL_BUFFER,
COMM_GPD_OUTPUT_SAMPLE,
COMM_GPD_SET_MODE,
COMM_GPD_FILL_BUFFER_INT8,
COMM_GPD_FILL_BUFFER_INT16,
COMM_GPD_SET_BUFFER_INT_SCALE,
COMM_GET_VALUES_SETUP,
COMM_SET_MCCONF_TEMP,
COMM_SET_MCCONF_TEMP_SETUP,
COMM_GET_VALUES_SELECTIVE,
COMM_GET_VALUES_SETUP_SELECTIVE,
COMM_EXT_NRF_PRESENT,
COMM_EXT_NRF_ESB_SET_CH_ADDR,
COMM_EXT_NRF_ESB_SEND_DATA,
COMM_EXT_NRF_ESB_RX_DATA,
COMM_EXT_NRF_SET_ENABLED,
COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP,
COMM_DETECT_APPLY_ALL_FOC,
COMM_JUMP_TO_BOOTLOADER_ALL_CAN,
COMM_ERASE_NEW_APP_ALL_CAN,
COMM_WRITE_NEW_APP_DATA_ALL_CAN,
COMM_PING_CAN,
COMM_APP_DISABLE_OUTPUT,
COMM_TERMINAL_CMD_SYNC,
COMM_GET_IMU_DATA,
COMM_BM_CONNECT,
COMM_BM_ERASE_FLASH_ALL,
COMM_BM_WRITE_FLASH,
COMM_BM_REBOOT,
COMM_BM_DISCONNECT,
COMM_BM_MAP_PINS_DEFAULT,
COMM_BM_MAP_PINS_NRF5X,
COMM_ERASE_BOOTLOADER,
COMM_ERASE_BOOTLOADER_ALL_CAN,
COMM_PLOT_INIT,
COMM_PLOT_DATA,
COMM_PLOT_ADD_GRAPH,
COMM_PLOT_SET_GRAPH,
COMM_GET_DECODED_BALANCE,
COMM_BM_MEM_READ,
COMM_WRITE_NEW_APP_DATA_LZO,
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
COMM_BM_WRITE_FLASH_LZO,
COMM_SET_CURRENT_REL,
COMM_CAN_FWD_FRAME,
COMM_SET_BATTERY_CUT,
COMM_SET_BLE_NAME,
COMM_SET_BLE_PIN,
COMM_SET_CAN_MODE,
COMM_GET_IMU_CALIBRATION,
COMM_GET_MCCONF_TEMP,

// Custom configuration for hardware
COMM_GET_CUSTOM_CONFIG_XML,
COMM_GET_CUSTOM_CONFIG,
COMM_GET_CUSTOM_CONFIG_DEFAULT,
COMM_SET_CUSTOM_CONFIG,

// BMS commands
COMM_BMS_GET_VALUES,
COMM_BMS_SET_CHARGE_ALLOWED,
COMM_BMS_SET_BALANCE_OVERRIDE,
COMM_BMS_RESET_COUNTERS,
COMM_BMS_FORCE_BALANCE,
COMM_BMS_ZERO_CURRENT_OFFSET,

// FW updates commands for different HW types
COMM_JUMP_TO_BOOTLOADER_HW,
COMM_ERASE_NEW_APP_HW,
COMM_WRITE_NEW_APP_DATA_HW,
COMM_ERASE_BOOTLOADER_HW,
COMM_JUMP_TO_BOOTLOADER_ALL_CAN_HW,
COMM_ERASE_NEW_APP_ALL_CAN_HW,
COMM_WRITE_NEW_APP_DATA_ALL_CAN_HW,
COMM_ERASE_BOOTLOADER_ALL_CAN_HW,

COMM_SET_ODOMETER,

// Power switch commands
COMM_PSW_GET_STATUS,
COMM_PSW_SWITCH,

COMM_BMS_FWD_CAN_RX,
COMM_BMS_HW_DATA,
COMM_GET_BATTERY_CUT,
COMM_BM_HALT_REQ,
COMM_GET_QML_UI_HW,
COMM_GET_QML_UI_APP,
COMM_CUSTOM_HW_DATA,
COMM_QMLUI_ERASE,
COMM_QMLUI_WRITE,

// IO Board
COMM_IO_BOARD_GET_ALL,
COMM_IO_BOARD_SET_PWM,
COMM_IO_BOARD_SET_DIGITAL,

COMM_BM_MEM_WRITE,
COMM_BMS_BLNC_SELFTEST,
COMM_GET_EXT_HUM_TMP,
COMM_GET_STATS,
COMM_RESET_STATS,

// Lisp
COMM_LISP_READ_CODE,
COMM_LISP_WRITE_CODE,
COMM_LISP_ERASE_CODE,
COMM_LISP_SET_RUNNING,
COMM_LISP_GET_STATS,
COMM_LISP_PRINT,

COMM_BMS_SET_BATT_TYPE,
COMM_BMS_GET_BATT_TYPE,

COMM_LISP_REPL_CMD,
COMM_LISP_STREAM_CODE,

COMM_FILE_LIST,
COMM_FILE_READ,
COMM_FILE_WRITE,
COMM_FILE_MKDIR,
COMM_FILE_REMOVE,

COMM_LOG_START,
COMM_LOG_STOP,
COMM_LOG_CONFIG_FIELD,
COMM_LOG_DATA_F32,

COMM_SET_APPCONF_NO_STORE,
COMM_GET_GNSS,

COMM_LOG_DATA_F64,
COMM_FW_VERSION = 0,
COMM_JUMP_TO_BOOTLOADER = 1,
COMM_ERASE_NEW_APP = 2,
COMM_WRITE_NEW_APP_DATA = 3,
COMM_GET_VALUES = 4,
COMM_SET_DUTY = 5,
COMM_SET_CURRENT = 6,
COMM_SET_CURRENT_BRAKE = 7,
COMM_SET_RPM = 8,
COMM_SET_POS = 9,
COMM_SET_HANDBRAKE = 10,
COMM_SET_DETECT = 11,
COMM_SET_SERVO_POS = 12,
COMM_SET_MCCONF = 13,
COMM_GET_MCCONF = 14,
COMM_GET_MCCONF_DEFAULT = 15,
COMM_SET_APPCONF = 16,
COMM_GET_APPCONF = 17,
COMM_GET_APPCONF_DEFAULT = 18,
COMM_SAMPLE_PRINT = 19,
COMM_TERMINAL_CMD = 20,
COMM_PRINT = 21,
COMM_ROTOR_POSITION = 22,
COMM_EXPERIMENT_SAMPLE = 23,
COMM_DETECT_MOTOR_PARAM = 24,
COMM_DETECT_MOTOR_R_L = 25,
COMM_DETECT_MOTOR_FLUX_LINKAGE = 26,
COMM_DETECT_ENCODER = 27,
COMM_DETECT_HALL_FOC = 28,
COMM_REBOOT = 29,
COMM_ALIVE = 30,
COMM_GET_DECODED_PPM = 31,
COMM_GET_DECODED_ADC = 32,
COMM_GET_DECODED_CHUK = 33,
COMM_FORWARD_CAN = 34,
COMM_SET_CHUCK_DATA = 35,
COMM_CUSTOM_APP_DATA = 36,
COMM_NRF_START_PAIRING = 37,
COMM_GPD_SET_FSW = 38,
COMM_GPD_BUFFER_NOTIFY = 39,
COMM_GPD_BUFFER_SIZE_LEFT = 40,
COMM_GPD_FILL_BUFFER = 41,
COMM_GPD_OUTPUT_SAMPLE = 42,
COMM_GPD_SET_MODE = 43,
COMM_GPD_FILL_BUFFER_INT8 = 44,
COMM_GPD_FILL_BUFFER_INT16 = 45,
COMM_GPD_SET_BUFFER_INT_SCALE = 46,
COMM_GET_VALUES_SETUP = 47,
COMM_SET_MCCONF_TEMP = 48,
COMM_SET_MCCONF_TEMP_SETUP = 49,
COMM_GET_VALUES_SELECTIVE = 50,
COMM_GET_VALUES_SETUP_SELECTIVE = 51,
COMM_EXT_NRF_PRESENT = 52,
COMM_EXT_NRF_ESB_SET_CH_ADDR = 53,
COMM_EXT_NRF_ESB_SEND_DATA = 54,
COMM_EXT_NRF_ESB_RX_DATA = 55,
COMM_EXT_NRF_SET_ENABLED = 56,
COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP = 57,
COMM_DETECT_APPLY_ALL_FOC = 58,
COMM_JUMP_TO_BOOTLOADER_ALL_CAN = 59,
COMM_ERASE_NEW_APP_ALL_CAN = 60,
COMM_WRITE_NEW_APP_DATA_ALL_CAN = 61,
COMM_PING_CAN = 62,
COMM_APP_DISABLE_OUTPUT = 63,
COMM_TERMINAL_CMD_SYNC = 64,
COMM_GET_IMU_DATA = 65,
COMM_BM_CONNECT = 66,
COMM_BM_ERASE_FLASH_ALL = 67,
COMM_BM_WRITE_FLASH = 68,
COMM_BM_REBOOT = 69,
COMM_BM_DISCONNECT = 70,
COMM_BM_MAP_PINS_DEFAULT = 71,
COMM_BM_MAP_PINS_NRF5X = 72,
COMM_ERASE_BOOTLOADER = 73,
COMM_ERASE_BOOTLOADER_ALL_CAN = 74,
COMM_PLOT_INIT = 75,
COMM_PLOT_DATA = 76,
COMM_PLOT_ADD_GRAPH = 77,
COMM_PLOT_SET_GRAPH = 78,
COMM_GET_DECODED_BALANCE = 79,
COMM_BM_MEM_READ = 80,
COMM_WRITE_NEW_APP_DATA_LZO = 81,
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO = 82,
COMM_BM_WRITE_FLASH_LZO = 83,
COMM_SET_CURRENT_REL = 84,
COMM_CAN_FWD_FRAME = 85,
COMM_SET_BATTERY_CUT = 86,
COMM_SET_BLE_NAME = 87,
COMM_SET_BLE_PIN = 88,
COMM_SET_CAN_MODE = 89,
COMM_GET_IMU_CALIBRATION = 90,
COMM_GET_MCCONF_TEMP = 91,

// Custom configuration for hardware
COMM_GET_CUSTOM_CONFIG_XML = 92,
COMM_GET_CUSTOM_CONFIG = 93,
COMM_GET_CUSTOM_CONFIG_DEFAULT = 94,
COMM_SET_CUSTOM_CONFIG = 95,

// BMS commands
COMM_BMS_GET_VALUES = 96,
COMM_BMS_SET_CHARGE_ALLOWED = 97,
COMM_BMS_SET_BALANCE_OVERRIDE = 98,
COMM_BMS_RESET_COUNTERS = 99,
COMM_BMS_FORCE_BALANCE = 100,
COMM_BMS_ZERO_CURRENT_OFFSET = 101,

// FW updates commands for different HW types
COMM_JUMP_TO_BOOTLOADER_HW = 102,
COMM_ERASE_NEW_APP_HW = 103,
COMM_WRITE_NEW_APP_DATA_HW = 104,
COMM_ERASE_BOOTLOADER_HW = 105,
COMM_JUMP_TO_BOOTLOADER_ALL_CAN_HW = 106,
COMM_ERASE_NEW_APP_ALL_CAN_HW = 107,
COMM_WRITE_NEW_APP_DATA_ALL_CAN_HW = 108,
COMM_ERASE_BOOTLOADER_ALL_CAN_HW = 109,

COMM_SET_ODOMETER = 110,

// Power switch commands
COMM_PSW_GET_STATUS = 111,
COMM_PSW_SWITCH = 112,

COMM_BMS_FWD_CAN_RX = 113,
COMM_BMS_HW_DATA = 114,
COMM_GET_BATTERY_CUT = 115,
COMM_BM_HALT_REQ = 116,
COMM_GET_QML_UI_HW = 117,
COMM_GET_QML_UI_APP = 118,
COMM_CUSTOM_HW_DATA = 119,
COMM_QMLUI_ERASE = 120,
COMM_QMLUI_WRITE = 121,

// IO Board
COMM_IO_BOARD_GET_ALL = 122,
COMM_IO_BOARD_SET_PWM = 123,
COMM_IO_BOARD_SET_DIGITAL = 124,

COMM_BM_MEM_WRITE = 125,
COMM_BMS_BLNC_SELFTEST = 126,
COMM_GET_EXT_HUM_TMP = 127,
COMM_GET_STATS = 128,
COMM_RESET_STATS = 129,

// Lisp
COMM_LISP_READ_CODE = 130,
COMM_LISP_WRITE_CODE = 131,
COMM_LISP_ERASE_CODE = 132,
COMM_LISP_SET_RUNNING = 133,
COMM_LISP_GET_STATS = 134,
COMM_LISP_PRINT = 135,

COMM_BMS_SET_BATT_TYPE = 136,
COMM_BMS_GET_BATT_TYPE = 137,

COMM_LISP_REPL_CMD = 138,
COMM_LISP_STREAM_CODE = 139,

COMM_FILE_LIST = 140,
COMM_FILE_READ = 141,
COMM_FILE_WRITE = 142,
COMM_FILE_MKDIR = 143,
COMM_FILE_REMOVE = 144,

COMM_LOG_START = 145,
COMM_LOG_STOP = 146,
COMM_LOG_CONFIG_FIELD = 147,
COMM_LOG_DATA_F32 = 148,

COMM_SET_APPCONF_NO_STORE = 149,
COMM_GET_GNSS = 150,

COMM_LOG_DATA_F64 = 151,

COMM_LISP_RMSG = 152,

//Placeholders for pinlock commands
//COMM_PINLOCK1 = 153,
//COMM_PINLOCK2 = 154,
//COMM_PINLOCK3 = 155,

COMM_SHUTDOWN = 156,
} COMM_PACKET_ID;

// CAN commands
Expand Down
Loading
Loading