#include "commands.h" /* This file defines the commands structure. * This is the canonical reference for all commands * used. This file can be used - unchanged - on both the quad side * and on the ground station side. The commands.h file is also entirely * portable and may be used unchanged. * * This file (commands.c) and the matching header (commands.h) * are fully portable (quad + groundStation). * * To use this file, three non-portable files must also exist: * - callbacks.h. Typedef for command_cb * - cb_default.h. Implementation of cb_default. * - callbacks.c file. Contains implemented callbacks. * * There are two mandatory things that must be implemented in * other files for this to work: First, in callbacks.h, create a typedef * for command_cb. See the callbacks.h of the ground station for an * example. * * Second, in cb_default.h, implement the function * cb_default. This function should do nothing; it will be the * default action for an unimplemented callback. Note that because * the function is implemented in the .h file, cb_default.h MUST NOT * be included in any other file! * * To implement callbacks, simply define them in callbacks.c. * * * EXTENDING COMMANDS.C * * To extend this file, simply add the new subtypes (typically * a Setter, Getter, and Response) and create weak aliases below. * * Ensure the Quad and GroundStation always maintain this file in sync! * */ /* List of callbacks. DO NOT MODIFY THESE IN THIS FILE - * Simply implement a function with the same name * in a different file (callbacks.c) and these will * be overridden. */ /* Grab the default callback implementation */ #include "cb_default.h" /* Misc. callbacks */ command_cb cb_debug __attribute__((weak, alias("cb_default"))); command_cb cb_packetlog __attribute__((weak, alias("cb_default"))); command_cb cb_getpacketlogs __attribute__((weak, alias("cb_default"))); command_cb cb_update __attribute__((weak, alias("cb_default"))); command_cb cb_beginupdate __attribute__((weak, alias("cb_default"))); command_cb cb_log __attribute__((weak, alias("cb_default"))); command_cb cb_response __attribute__((weak, alias("cb_default"))); /* Callbacks for configuration (setters)*/ command_cb cb_setyawp __attribute__((weak, alias("cb_default"))); command_cb cb_setyawi __attribute__((weak, alias("cb_default"))); command_cb cb_setyawd __attribute__((weak, alias("cb_default"))); command_cb cb_setrollp __attribute__((weak, alias("cb_default"))); command_cb cb_setrolli __attribute__((weak, alias("cb_default"))); command_cb cb_setrolld __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchp __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchi __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchd __attribute__((weak, alias("cb_default"))); command_cb cb_setyawratep __attribute__((weak, alias("cb_default"))); command_cb cb_setyawratei __attribute__((weak, alias("cb_default"))); command_cb cb_setyawrated __attribute__((weak, alias("cb_default"))); command_cb cb_setrollratep __attribute__((weak, alias("cb_default"))); command_cb cb_setrollratei __attribute__((weak, alias("cb_default"))); command_cb cb_setrollrated __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchratep __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchratei __attribute__((weak, alias("cb_default"))); command_cb cb_setpitchrated __attribute__((weak, alias("cb_default"))); command_cb cb_setxp __attribute__((weak, alias("cb_default"))); command_cb cb_setxi __attribute__((weak, alias("cb_default"))); command_cb cb_setxd __attribute__((weak, alias("cb_default"))); command_cb cb_setyp __attribute__((weak, alias("cb_default"))); command_cb cb_setyi __attribute__((weak, alias("cb_default"))); command_cb cb_setyd __attribute__((weak, alias("cb_default"))); command_cb cb_setheightp __attribute__((weak, alias("cb_default"))); command_cb cb_setheighti __attribute__((weak, alias("cb_default"))); command_cb cb_setheightd __attribute__((weak, alias("cb_default"))); command_cb cb_setheight __attribute__((weak, alias("cb_default"))); command_cb cb_setx __attribute__((weak, alias("cb_default"))); command_cb cb_sety __attribute__((weak, alias("cb_default"))); command_cb cb_setlon __attribute__((weak, alias("cb_default"))); command_cb cb_setlat __attribute__((weak, alias("cb_default"))); command_cb cb_setyaw __attribute__((weak, alias("cb_default"))); command_cb cb_setpitch __attribute__((weak, alias("cb_default"))); command_cb cb_setroll __attribute__((weak, alias("cb_default"))); /* Default callbacks for getters */ command_cb cb_getyawp __attribute__((weak, alias("cb_default"))); command_cb cb_getyawi __attribute__((weak, alias("cb_default"))); command_cb cb_getyawd __attribute__((weak, alias("cb_default"))); command_cb cb_getrollp __attribute__((weak, alias("cb_default"))); command_cb cb_getrolli __attribute__((weak, alias("cb_default"))); command_cb cb_getrolld __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchp __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchi __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchd __attribute__((weak, alias("cb_default"))); command_cb cb_getyawratep __attribute__((weak, alias("cb_default"))); command_cb cb_getyawratei __attribute__((weak, alias("cb_default"))); command_cb cb_getyawrated __attribute__((weak, alias("cb_default"))); command_cb cb_getrollratep __attribute__((weak, alias("cb_default"))); command_cb cb_getrollratei __attribute__((weak, alias("cb_default"))); command_cb cb_getrollrated __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchratep __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchratei __attribute__((weak, alias("cb_default"))); command_cb cb_getpitchrated __attribute__((weak, alias("cb_default"))); command_cb cb_getxp __attribute__((weak, alias("cb_default"))); command_cb cb_getxi __attribute__((weak, alias("cb_default"))); command_cb cb_getxd __attribute__((weak, alias("cb_default"))); command_cb cb_getyp __attribute__((weak, alias("cb_default"))); command_cb cb_getyi __attribute__((weak, alias("cb_default"))); command_cb cb_getyd __attribute__((weak, alias("cb_default"))); command_cb cb_getheightp __attribute__((weak, alias("cb_default"))); command_cb cb_getheighti __attribute__((weak, alias("cb_default"))); command_cb cb_getheightd __attribute__((weak, alias("cb_default"))); command_cb cb_getheight __attribute__((weak, alias("cb_default"))); command_cb cb_getx __attribute__((weak, alias("cb_default"))); command_cb cb_gety __attribute__((weak, alias("cb_default"))); command_cb cb_getlon __attribute__((weak, alias("cb_default"))); command_cb cb_getlat __attribute__((weak, alias("cb_default"))); command_cb cb_getyaw __attribute__((weak, alias("cb_default"))); command_cb cb_getpitch __attribute__((weak, alias("cb_default"))); command_cb cb_getroll __attribute__((weak, alias("cb_default"))); /* Default callbacks for responses */ command_cb cb_respyawp __attribute__((weak, alias("cb_default"))); command_cb cb_respyawi __attribute__((weak, alias("cb_default"))); command_cb cb_respyawd __attribute__((weak, alias("cb_default"))); command_cb cb_resprollp __attribute__((weak, alias("cb_default"))); command_cb cb_resprolli __attribute__((weak, alias("cb_default"))); command_cb cb_resprolld __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchp __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchi __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchd __attribute__((weak, alias("cb_default"))); command_cb cb_respyawratep __attribute__((weak, alias("cb_default"))); command_cb cb_respyawratei __attribute__((weak, alias("cb_default"))); command_cb cb_respyawrated __attribute__((weak, alias("cb_default"))); command_cb cb_resprollratep __attribute__((weak, alias("cb_default"))); command_cb cb_resprollratei __attribute__((weak, alias("cb_default"))); command_cb cb_resprollrated __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchratep __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchratei __attribute__((weak, alias("cb_default"))); command_cb cb_resppitchrated __attribute__((weak, alias("cb_default"))); command_cb cb_respxp __attribute__((weak, alias("cb_default"))); command_cb cb_respxi __attribute__((weak, alias("cb_default"))); command_cb cb_respxd __attribute__((weak, alias("cb_default"))); command_cb cb_respyp __attribute__((weak, alias("cb_default"))); command_cb cb_respyi __attribute__((weak, alias("cb_default"))); command_cb cb_respyd __attribute__((weak, alias("cb_default"))); command_cb cb_respheightp __attribute__((weak, alias("cb_default"))); command_cb cb_respheighti __attribute__((weak, alias("cb_default"))); command_cb cb_respheightd __attribute__((weak, alias("cb_default"))); command_cb cb_respheight __attribute__((weak, alias("cb_default"))); command_cb cb_respx __attribute__((weak, alias("cb_default"))); command_cb cb_respy __attribute__((weak, alias("cb_default"))); command_cb cb_resplon __attribute__((weak, alias("cb_default"))); command_cb cb_resplat __attribute__((weak, alias("cb_default"))); command_cb cb_respyaw __attribute__((weak, alias("cb_default"))); command_cb cb_resppitch __attribute__((weak, alias("cb_default"))); command_cb cb_resproll __attribute__((weak, alias("cb_default"))); /* Command structure */ struct MessageType MessageTypes[MAX_TYPE] = { // DEBUG { // Message Type ID 0x00, // Debug Subtypes { // NONE subtype { // ID 0x00, // Command text "debug", // Type of the command data stringType, // Function pointer &cb_debug }, // NONE subtype { // ID 0x01, // Command text "packetlog", // Type of the command data stringType, // Function pointer &cb_packetlog }, // NONE subtype { // ID 0x02, // Command text "getpacketlogs", // Type of the command data stringType, // Function pointer &cb_getpacketlogs } } }, // CALIBRATION { // Message Type ID 0x01, // Calibration Subtypes (PID coefficients) { // yaw p constant subtype { // ID 0x00, // Command text "setyawp", // Type of the command data floatType, // Function pointer &cb_setyawp }, // yaw i constant subtype { // ID 0x01, // Command text "setyawi", // Type of the command data floatType, // Function pointer &cb_setyawi }, // yaw d constant subtype { // ID 0x02, // Command text "setyawd", // Type of the command data floatType, // Function pointer &cb_setyawd }, // roll p constant subtype { // ID 0x03, // Command text "setrollp", // Type of the command data floatType, // Function pointer &cb_setrollp }, // roll i constant subtype { // ID 0x04, // Command text "setrolli", // Type of the command data floatType, // Function pointer &cb_setrolli }, // roll d constant subtype { // ID 0x05, // Command text "setrolld", // Type of the command data floatType, // Function pointer &cb_setrolld }, // pitch p constant subtype { // ID 0x06, // Command text "setpitchp", // Type of the command data floatType, // Function pointer &cb_setpitchp }, // pitch i constant subtype { // ID 0x07, // Command text "setpitchi", // Type of the command data floatType, // Function pointer &cb_setpitchi }, // pitch d constant subtype { // ID 0x08, // Command text "setpitchd", // Type of the command data floatType, // Function pointer &cb_setpitchd }, // yawrate p constant subtype { // ID 0x09, // Command text "setyawratep", // Type of the command data floatType, // Function pointer &cb_setyawratep }, // yawrate i constant subtype { // ID 0x0A, // Command text "setyawratei", // Type of the command data floatType, // Function pointer &cb_setyawratei }, // yawrate d constant subtype { // ID 0x0B, // Command text "setyawrated", // Type of the command data floatType, // Function pointer &cb_setyawrated }, // rollrate p constant subtype { // ID 0x0C, // Command text "setrollratep", // Type of the command data floatType, // Function pointer &cb_setrollratep }, // rollrate i constant subtype { // ID 0x0D, // Command text "setrollratei", // Type of the command data floatType, // Function pointer &cb_setrollratei }, // rollrate d constant subtype { // ID 0x0E, // Command text "setrollrated", // Type of the command data floatType, // Function pointer &cb_setrollrated }, // pitchrate p constant subtype { // ID 0x0F, // Command text "setpitchratep", // Type of the command data floatType, // Function pointer &cb_setpitchratep }, // pitchrate i constant subtype { // ID 0x10, // Command text "setpitchratei", // Type of the command data floatType, // Function pointer &cb_setpitchratei }, // pitchrate d constant subtype { // ID 0x11, // Command text "setpitchrated", // Type of the command data floatType, // Function pointer &cb_setpitchrated }, // height p constant subtype { // ID 0x12, // Command text "setheightp", // Type of the command data floatType, // Function pointer &cb_setheightp }, // height i constant subtype { // ID 0x13, // Command text "setheighti", // Type of the command data floatType, // Function pointer &cb_setheighti }, // height d constant subtype { // ID 0x14, // Command text "setheightd", // Type of the command data floatType, // Function pointer &cb_setheightd }, // x p constant subtype { // ID 0x15, // Command text "setxp", // Type of the command data floatType, // Function pointer &cb_setxp }, // x i constant subtype { // ID 0x16, // Command text "setxi", // Type of the command data floatType, // Function pointer &cb_setxi }, // x d constant subtype { // ID 0x17, // Command text "setxd", // Type of the command data floatType, // Function pointer &cb_setxd }, // y p constant subtype { // ID 0x18, // Command text "setyp", // Type of the command data floatType, // Function pointer &cb_setyp }, // y i constant subtype { // ID 0x19, // Command text "setyi", // Type of the command data floatType, // Function pointer &cb_setyi }, // y d constant subtype { // ID 0x1A, // Command text "setyd", // Type of the command data floatType, // Function pointer &cb_setyd }, // height setpoint subtype { // ID 0x1B, // Command text "setheight", // Type of the command data floatType, // Function pointer &cb_setheight }, // x setpoint subtype { // ID 0x1C, // Command text "setx", // Type of the command data floatType, // Function pointer &cb_setx }, // y setpoint subtype { // ID 0x1D, // Command text "sety", // Type of the command data floatType, // Function pointer &cb_sety }, // yaw setpoint subtype { // ID 0x1E, // Command text "setyaw", // Type of the command data floatType, // Function pointer &cb_setyaw }, // pitch setpoint subtype { // ID 0x1F, // Command text "setpitch", // Type of the command data floatType, // Function pointer &cb_setpitch }, // roll setpoint subtype { // ID 0x20, // Command text "setroll", // Type of the command data floatType, // Function pointer &cb_setroll } } }, // REQUEST { // Message Type ID 0x02, // Calibration Subtypes (PID coefficients) { // yaw p constant subtype { // ID 0x00, // Command text "getyawp", // Type of the command data floatType, // Function pointer &cb_getyawp }, // yaw i constant subtype { // ID 0x01, // Command text "getyawi", // Type of the command data floatType, // Function pointer &cb_getyawi }, // yaw d constant subtype { // ID 0x02, // Command text "getyawd", // Type of the command data floatType, // Function pointer &cb_getyawd }, // roll p constant subtype { // ID 0x03, // Command text "getrollp", // Type of the command data floatType, // Function pointer &cb_getrollp }, // roll i constant subtype { // ID 0x04, // Command text "getrolli", // Type of the command data floatType, // Function pointer &cb_getrolli }, // roll d constant subtype { // ID 0x05, // Command text "getrolld", // Type of the command data floatType, // Function pointer &cb_getrolld }, // pitch p constant subtype { // ID 0x06, // Command text "getpitchp", // Type of the command data floatType, // Function pointer &cb_getpitchp }, // pitch i constant subtype { // ID 0x07, // Command text "getpitchi", // Type of the command data floatType, // Function pointer &cb_getpitchi }, // pitch d constant subtype { // ID 0x08, // Command text "getpitchd", // Type of the command data floatType, // Function pointer &cb_getpitchd }, // yawrate p constant subtype { // ID 0x09, // Command text "getyawratep", // Type of the command data floatType, // Function pointer &cb_getyawratep }, // yawrate i constant subtype { // ID 0x0A, // Command text "getyawratei", // Type of the command data floatType, // Function pointer &cb_getyawratei }, // yawrate d constant subtype { // ID 0x0B, // Command text "getyawrated", // Type of the command data floatType, // Function pointer &cb_getyawrated }, // rollrate p constant subtype { // ID 0x0C, // Command text "getrollratep", // Type of the command data floatType, // Function pointer &cb_getrollratep }, // rollrate i constant subtype { // ID 0x0D, // Command text "getrollratei", // Type of the command data floatType, // Function pointer &cb_getrollratei }, // rollrate d constant subtype { // ID 0x0E, // Command text "getrollrated", // Type of the command data floatType, // Function pointer &cb_getrollrated }, // pitchrate p constant subtype { // ID 0x0F, // Command text "getpitchratep", // Type of the command data floatType, // Function pointer &cb_getpitchratep }, // pitchrate i constant subtype { // ID 0x10, // Command text "getpitchratei", // Type of the command data floatType, // Function pointer &cb_getpitchratei }, // pitchrate d constant subtype { // ID 0x11, // Command text "getpitchrated", // Type of the command data floatType, // Function pointer &cb_getpitchrated }, // height p constant subtype { // ID 0x12, // Command text "getheightp", // Type of the command data floatType, // Function pointer &cb_getheightp }, // height i constant subtype { // ID 0x13, // Command text "getheighti", // Type of the command data floatType, // Function pointer &cb_getheighti }, // height d constant subtype { // ID 0x14, // Command text "getheightd", // Type of the command data floatType, // Function pointer &cb_getheightd }, // x p constant subtype { // ID 0x15, // Command text "getxp", // Type of the command data floatType, // Function pointer &cb_getxp }, // x i constant subtype { // ID 0x16, // Command text "getxi", // Type of the command data floatType, // Function pointer &cb_getxi }, // x d constant subtype { // ID 0x17, // Command text "getxd", // Type of the command data floatType, // Function pointer &cb_getxd }, // y p constant subtype { // ID 0x18, // Command text "getyp", // Type of the command data floatType, // Function pointer &cb_getyp }, // y i constant subtype { // ID 0x19, // Command text "getyi", // Type of the command data floatType, // Function pointer &cb_getyi }, // y d constant subtype { // ID 0x1A, // Command text "getyd", // Type of the command data floatType, // Function pointer &cb_getyd }, // height setpoint subtype { // ID 0x1B, // Command text "getheight", // Type of the command data floatType, // Function pointer &cb_getheight }, // x getpoint subtype { // ID 0x1C, // Command text "getx", // Type of the command data floatType, // Function pointer &cb_getx }, // y getpoint subtype { // ID 0x1D, // Command text "gety", // Type of the command data floatType, // Function pointer &cb_gety }, // yaw getpoint subtype { // ID 0x1E, // Command text "getyaw", // Type of the command data floatType, // Function pointer &cb_getyaw }, // pitch getpoint subtype { // ID 0x1F, // Command text "getpitch", // Type of the command data floatType, // Function pointer &cb_getpitch }, // roll getpoint subtype { // ID 0x20, // Command text "getroll", // Type of the command data floatType, // Function pointer &cb_getroll } } }, // RESPONSE { // Message Type ID 0x03, // Calibration Subtypes (PID coefficients) { // yaw p constant subtype { // ID 0x00, // Command text "respyawp", // Type of the command data floatType, // Function pointer &cb_respyawp }, // yaw i constant subtype { // ID 0x01, // Command text "respyawi", // Type of the command data floatType, // Function pointer &cb_respyawi }, // yaw d constant subtype { // ID 0x02, // Command text "respyawd", // Type of the command data floatType, // Function pointer &cb_respyawd }, // roll p constant subtype { // ID 0x03, // Command text "resprollp", // Type of the command data floatType, // Function pointer &cb_resprollp }, // roll i constant subtype { // ID 0x04, // Command text "resprolli", // Type of the command data floatType, // Function pointer &cb_resprolli }, // roll d constant subtype { // ID 0x05, // Command text "resprolld", // Type of the command data floatType, // Function pointer &cb_resprolld }, // pitch p constant subtype { // ID 0x06, // Command text "resppitchp", // Type of the command data floatType, // Function pointer &cb_resppitchp }, // pitch i constant subtype { // ID 0x07, // Command text "resppitchi", // Type of the command data floatType, // Function pointer &cb_resppitchi }, // pitch d constant subtype { // ID 0x08, // Command text "resppitchd", // Type of the command data floatType, // Function pointer &cb_resppitchd }, // yawrate p constant subtype { // ID 0x09, // Command text "respyawratep", // Type of the command data floatType, // Function pointer &cb_respyawratep }, // yawrate i constant subtype { // ID 0x0A, // Command text "respyawratei", // Type of the command data floatType, // Function pointer &cb_respyawratei }, // yawrate d constant subtype { // ID 0x0B, // Command text "respyawrated", // Type of the command data floatType, // Function pointer &cb_respyawrated }, // rollrate p constant subtype { // ID 0x0C, // Command text "resprollratep", // Type of the command data floatType, // Function pointer &cb_resprollratep }, // rollrate i constant subtype { // ID 0x0D, // Command text "resprollratei", // Type of the command data floatType, // Function pointer &cb_resprollratei }, // rollrate d constant subtype { // ID 0x0E, // Command text "resprollrated", // Type of the command data floatType, // Function pointer &cb_resprollrated }, // pitchrate p constant subtype { // ID 0x0F, // Command text "resppitchratep", // Type of the command data floatType, // Function pointer &cb_resppitchratep }, // pitchrate i constant subtype { // ID 0x10, // Command text "resppitchratei", // Type of the command data floatType, // Function pointer &cb_resppitchratei }, // pitchrate d constant subtype { // ID 0x11, // Command text "resppitchrated", // Type of the command data floatType, // Function pointer &cb_resppitchrated }, // height p constant subtype { // ID 0x12, // Command text "respheightp", // Type of the command data floatType, // Function pointer &cb_respheightp }, // height i constant subtype { // ID 0x13, // Command text "respheighti", // Type of the command data floatType, // Function pointer &cb_respheighti }, // height d constant subtype { // ID 0x14, // Command text "respheightd", // Type of the command data floatType, // Function pointer &cb_respheightd }, // x p constant subtype { // ID 0x15, // Command text "respxp", // Type of the command data floatType, // Function pointer &cb_respxp }, // x i constant subtype { // ID 0x16, // Command text "respxi", // Type of the command data floatType, // Function pointer &cb_respxi }, // x d constant subtype { // ID 0x17, // Command text "respxd", // Type of the command data floatType, // Function pointer &cb_respxd }, // y p constant subtype { // ID 0x18, // Command text "respyp", // Type of the command data floatType, // Function pointer &cb_respyp }, // y i constant subtype { // ID 0x19, // Command text "respyi", // Type of the command data floatType, // Function pointer &cb_respyi }, // y d constant subtype { // ID 0x1A, // Command text "respyd", // Type of the command data floatType, // Function pointer &cb_respyd }, // height setpoint subtype { // ID 0x1B, // Command text "respheight", // Type of the command data floatType, // Function pointer &cb_respheight }, // x resppoint subtype { // ID 0x1C, // Command text "respx", // Type of the command data floatType, // Function pointer &cb_respx }, // y resppoint subtype { // ID 0x1D, // Command text "respy", // Type of the command data floatType, // Function pointer &cb_respy }, // yaw resppoint subtype { // ID 0x1E, // Command text "respyaw", // Type of the command data floatType, // Function pointer &cb_respyaw }, // pitch resppoint subtype { // ID 0x1F, // Command text "resppitch", // Type of the command data floatType, // Function pointer &cb_resppitch }, // roll resppoint subtype { // ID 0x20, // Command text "resproll", // Type of the command data floatType, // Function pointer &cb_resproll } } }, // UPDATE { // Message Type ID 0x04, // Update Subtypes { // NONE subtype { // ID 0x00, // Command text "update", // Type of the command data stringType, // Function pointer &cb_update }, // BEGIN update { // ID 0x01, // Command text "beginupdate", // Type of the command data stringType, // Function pointer &cb_beginupdate } } }, // LOG { // Message Type ID 0x05, // Log Subtypes { // NONE subtype { // ID 0x00, // Command text "log", // Type of the command data stringType, // Function pointer &cb_log }, // Response subtype { // ID 0x01, // Command text "response", // Type of the command data stringType, // Function pointer &cb_response } } }, };