-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmon08_strings.h
More file actions
66 lines (59 loc) · 2.41 KB
/
Copy pathmon08_strings.h
File metadata and controls
66 lines (59 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @file mon08_strings.h
* @brief String conversion utilities for MON08 enumerations.
* @details Translates protocol status and configuration enumerations into
* human-readable string constants to facilitate console logging
* and telemetry debugging.
*/
#ifndef MON08_STRINGS_H
#define MON08_STRINGS_H
#include "mon08.h"
///@brief Converts MON08_POWER to string
const char* power_strings(MON08_POWER power) {
switch (power) {
case MON08_POWER_OFF: return "OFF";
case MON08_POWER_ON: return "ON";
case MON08_POWER_HIZ: return "HIGH-IMPEDANCE";
default: return "UNKNOWN";
}
}
///@brief Converts MON08_STATUS to string
const char* status_strings(MON08_STATUS status) {
switch (status) {
case MON08_STATUS_IDLE: return "Idle";
case MON08_STATUS_OK: return "Ok";
case MON08_STATUS_HAL_ERROR: return "HAL Error";
case MON08_STATUS_NO_ECHO: return "No echo response";
case MON08_STATUS_BAD_ECHO: return "Echo is different from sent data";
case MON08_STATUS_NO_RESPONSE: return "Cannot read target response";
default: return "Unknown";
}
}
///@brief Converts MON08_AUTH_STATUS to string
const char* auth_status_strings(MON08_AUTH_STATUS status) {
switch (status) {
case MON08_AUTH_UNKNOWN: return "Unknown status";
case MON08_AUTH_WAITING_CODE: return "Waiting for security bytes";
case MON08_AUTH_OK: return "Authorized";
case MON08_AUTH_UNAUTHORIZED: return "Unauthorized";
case MON08_AUTH_NO_BREAK: return "No break detected after sending the eight security bytes";
case MON08_AUTH_BREAK_TIMEOUT: return "Break timeout (too long)";
case MON08_AUTH_INVALID_BREAK: return "Break has invalid length";
case MON08_AUTH_INVALID_RESPONSE: return "Cannot check the authentication result";
case MON08_AUTH_COM_FAILED: return "Communication error";
default: return "Unknown";
}
}
///@brief Converts MON08_GLITCH_STATUS to string
const char* glitch_status_strings(MON08_GLITCH_STATUS status) {
switch (status) {
case MON08_GLITCH_DISABLED: return "Disabled";
case MON08_GLITCH_IDLE: return "Waiting for configuration";
case MON08_GLITCH_READY: return "Ready to go";
case MON08_GLITCH_RUNNING: return "Running";
case MON08_GLITCH_UNSUCCESSFUL: return "Completed but unsuccessful";
case MON08_GLITCH_SUCCESSFUL: return "Successfully completed";
default: return "Unknown";
}
}
#endif