Skip to content

Commit 5e817dc

Browse files
Added command response to ARM and Execute
1 parent 98b9156 commit 5e817dc

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

interfaces/obc_gs_interface/commands/command_response_callbacks.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ def parse_cmd_arm(cmd_response: CmdRes, data: bytes) -> CmdArmRes:
8585
if cmd_response.cmd_id != CmdCallbackId.CMD_ARM:
8686
raise ValueError("Wrong command id for parsing the name command")
8787

88+
cmd_arm = int.from_bytes(data[0:3], "little")
89+
cmd_arm_id = int.from_bytes(data[4:8], "little")
90+
8891
return CmdArmRes(
8992
cmd_response.cmd_id,
9093
cmd_response.error_code,
9194
cmd_response.response_length,
92-
cmd_response.cmd_arm,
93-
cmd_response.cmd_arm_id,
95+
cmd_arm,
96+
cmd_arm_id,
9497
)
9598

9699

@@ -104,12 +107,15 @@ def parse_cmd_execute(cmd_response: CmdRes, data: bytes) -> CmdExecuteRes:
104107
if cmd_response.cmd_id != CmdCallbackId.CMD_EXECUTE:
105108
raise ValueError("Wrong command id for parsing the name command")
106109

110+
cmd_execute = int.from_bytes(data[0:3], "little")
111+
cmd_exec_id = int.from_bytes(data[4:8], "little")
112+
107113
return CmdExecuteRes(
108114
cmd_response.cmd_id,
109115
cmd_response.error_code,
110116
cmd_response.response_length,
111-
cmd_response.cmd_execute,
112-
cmd_response.cmd_exec_id,
117+
cmd_execute,
118+
cmd_exec_id,
113119
)
114120

115121

obc/app/modules/command_mgr/command_callbacks.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,46 @@ static obc_error_code_t I2CProbeCmdCallback(cmd_msg_t *cmd, uint8_t *responseDat
116116
return OBC_ERR_CODE_SUCCESS;
117117
}
118118

119-
static obc_error_code_t cmdArmCmdCallback(cmd_msg_t *cmd, uint8_t *responseData, uint8_t *responseDataLen) {
119+
static obc_error_code_t armCmdCallback(cmd_msg_t *cmd, uint8_t *responseData, uint8_t *responseDataLen) {
120120
if (cmd == NULL || responseData == NULL || responseDataLen == NULL) {
121121
return OBC_ERR_CODE_INVALID_ARG;
122122
}
123+
// Parsing the cmdArm data into bytes
124+
responseData[0] = cmd->cmdArm.cmdArm;
125+
responseData[1] = cmd->cmdArm.cmdArm >> 8;
126+
responseData[2] = cmd->cmdArm.cmdArm >> 16;
127+
responseData[3] = cmd->cmdArm.cmdArm >> 24;
128+
129+
// Parsing the armId data into bytes
130+
responseData[4] = cmd->cmdArm.armId;
131+
responseData[5] = cmd->cmdArm.armId >> 8;
132+
responseData[6] = cmd->cmdArm.armId >> 16;
133+
responseData[7] = cmd->cmdArm.armId >> 24;
134+
135+
*responseDataLen = 8;
123136

124137
return OBC_ERR_CODE_SUCCESS;
125138
}
126139

127-
static obc_error_code_t cmdExecuteCmdCallback(cmd_msg_t *cmd, uint8_t *responseData, uint8_t *responseDataLen) {
140+
static obc_error_code_t executeCmdCallback(cmd_msg_t *cmd, uint8_t *responseData, uint8_t *responseDataLen) {
128141
if (cmd == NULL || responseData == NULL || responseDataLen == NULL) {
129142
return OBC_ERR_CODE_INVALID_ARG;
130143
}
131144

145+
// Parsing the cmdExecute data into bytes
146+
responseData[0] = cmd->cmdExecute.cmdExecute;
147+
responseData[1] = cmd->cmdExecute.cmdExecute >> 8;
148+
responseData[2] = cmd->cmdExecute.cmdExecute >> 16;
149+
responseData[3] = cmd->cmdExecute.cmdExecute >> 24;
150+
151+
// Parsing the execId data into bytes
152+
responseData[4] = cmd->cmdExecute.execId;
153+
responseData[5] = cmd->cmdExecute.execId >> 8;
154+
responseData[6] = cmd->cmdExecute.execId >> 16;
155+
responseData[7] = cmd->cmdExecute.execId >> 24;
156+
157+
*responseDataLen = 8;
158+
132159
return OBC_ERR_CODE_SUCCESS;
133160
}
134161

@@ -142,8 +169,8 @@ const cmd_info_t cmdsConfig[] = {
142169
[CMD_PING] = {pingCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
143170
[CMD_DOWNLINK_TELEM] = {downlinkTelemCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
144171
[CMD_I2C_PROBE] = {I2CProbeCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
145-
[CMD_ARM] = {cmdArmCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
146-
[CMD_EXECUTE] = {cmdExecuteCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
172+
[CMD_ARM] = {armCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
173+
[CMD_EXECUTE] = {executeCmdCallback, CMD_POLICY_PROD, CMD_TYPE_NORMAL},
147174
};
148175

149176
// This function is purely to trick the compiler into thinking we are using the cmdsConfig variable so we avoid the

0 commit comments

Comments
 (0)