aboutsummaryrefslogtreecommitdiff
path: root/robot/errcatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'robot/errcatch.c')
-rw-r--r--robot/errcatch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/robot/errcatch.c b/robot/errcatch.c
index 0f809f9..77fcfd3 100644
--- a/robot/errcatch.c
+++ b/robot/errcatch.c
@@ -19,21 +19,21 @@ void w2_errcatch_handle_error(w2_s_error *error) {
default: {
g_w2_error_uncaught = true;
#ifdef W2_SIM
- simwarn("Uncaught/unhandled error found with code 0x%02x\n", error->code);
+ simwarn("Uncaught/unhandled error found with code 0x%02x", error->code);
+ if (error->message_length > 0) fprintf(stderr, " and message \"%.*s\"", error->message_length, error->message);
+ fprintf(stderr, "\n");
#endif
}
}
// forward error to sercomm
- size_t msg_size = sizeof(w2_s_cmd_expt_tx) + sizeof(uint8_t) * error->message_length;
- w2_s_cmd_expt_tx *msg = malloc(msg_size);
+ W2_CREATE_MSG_SIZE_BIN(w2_s_cmd_expt_tx, sizeof(w2_s_cmd_expt_tx) + sizeof(uint8_t) * error->message_length, msg, msg_bin);
msg->opcode = W2_CMD_EXPT | W2_CMDDIR_TX;
msg->error = error->code;
msg->length = error->message_length;
memcpy(msg->message, error->message, error->message_length);
- w2_s_bin *msg_bin = w2_bin_s_alloc(msg_size, (uint8_t *)msg);
+
w2_sercomm_append_msg(msg_bin);
- free(msg);
free(msg_bin);
return;