Sternum Linux SDK
sternum_trace_api.h
Go to the documentation of this file.
1 
8 #ifndef __STERNUM_TRACE_API_H__
9 #define __STERNUM_TRACE_API_H__
10 
11 #ifdef __cplusplus
12  extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include <stdbool.h>
17 #include <stdlib.h>
18 
19 #include "trace_protocol_user_definition.h"
20 #include "error_codes.h"
21 #include "device_type.h"
22 
23 
97 #define STERNUM_ADS_TRACE(TRACE, ...) sternum_trace_dynamic(TRACE, ## __VA_ARGS__, END_OF_ARGUMENTS)
122 #define STERNUM_ADS_TRACEF(TRACE, ARG_ROLE, MAX_LENGTH, FORMAT, ...) sternum_trace_string_format(TRACE, ARG_ROLE, MAX_LENGTH, FORMAT, ## __VA_ARGS__)
123 
124 
125 #define END_OF_ARGUMENTS 0
126 #define POINTER_DEREFERENCE_INDICATOR 0x8000
127 #define UNSIGNED_INTEGER_TYPE 0
128 #define SIGNED_INTEGER_TYPE 1
129 #define FLOAT_TYPE 2
130 #define POINTER_TYPE 3
131 #define BLOB_TYPE (4 | POINTER_DEREFERENCE_INDICATOR)
132 #define STRING_TYPE (5 | POINTER_DEREFERENCE_INDICATOR)
133 
134 #define ARGUMENT_STRING(ARG_ROLE, MAX_SIZE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)STRING_TYPE, (unsigned int)MAX_SIZE, (char*)(ARG_VALUE)
135 #define ARGUMENT_BLOB(ARG_ROLE, SIZE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)BLOB_TYPE, (unsigned int)SIZE, (uint8_t*)(ARG_VALUE)
136 #define ARGUMENT_INTEGER(ARG_ROLE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)SIGNED_INTEGER_TYPE, (unsigned int)sizeof(ARG_VALUE), (ARG_VALUE)
137 #define ARGUMENT_UINTEGER(ARG_ROLE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)UNSIGNED_INTEGER_TYPE, (unsigned int)sizeof(ARG_VALUE), (ARG_VALUE)
138 #define ARGUMENT_POINTER(ARG_ROLE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)POINTER_TYPE, (unsigned int)sizeof(ARG_VALUE), (ARG_VALUE)
139 #define ARGUMENT_FLOAT(ARG_ROLE, ARG_VALUE) (unsigned int)ARG_ROLE, (unsigned int)FLOAT_TYPE, (unsigned int)sizeof(ARG_VALUE), (ARG_VALUE)
140 
141 sternum_code_t sternum_trace_dynamic(int trace_event_type, ...);
142 sternum_code_t sternum_trace_string_format(uint16_t trace_event_type, uint16_t argument_role_type, uint16_t max_length, const char* format, ...);
143 
144 /***********************************************************************************************
145  * Predefined traces definitions
146  **********************************************************************************************/
147 
154 void trace_battery_health(unsigned int capacity_percent, unsigned int voltage_mV);
155 
164 void trace_error(unsigned int error_code, const char* message, const char* file_name, unsigned int line);
165 
176 #define STERNUM_ADS_TRACE_ERROR(error_code, message) trace_error(error_code, message, __FILE__, __LINE__)
177 
187 void trace_firmware_update_start(const char* firmware_version, const char* firmware_hash, const char* hash_algorithm);
188 
195 
201 void trace_reboot_reason(const char* reboot_reason);
202 
209 void trace_signal_strength_report(unsigned int communication_type, int signal_strength);
210 
238 void upload_text_file(const char* path, size_t fseek_offset, size_t max_size);
239 
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif /* __STERNUM_TRACE_API_H__ */
int sternum_code_t
Definition: error_codes.h:11
sternum_code_t sternum_trace_dynamic(int trace_event_type,...)
void trace_reboot_reason(const char *reboot_reason)
Trace reboot reason.
void trace_firmware_update_finish(void)
Trace firmware update finished.
void trace_battery_health(unsigned int capacity_percent, unsigned int voltage_mV)
Trace battery health.
void trace_firmware_update_start(const char *firmware_version, const char *firmware_hash, const char *hash_algorithm)
Trace firmware update start.
void upload_text_file(const char *path, size_t fseek_offset, size_t max_size)
Reads text from a file at a given offset and sends it as a trace.
sternum_code_t sternum_trace_string_format(uint16_t trace_event_type, uint16_t argument_role_type, uint16_t max_length, const char *format,...)
void trace_signal_strength_report(unsigned int communication_type, int signal_strength)
Trace signal strength.
void trace_error(unsigned int error_code, const char *message, const char *file_name, unsigned int line)
Trace error.