-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug-com.nxc
176 lines (146 loc) · 4.04 KB
/
debug-com.nxc
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/**
* @file debug-com.nxc
* \ingroup debug
*
* @brief Remote debugging functions
*
**/
/*
CHANGELOG:
TODO:
BUGS:
*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#ifndef __DEBUG_COM_H_
#define __DBEUG_COM_H_
#include "com.nxc"
#include "class.nxc"
/// Do not define if you make a release executable with no debugging
#ifndef DEBUG_COM_OFF
#define DEBUG_COM
#endif
/// \cond
#ifdef DEBUG_COM
// debug module uses other standard parameters
sCom mDebugCom;
#endif
/// \endcond
/**
* \brief Initialize the communication module.
*
* Use this to initialize the communication module.
* The paramters are set to default values.
* Standard send-time = 500 ms.
* You can initialize the com-module with other standard
* in/outbox or sendTime. The send-time is used after every send function.
*
* \param outbox Set default outbox for sending messages.
* (0-8)
* \param sendTime Time in milliseconds.
*/
void initComDebug(const byte outbox = 0, const unsigned long sendTime = 500)
{
#ifdef DEBUG_COM
initCom(); // initCom Ok????
mDebugCom.SendTime = sendTime;
mDebugCom.Outbox = outbox;
#endif
}
/**
* \brief Set default send-time
*
* You may set a new default send time.
* Standard wait-time is 500ms.
* Use high values so that you can follow the message stream.
* The send-time is used after every send function.
*
* \param sendTime Time in milliseconds.
*/
void setComDebugSendTime(const unsigned long sendTime)
{
#ifdef DEBUG_COM
mDebugCom.SendTime = sendTime;
#endif
}
/**
* \brief Set default outbox.
*
* You may set a new default outbox.
* Standard outbox is 0.
*
* \param outbox See nxc api for more information.
*/
void setComDebugOutbox(const byte outbox)
{
#ifdef DEBUG_COM
mDebugCom.Outbox = outbox;
#endif
}
/**
* \brief Send a debug message to outbox.
*
* Send a debug message to specified outbox and wait for time ms.
* Designed for simplicity: send("No other parameters");
* Read class description for more information!
*
* \param message Any String. (Text)
* \param class The class which the message belongs to.
* \param time The send time in milliseconds.
*/
void sendDebug(const string message,
unsigned int class = NA,
unsigned long time = NA)
{
#ifdef DEBUG_COM
if(time == NA) time = mDebugCom.SendTime;
if(classHandler(class))
send(message, time, mDebugCom.Outbox);
#endif
}
/**
* \brief Send a debug number to outbox.
*
* Send a debug number to specified outbox and wait for time ms.
* Designed for simplicity: send(10.01);
* Read class description for more information!
*
* \param number Any number.
* \param class The class which the message belongs to.
* \param time The send time in milliseconds.
*/
void sendDebugNum(float number,
unsigned int class = NA,
unsigned long time = NA)
{
#ifdef DEBUG_COM
if(time == NA) time = mDebugCom.SendTime;
if(classHandler(class))
sendNum(number, time, mDebugCom.Outbox);
#endif
}
/**
* \brief Send a debug message to outbox.
*
* Send a debug message to specified outbox and wait for time ms.
* Designed for simplicity: send("No other parameters");
* Read class description for more information!
*
* \param format A string specifying the desired format.
* See nxc api sprintf or ex_console.
* \param number The number to send in the specified format.
* \param class The class which the message belongs to.
* \param time The send time in milliseconds.
*/
void sendDebugF(const string format,
const float number,
unsigned int class = NA,
unsigned long time = NA)
{
#ifdef DEBUG_COM
if(time == NA) time = mDebugCom.SendTime;
if(classHandler(class))
sendF(format, number, time, mDebugCom.Outbox);
#endif
}
#endif