ESP3D  3.0
Firmware for ESP boards connected to 3D Printer
debug_esp3d.h
Go to the documentation of this file.
1 /*
2  debug_esp3d.h - esp3d debug functions
3 
4  Copyright (c) 2014 Luc Lebosse. All rights reserved.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef _DEBUG_ESP3D_H
22 #define _DEBUG_ESP3D_H
23 
24 #include "../include/esp3d_config.h"
25 #if defined(ARDUINO_ARCH_ESP32)
26 #define log_esp3d(format, ...) log_d(format, ##__VA_ARGS__)
27 #define log_esp3dS(format, ...) log_d(format, ##__VA_ARGS__)
28 #else
29 #define log_esp3d(format, ...)
30 #define log_esp3dS(format, ...)
31 #endif
32 #define DEBUG_ESP3D_INIT
33 #define DEBUG_ESP3D_NETWORK_INIT
34 #define DEBUG_ESP3D_NETWORK_HANDLE
35 #define DEBUG_ESP3D_NETWORK_END
36 #if defined(ESP_DEBUG_FEATURE)
37 #if defined(ARDUINO_ARCH_ESP8266)
38 extern const char * pathToFileName(const char * path);
39 #endif //ARDUINO_ARCH_ESP8266
40 #undef log_esp3d
41 #undef log_esp3dS
42 //Serial
43 #if (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL0) || (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL1) || (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2)
44 
45 #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL0
46 #define DEBUG_OUTPUT_SERIAL Serial
47 #endif //DEBUG_OUTPUT_SERIAL0
48 #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL1
49 #define DEBUG_OUTPUT_SERIAL Serial1
50 #endif //DEBUG_OUTPUT_SERIAL1
51 #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2
52 #define DEBUG_OUTPUT_SERIAL Serial2
53 #endif //DEBUG_OUTPUT_SERIAL2
54 #undef DEBUG_ESP3D_INIT
55 #define DEBUG_ESP3D_INIT DEBUG_OUTPUT_SERIAL.begin(115200);
56 #define log_esp3d(format, ...) DEBUG_OUTPUT_SERIAL.printf("[ESP3D][%s:%u] %s(): " format "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__)
57 #define log_esp3dS(format, ...) DEBUG_OUTPUT_SERIAL.printf(format "\r\n", ##__VA_ARGS__)
58 #endif //DEBUG_OUTPUT_SERIAL0 || DEBUG_OUTPUT_SERIAL1 || DEBUG_OUTPUT_SERIAL2
59 
60 //Telnet
61 #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_TELNET
62 #include "../modules/telnet/telnet_server.h"
63 extern Telnet_Server telnet_debug;
64 #undef DEBUG_ESP3D_NETWORK_INIT
65 #undef DEBUG_ESP3D_NETWORK_END
66 #undef DEBUG_ESP3D_NETWORK_HANDLE
67 #define DEBUG_ESP3D_NETWORK_INIT telnet_debug.begin(DEBUG_ESP3D_OUTPUT_PORT, true);
68 #define DEBUG_ESP3D_NETWORK_HANDLE telnet_debug.handle();
69 #define DEBUG_ESP3D_NETWORK_END telnet_debug.end();
70 #define log_esp3d(format, ...) telnet_debug.printf("[ESP3D][%s:%u] %s(): " format "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__)
71 #define log_esp3dS(format, ...) telnet_debug.printf(format "\r\n", ##__VA_ARGS__)
72 #endif // DEBUG_OUTPUT_TELNET
73 
74 //Telnet
75 #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_WEBSOCKET
76 #include "../modules/websocket/websocket_server.h"
77 extern WebSocket_Server websocket_debug;
78 #undef DEBUG_ESP3D_NETWORK_INIT
79 #undef DEBUG_ESP3D_NETWORK_END
80 #undef DEBUG_ESP3D_NETWORK_HANDLE
81 #define DEBUG_ESP3D_NETWORK_INIT websocket_debug.begin(DEBUG_ESP3D_OUTPUT_PORT, true);
82 #define DEBUG_ESP3D_NETWORK_HANDLE websocket_debug.handle();
83 #define DEBUG_ESP3D_NETWORK_END websocket_debug.end();
84 #define log_esp3d(format, ...) websocket_debug.printf("[ESP3D][%s:%u] %s(): " format "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__)
85 #define log_esp3dS(format, ...) websocket_debug.printf(format "\r\n", ##__VA_ARGS__)
86 #endif // DEBUG_OUTPUT_WEBSOCKET
87 
88 #endif //ESP_DEBUG_FEATURE
89 #endif //_DEBUG_ESP3D_H
WebSocket_Server
Definition: websocket_server.h:30
Telnet_Server
Definition: telnet_server.h:30