summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/setup.c2
-rw-r--r--client/strings.c56
-rw-r--r--client/ui_errcatch.c21
-rw-r--r--robot/setup.c3
4 files changed, 49 insertions, 33 deletions
diff --git a/client/setup.c b/client/setup.c
index 0f2b0f7..e51965f 100644
--- a/client/setup.c
+++ b/client/setup.c
@@ -10,8 +10,6 @@
#include "strings.h"
#include "ui.h"
-#include "errcatch.h"
-
// pointers for endianness check
static const uint16_t _test = 1;
static const uint8_t *_ptest = (uint8_t *)&_test;
diff --git a/client/strings.c b/client/strings.c
index c89cbbf..0ab260e 100644
--- a/client/strings.c
+++ b/client/strings.c
@@ -1,5 +1,5 @@
-#include "../shared/errcatch.h"
#include "strings.h"
+#include "../shared/errcatch.h"
char *g_w2_mode_strings[W2_MODE_COUNT];
char *g_w2_tab_strings[W2_UI_TAB_COUNT];
@@ -32,39 +32,53 @@ void w2_strings_errors_types() {
void w2_strings_errors_internal() {
g_w2_error_internal_strings[W2_E_CRIT_CONN_LOST] = W2_UI_ERROR_INT_W2_E_CRIT_CONN_LOST;
- g_w2_error_internal_strings[W2_E_CRIT_COM_UNAVAILABLE] = W2_UI_ERROR_INT_W2_E_CRIT_COM_UNAVAILABLE;
+ g_w2_error_internal_strings[W2_E_CRIT_COM_UNAVAILABLE] =
+ W2_UI_ERROR_INT_W2_E_CRIT_COM_UNAVAILABLE;
g_w2_error_internal_strings[W2_E_CRIT_LINE_LOST] = W2_UI_ERROR_INT_W2_E_CRIT_LINE_LOST;
- g_w2_error_internal_strings[W2_E_CRIT_OBSTACLE_STUCK] = W2_UI_ERROR_INT_W2_E_CRIT_OBSTACLE_STUCK;
- g_w2_error_internal_strings[W2_E_CRIT_VERSION_INCOMPATIBLE] = W2_UI_ERROR_INT_W2_E_CRIT_VERSION_INCOMPATIBLE;
+ g_w2_error_internal_strings[W2_E_CRIT_OBSTACLE_STUCK] =
+ W2_UI_ERROR_INT_W2_E_CRIT_OBSTACLE_STUCK;
+ g_w2_error_internal_strings[W2_E_CRIT_VERSION_INCOMPATIBLE] =
+ W2_UI_ERROR_INT_W2_E_CRIT_VERSION_INCOMPATIBLE;
g_w2_error_internal_strings[W2_E_WARN_BATTERY_LOW] = W2_UI_ERROR_INT_W2_E_WARN_BATTERY_LOW;
- g_w2_error_internal_strings[W2_E_WARN_OBSTACLE_DETECTED] = W2_UI_ERROR_INT_W2_E_WARN_OBSTACLE_DETECTED;
+ g_w2_error_internal_strings[W2_E_WARN_OBSTACLE_DETECTED] =
+ W2_UI_ERROR_INT_W2_E_WARN_OBSTACLE_DETECTED;
g_w2_error_internal_strings[W2_E_WARN_CYCLE_EXPIRED] = W2_UI_ERROR_INT_W2_E_WARN_CYCLE_EXPIRED;
- g_w2_error_internal_strings[W2_E_WARN_UNCAUGHT_ERROR] = W2_UI_ERROR_INT_W2_E_WARN_UNCAUGHT_ERROR;
- g_w2_error_internal_strings[W2_E_WARN_ERR_BUFFER_FULL] = W2_UI_ERROR_INT_W2_E_WARN_ERR_BUFFER_FULL;
+ g_w2_error_internal_strings[W2_E_WARN_UNCAUGHT_ERROR] =
+ W2_UI_ERROR_INT_W2_E_WARN_UNCAUGHT_ERROR;
+ g_w2_error_internal_strings[W2_E_WARN_ERR_BUFFER_FULL] =
+ W2_UI_ERROR_INT_W2_E_WARN_ERR_BUFFER_FULL;
g_w2_error_internal_strings[W2_E_WARN_LINE_LOST] = W2_UI_ERROR_INT_W2_E_WARN_LINE_LOST;
- g_w2_error_internal_strings[W2_E_WARN_SERCOMM_BUFFER_FULL] = W2_UI_ERROR_INT_W2_E_WARN_SERCOMM_BUFFER_FULL;
- g_w2_error_internal_strings[W2_E_WARN_VERSION_INCOMPATIBLE] = W2_UI_ERROR_INT_W2_E_WARN_VERSION_INCOMPATIBLE;
+ g_w2_error_internal_strings[W2_E_WARN_SERCOMM_BUFFER_FULL] =
+ W2_UI_ERROR_INT_W2_E_WARN_SERCOMM_BUFFER_FULL;
+ g_w2_error_internal_strings[W2_E_WARN_VERSION_INCOMPATIBLE] =
+ W2_UI_ERROR_INT_W2_E_WARN_VERSION_INCOMPATIBLE;
g_w2_error_internal_strings[W2_E_WARN_SERIAL_NOISY] = W2_UI_ERROR_INT_W2_E_WARN_SERIAL_NOISY;
- g_w2_error_internal_strings[W2_E_WARN_MODE_HISTORY_BUFFER_IOB] = W2_UI_ERROR_INT_W2_E_WARN_MODE_HISTORY_BUFFER_IOB;
+ g_w2_error_internal_strings[W2_E_WARN_MODE_HISTORY_BUFFER_IOB] =
+ W2_UI_ERROR_INT_W2_E_WARN_MODE_HISTORY_BUFFER_IOB;
g_w2_error_internal_strings[W2_E_WARN_PING_TIMEOUT] = W2_UI_ERROR_INT_W2_E_WARN_PING_TIMEOUT;
}
void w2_strings_errors_user() {
- g_w2_error_user_strings[W2_E_CRIT_CONN_LOST] = W2_UI_ERROR_USR_W2_E_CRIT_CONN_LOST;
+ g_w2_error_user_strings[W2_E_CRIT_CONN_LOST] = W2_UI_ERROR_USR_W2_E_CRIT_CONN_LOST;
g_w2_error_user_strings[W2_E_CRIT_COM_UNAVAILABLE] = W2_UI_ERROR_USR_W2_E_CRIT_COM_UNAVAILABLE;
- g_w2_error_user_strings[W2_E_CRIT_LINE_LOST] = W2_UI_ERROR_USR_W2_E_CRIT_LINE_LOST;
- g_w2_error_user_strings[W2_E_CRIT_OBSTACLE_STUCK] = W2_UI_ERROR_USR_W2_E_CRIT_OBSTACLE_STUCK;
- g_w2_error_user_strings[W2_E_CRIT_VERSION_INCOMPATIBLE] = W2_UI_ERROR_USR_W2_E_CRIT_VERSION_INCOMPATIBLE;
+ g_w2_error_user_strings[W2_E_CRIT_LINE_LOST] = W2_UI_ERROR_USR_W2_E_CRIT_LINE_LOST;
+ g_w2_error_user_strings[W2_E_CRIT_OBSTACLE_STUCK] = W2_UI_ERROR_USR_W2_E_CRIT_OBSTACLE_STUCK;
+ g_w2_error_user_strings[W2_E_CRIT_VERSION_INCOMPATIBLE] =
+ W2_UI_ERROR_USR_W2_E_CRIT_VERSION_INCOMPATIBLE;
g_w2_error_user_strings[W2_E_WARN_BATTERY_LOW] = W2_UI_ERROR_USR_W2_E_WARN_BATTERY_LOW;
- g_w2_error_user_strings[W2_E_WARN_OBSTACLE_DETECTED] = W2_UI_ERROR_USR_W2_E_WARN_OBSTACLE_DETECTED;
- g_w2_error_user_strings[W2_E_WARN_CYCLE_EXPIRED] = W2_UI_ERROR_USR_W2_E_WARN_CYCLE_EXPIRED;
- g_w2_error_user_strings[W2_E_WARN_UNCAUGHT_ERROR] = W2_UI_ERROR_USR_W2_E_WARN_UNCAUGHT_ERROR;
+ g_w2_error_user_strings[W2_E_WARN_OBSTACLE_DETECTED] =
+ W2_UI_ERROR_USR_W2_E_WARN_OBSTACLE_DETECTED;
+ g_w2_error_user_strings[W2_E_WARN_CYCLE_EXPIRED] = W2_UI_ERROR_USR_W2_E_WARN_CYCLE_EXPIRED;
+ g_w2_error_user_strings[W2_E_WARN_UNCAUGHT_ERROR] = W2_UI_ERROR_USR_W2_E_WARN_UNCAUGHT_ERROR;
g_w2_error_user_strings[W2_E_WARN_ERR_BUFFER_FULL] = W2_UI_ERROR_USR_W2_E_WARN_ERR_BUFFER_FULL;
- g_w2_error_user_strings[W2_E_WARN_LINE_LOST] = W2_UI_ERROR_USR_W2_E_WARN_LINE_LOST;
- g_w2_error_user_strings[W2_E_WARN_SERCOMM_BUFFER_FULL] = W2_UI_ERROR_USR_W2_E_WARN_SERCOMM_BUFFER_FULL;
- g_w2_error_user_strings[W2_E_WARN_VERSION_INCOMPATIBLE] = W2_UI_ERROR_USR_W2_E_WARN_VERSION_INCOMPATIBLE;
+ g_w2_error_user_strings[W2_E_WARN_LINE_LOST] = W2_UI_ERROR_USR_W2_E_WARN_LINE_LOST;
+ g_w2_error_user_strings[W2_E_WARN_SERCOMM_BUFFER_FULL] =
+ W2_UI_ERROR_USR_W2_E_WARN_SERCOMM_BUFFER_FULL;
+ g_w2_error_user_strings[W2_E_WARN_VERSION_INCOMPATIBLE] =
+ W2_UI_ERROR_USR_W2_E_WARN_VERSION_INCOMPATIBLE;
g_w2_error_user_strings[W2_E_WARN_SERIAL_NOISY] = W2_UI_ERROR_USR_W2_E_WARN_SERIAL_NOISY;
- g_w2_error_user_strings[W2_E_WARN_MODE_HISTORY_BUFFER_IOB] = W2_UI_ERROR_USR_W2_E_WARN_MODE_HISTORY_BUFFER_IOB;
+ g_w2_error_user_strings[W2_E_WARN_MODE_HISTORY_BUFFER_IOB] =
+ W2_UI_ERROR_USR_W2_E_WARN_MODE_HISTORY_BUFFER_IOB;
g_w2_error_user_strings[W2_E_WARN_PING_TIMEOUT] = W2_UI_ERROR_USR_W2_E_WARN_PING_TIMEOUT;
}
diff --git a/client/ui_errcatch.c b/client/ui_errcatch.c
index e1fd71b..abfbe22 100644
--- a/client/ui_errcatch.c
+++ b/client/ui_errcatch.c
@@ -1,14 +1,14 @@
#include <stdlib.h>
#include <string.h>
+#include "errcatch.h"
#include "i18n.h"
#include "strings.h"
-#include "errcatch.h"
#include "ui.h"
unsigned int g_w2_errcatch_log_line = 0;
-unsigned int w2_newline_count(char* str, unsigned int len) {
+unsigned int w2_newline_count(char *str, unsigned int len) {
unsigned int newlines = 0;
for (unsigned int i = 0; i < len; i++)
if (str[i] == '\n') newlines++;
@@ -16,26 +16,27 @@ unsigned int w2_newline_count(char* str, unsigned int len) {
}
char *w2_err_format(w2_s_error *error) {
- const char* type = g_w2_error_type_strings[error->code >> 6];
- const char* internal = g_w2_error_internal_strings[error->code];
- const char* user = g_w2_error_user_strings[error->code];
+ const char *type = g_w2_error_type_strings[error->code >> 6];
+ const char *internal = g_w2_error_internal_strings[error->code];
+ const char *user = g_w2_error_user_strings[error->code];
if (internal == NULL || user == NULL) {
internal = W2_UI_ERROR_INT_W2_E_UNKNOWN;
- user = W2_UI_ERROR_USR_W2_E_UNKNOWN;
+ user = W2_UI_ERROR_USR_W2_E_UNKNOWN;
}
size_t errdesc_len = strlen(type) + strlen(internal) + strlen(user) + 8;
- size_t msg_indent = strlen(type) + 3;
- char *ret_str = malloc(errdesc_len + (error->message_length > 0 ? error->message_length + msg_indent : 0) + 1);
+ size_t msg_indent = strlen(type) + 3;
+ char *ret_str = malloc(
+ errdesc_len + (error->message_length > 0 ? error->message_length + msg_indent : 0) + 1);
sprintf(ret_str, "[%s] %02x#%s: %s", type, error->code, internal, user);
if (error->message_length > 0) {
- sprintf(ret_str + errdesc_len, "\n%*c%s", (int) msg_indent, ' ', error->message);
+ sprintf(ret_str + errdesc_len, "\n%*c%s", (int)msg_indent, ' ', error->message);
g_w2_errcatch_log_line += 1 + w2_newline_count(error->message, error->message_length);
}
return ret_str;
}
void w2_ui_tab_errcatch(bool first) {
- g_w2_errcatch_log_line = 0;
+ g_w2_errcatch_log_line = 0;
g_w2_ui_pad_body_scroll = 5 - g_w2_ui_height;
for (unsigned int x = 0; x < W2_ERRCATCH_LOG_SIZE; x++) {
unsigned int i = (x + g_w2_error_log_index) % W2_ERRCATCH_LOG_SIZE;
diff --git a/robot/setup.c b/robot/setup.c
index 4706d64..dfd88bd 100644
--- a/robot/setup.c
+++ b/robot/setup.c
@@ -34,6 +34,9 @@ void w2_setup_main() {
w2_modes_swap(W2_M_MAZE);
w2_modes_call(W2_M_HALT);
+ // send info
+ w2_cmd_info_rx(NULL);
+
// indicate startup done
play("L50 c>c");
}