Skip to content
Snippets Groups Projects
Commit 6e70e527 authored by dawehr's avatar dawehr
Browse files

Fixed compile errors.

parent 0008bdfc
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ struct graph_tuple { // Tuple for ...@@ -29,7 +29,7 @@ struct graph_tuple { // Tuple for
struct str { struct str {
char* str; char* str;
int size; size_t size;
size_t capacity; size_t capacity;
}; };
...@@ -43,34 +43,34 @@ int row_size; ...@@ -43,34 +43,34 @@ int row_size;
static char units_output_str[512] = {}; static char units_output_str[512] = {};
static char units_param_str[512] = {}; static char units_param_str[512] = {};
static struct str units_output { .str = units_output_str, .size = 0, .capacity = sizeof(units_output_str)}; static struct str units_output = { .str = units_output_str, .size = 0, .capacity = sizeof(units_output_str)};
static struct str units_param { .str = units_param_str, .size = 0 .capacity = sizeof(units_output_str)}; static struct str units_param = { .str = units_param_str, .size = 0, .capacity = sizeof(units_output_str)};
void safe_strcat(struct str, char* to_add) { void safe_strcat(struct str str, char* to_add) {
size_t add_len = strlen(to_add); size_t add_len = strlen(to_add);
if (add_len + str.size <= str.capacity) { if (add_len + str.size <= str.capacity) {
strcpy(&(str.str[str.size]), to_add); strcpy(&(str.str[str.size]), to_add);
str.size += to_add; str.size += add_len;
} }
} }
void addOutputToLog(log_t* log_struct, int controller_id, int output_id, char* units) { void addOutputToLog(log_t* log_struct, int controller_id, int output_id, char* units) {
static units_buf[64]; static char units_buf[64];
if (n_outputs < MAX_LOG_NUM) { if (n_outputs < MAX_LOG_NUM) {
log_outputs[n_outputs].block_id = controller_id; log_outputs[n_outputs].block_id = controller_id;
log_outputs[n_outputs].sub_id = output_id; log_outputs[n_outputs].sub_id = output_id;
n_outputs++; n_outputs++;
snprintf(units_buf, sizeof(units_buf) "\t%s", units); snprintf(units_buf, sizeof(units_buf), "\t%s", units);
safe_strcat(units_output, units_buf); safe_strcat(units_output, units_buf);
} }
} }
void addParamToLog(log_t* log_struct, int controller_id, int param_id, char* units) { void addParamToLog(log_t* log_struct, int controller_id, int param_id, char* units) {
static units_buf[64]; static char units_buf[64];
if (n_params < MAX_LOG_NUM) { if (n_params < MAX_LOG_NUM) {
log_params[n_params].block_id = controller_id; log_params[n_params].block_id = controller_id;
log_params[n_params].sub_id = param_id; log_params[n_params].sub_id = param_id;
n_params++; n_params++;
snprintf(units_buf, sizeof(units_buf) "\t%s", units); snprintf(units_buf, sizeof(units_buf), "\t%s", units);
safe_strcat(units_param, units_buf); safe_strcat(units_param, units_buf);
} }
} }
...@@ -167,7 +167,7 @@ void printLogging(hardware_t *hardware_struct, log_t* log_struct, parameter_t* p ...@@ -167,7 +167,7 @@ void printLogging(hardware_t *hardware_struct, log_t* log_struct, parameter_t* p
// Let user know that allocation failed // Let user know that allocation failed
if (arraySize != LOG_STARTING_SIZE) { if (arraySize != LOG_STARTING_SIZE) {
size_t send_len = sprintf(header1, "Failed to allocate enough log memory\n"); size_t send_len = sprintf(header1, "Failed to allocate enough log memory\n");
send_data(hardware_struct, LOG_ID, 0, header1, send_len); send_data(&hardware_struct->uart, LOG_ID, 0, header1, send_len);
return; return;
} }
......
...@@ -18,12 +18,12 @@ void initialize_logging(log_t* log_struct, parameter_t* ps); ...@@ -18,12 +18,12 @@ void initialize_logging(log_t* log_struct, parameter_t* ps);
/** /**
* Adds the given block output to the data to be logged * Adds the given block output to the data to be logged
*/ */
void addOutputToLog(log_t* log_struct, int controller_id, int output_id); void addOutputToLog(log_t* log_struct, int controller_id, int output_id, char* units);
/** /**
* Adds the given block parameter to the data to be logged * Adds the given block parameter to the data to be logged
*/ */
void addParamToLog(log_t* log_struct, int controller_id, int param_id); void addParamToLog(log_t* log_struct, int controller_id, int param_id, char* units);
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment