diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-02 19:14:08 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-02 19:14:08 +0200 |
commit | 595763efb64ee861f3ccf458ff35992b94f2fa3a (patch) | |
tree | 428ae0f7b474b8cb644fadcb4491ed7d8e4baffa /robot/errcatch.c | |
parent | 14779cb187dac9ed4a0b6e7645e76e78587ad024 (diff) |
[WIP] stop on connection lost in dirc
Diffstat (limited to 'robot/errcatch.c')
-rw-r--r-- | robot/errcatch.c | 10 |
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; |