Arduino的库通过Web App或Telnet客户端通过WiFi进行调试,并带有Serial Monitor之类的打印命令。


默认情况下,Arduino仅通过串行端口具有调试可能性。这有一些缺点:
使用ESP8266(NodeMCU)或ESP32,我们现在拥有网络连接(WiFi),可实时流式传输调试信息。
该库非常适合物联网项目,家庭自动化,移动机器人(可以用电缆进行调试?)或其他WiFi项目。
实际上,该图书馆诞生的是需要调试家庭自动化的物联网项目。在这个项目中,有一个中央模块和三个辅助模块,而这些模块彼此远远不够。在房子的屋顶下很难到达。要调试这个项目,可以通过USB Cable伴随传统方式来伴随消息交换。
MIP_ESP8266_LIBRARY和我的ESP32 WiFi机器人是使用RemotedeBug的项目的示例。在以下查看:MIP_ESP8266_LIBRARY和ESPLORER_V1
通过客户缓冲, RemotedeBug改进了(上次发送<= 10ms),以避免在ESP32和ESP8266板上的WiFi网络延迟
注意:如果您的项目不使用wifi,则可以使用我的另一个库,即Serialdebug库,此库可与任何Arduino板一起使用。
注释II: RemotedeBug Library现在仅用于Espressif Boards,例如ESP32和ESP8266,如果需要另一个WiFi板,请添加有关此问题的问题,我们将看看是否有可能使您的董事会成为端口。
图像:在remotedebugapp(Web应用程序)中

图片:在Telnet客户端

YouTube(RemotedeBug V2):
YouTube(与remotedeBug的3个Telnet连接)V1:
通过在GitHub上创建帐户来为该图书馆的开发做出贡献。
请给星星,如果您觉得这个库有用,这也会帮助另一个人,也会发现它。
请添加问题或建议。
remotedebugapp beta
现在还有另一个存储库RemotedeBugapp,它用于Internet中的Web应用程序本地副本。在Web Server中发布后,它已使用Web应用程序的Last版本进行更新:http://joaolopesf.net/remotedebugapp。下载它,供互联网离线时使用。由于它是本地副本,因此该应用将定期检查新版本。
用于在Web浏览器中调试的HTML5 Web应用程序,而是使用Web套接字来交流的Telnet Client。
现在,RemotedeBug V3也具有Web插座服务器,以支持RemotedeBugApp连接。
RemotedeBugapp在Beta中,如果您有任何问题或建议,请添加有关此问题的问题。
telnet连接仍然存在,或任何需要的连接,或脱机使用。
版本2.1.1
版本2.0.0
现在, RemotedeBug可以具有与SerialDebug库相同的简单软件调试器。这是这样做的,安装了另一个库, compedebugger the remotedebugger作为对远程摄影的添加。为了支持此插件,远程登录的更改是最少的,只需几个回调即可为不需要调试器的项目添加额外的开销。要获得更多信息,请访问remotedebugger github存储库。
现在, RemotedeBug拥有一个新的颜色系统,使用更多颜色,如Serialdebugapp所做的那样
注意:由于remotedebug库,迁移到Arduino 1.5格式,并带有文件夹“ SRC”,请删除并重新安装库,以避免重复remotedebug源文件。
版本1.5。*
在1.5.0版本中,我们有debug*和rdebug*宏(请参见下文),它们自动将调用的函数名称和核心ID(核心ID仅适用于ESP32)
SerialDebug比serial.print命令:
是否通过USB电缆进行调试,serial.print Command Allways已处理,浪费CPU时间在微控制器上。换句话说,调试命令被处理,某人是否在串行中连接。
使用RemotedeBug ,仅当存在通过telnet或Web应用程序连接调试的任何人时,才能处理所有调试输出。
随着资源调试级别,显示消息的卷将减少更高的级别。例如,仅处理所有消息,如果级别是最低的,则详细信息,
将RemotedeBug被用来减少CPU和内存中的开销,并包括客户端缓冲功能。
在开发过程中,我们可以放置很多调试消息...
但是使用remotedebug ,我们可以在每个水平上提出一个水平。
对于所有消息(级别始终(debuga)或错误(Debuge),仅处理并显示该消息,如果调试级别等于或高于IT级别
按照优先级顺序, RemotedeBug具有6个调试级别:
总是显示:
错误:关键错误
总是:重要消息
另一个级别(显示级别是相等还是更高的实际级别):
警告:错误条件但不是关键
信息:信息消息
调试:额外信息
冗长:比平常的信息更多
因此,我们可以将级别更改为冗长,以查看所有消息。或调试仅查看调试或更高级别等。
减少项目可以生成的大量消息,以帮助调试非常好。
RemotedeBug有一个转换器,可以帮助您迁移您的Arduino代码,从Serial.Prints到此库。
remotedebugconverter
即使您想手动执行此操作,也很简单。请参阅上面的主题。
一个简单的调试:
debugV ( " * Run time: %02u:%02u:%02u (VERBOSE) " , mRunHours , mRunMinutes , mRunSeconds );可以在串行显示器中生成此输出:
(V p:3065 loop C1) * Run time: 00:41:23 (VERBOSE)
Where: V: is the level
p: is a profiler time, elased, between this and previous debug
loop: is a function name, that executed this debug
C1: is a core that executed this debug (and a function of this) (only for ESP32)
The remaining is the message formatted (printf)
对于ESP32,每个调试中的核心ID对于优化器多核编程非常好。
例如:
显示帮助( ? )
更改调试级别( V , D , I , W , E ),以更少或更多的消息。
请参阅内存( M )
重置董事会(重置)
请参阅下面有关remotedebug命令。
您可以添加自己的命令,请参见示例
如果您的项目已安装了RemotedeBugger ,请有一个新命令,例如调用函数,请参阅/更改变量,...
现在, RemotedeBug (版本> = 2.0.0),具有基于SerialDebug库代码的简单软件调试器。
这是另一个库,它充当了remotedebug的插件。
请提供更多信息: RemotedeBugger
For release your device, just uncomment DEBUG_DISABLED in your project
Done this, and no more debug processing.
And better for DEBUG_DISABLED, __RemoteDebug__ have ZERO overhead,
due is nothing of this is compiled.
作为Serialdebug,现在remotedebug(v3)具有一个应用程序,即remotedebugapp,可以在Web浏览器中调试。
该应用程序是一个HTM5 Web应用程序,其Websocket可以通信到Arduino Board。
为此,RemotedeBug V3具有Web套接字服务器(可以禁用)。它使用了ArduinoweBockockets库的本地副本,因为它在Arduino Library Manager中没有。
作为Web服务器上的大型网页,Arduino的解决方案将其保存在存储中,例如Spiffs。但是,没有自动在以这种方式保存的数据中自动更新新版本,因此该数据对项目有益,但对库不利。
因此,该应用程序未存储并由板提供,而是该应用程序在Web中:http://joaolopesf.net/remotedebugapp注意:这不是使用ssl(https),在arduino上的fuse web服务器套接字,而不是支持SSL(WSS)。但是,一页加载后,所有流量都在本地网络中,没有在Internet上公开数据。
RemotedeBugapp是现代的HTML5,需要现代浏览器才能工作。 Internet Explorer 11和Safari 10是不支持的示例。但是,您可以使用Athosher,例如Chrome,Edge,Firefox。
Web应用程序在Beta中,请添加问题,有关问题或建议。
现在还有另一个存储库RemotedeBugapp,它用于Internet中的Web应用程序本地副本。在Web Server中发布后,它已使用Web应用程序的Last版本进行更新:http://joaolopesf.net/remotedebugapp。下载它,供互联网离线时使用。由于它是本地副本,因此该应用程序将定期检查新版本,因为您可以下载新版本。
telnet仍然有效,对于此期间或Web应用程序上的失败。
Telnet是远程连接到服务器的标准方法,并在所有操作系统(Windows,Mac,Linux ...)上受支持。
MacOSX和Linux具有本机telnet客户端。
对于Windows,典型的Telnet客户端是Putty :Putty。
有一个好的手机工具:手指,请在您的移动商店中找到它。它显示本地网络(WiFi)中的所有设备,显示端口已打开并可以执行telnet客户端(外部应用)
RemotedeBug设置了telnet服务器,该服务器正在收听任何想要连接的Telnet客户端。连接后,将记录流传输到Telnet客户端。
RemotedeBug非常易于使用,在几行初始化代码之后,您可以使用众所周知的“打印”命令将日志记录流传输到远程客户端。
RemotedeBug支持基于调试级别的日志记录过滤:
仅显示实际调试级别:
注意:这些级别是按照最少的 - >最小值的顺序。
或始终显示(不取决于实际调试级别):
注意:所有调试都已处理,并且仅在具有客户端连接时显示。
Telnet客户端或Web应用程序可以通过键入一些简单的命令来设置调试级别。
RemotedeBug包括一个简单的探测器。可以通过连接的客户端(Telnet或Web应用程序)或Arduino代码本身启用它。
启用后,它显示了2个调试语句之间的时间,并根据经过的时间使用不同的颜色。
一个典型的示例是在函数之前和之后插入记录,然后您可以看到在功能中花费了多少。
RemotedeBug旨在提供最小的开销(是否连接),并且仅连接了客户端(Telnet或Web应用程序),则仅提供处理调试。
RemotedeBug支持可以在客户端(Telnet或Web应用程序)中输入的自定义命令。这些触发了Arduino代码中的自定义函数的执行。例如,这可以用于根据客户的要求发送状态。
当前版本的RemotedeBug尚未包含任何加密身份验证,仅纯文本,仅用于开发,而不用于生产/发布。
如果可能的话,将来版本将包括一种安全的认证方法和进一步测试以支持生产环境。
- An app to RemoteDebug like SerialDebug have.
- Http page to begin/stop the telnet server or websocket server.
- Authentication as telnet support (kerberos, etc.) to support production environment
只需下载或克隆此存储库即可。
或对于Arduino IDE,您可以使用库管理器安装和更新库。
有关安装帮助,请单击此:
对于另一个IDE或不使用Arduino IDE的库管理器,我建议您使用GitHub桌面应用程序克隆,它有助于保持更新。
请打开示例文件夹中的项目,以查看其工作。
# include " RemoteDebug.h " // https://github.com/JoaoLopesF/RemoteDebugremotedebug调试;
在WiFi初始化之后的设置功能中
// Initialize the server (telnet or web socket) of RemoteDebug
Debug.begin(HOST_NAME);
// OR
Debug.begin(HOST_NAME, startingDebugLevel);
// Options
Debug.setResetCmdEnabled( true ); // Enable the reset command
// Debug.showProfiler(true); // To show profiler - time between messages of Debug
注意:要启用remotedeBugger的调试器,请访问此github存储库: remotedebugger
在循环功能的尾部
// Remote debug over WiFi
Debug.handle();
// Or
debugHandle (); // Equal to SerialDebug
在您的任何地方代码:
# ifndef DEBUG_DISABLED
if (Debug.isActive(Debug.<level>)) {
Debug. printf ( " bla bla bla: %d %s " , number, str); // OR
Debug. printf ( " bla bla bla: %d %s " , number, str. c_str ()); // Note: if type is String need c_str() // OR
Debug. println ( " bla bla bla 2 ln " );
Debug. printf ( " float: %f n " , value); // Not works in ESP8266 :-(
// Note: to show floats with printf (ESP8266 only),
// you can use my ArduinoUtil library -> https://github.com/JoaoLopesF/ArduinoUtil
Debug. printf ( " float: %s n " , Util. formatFloat (value, 0 , 5 ). c_str ());
}
# endif注意:使用ISACTIVE,您需要通过debug_disable预编译条件包围代码,以避免将其编译为生产/发布
或短路(等于serialdebug)(如果只有一次调试,则优先):
debugA ( " This is a any (always showed) - var %d " , var);
debugV ( " This is a verbose - var %d " , var);
debugD ( " This is a debug - var %d " , var);
debugI ( " This is a information - var %d " , var);
debugW ( " This is a warning - var %d " , var);
debugE ( " This is a error - var %d " , var);
debugV ( " This is a println " );或者如果您的项目使用多个序列命令来生成单个调试消息,例如:
Serial.print( " a = " );
Serial.print(a);
Serial.print( " b = " );
Serial.print(b);
Serial.print( " c = " );
Serial.println(c);可以使用rdebug*宏:
rdebugV ( " a = " );
rdebugV (a);
rdebugV ( " b = " );
rdebugV (b);
rdebugV ( " c = " );
rdebugVln (c);注意:将来,我建议您将其迁移到一个调试命令:
debugV (a = %d b = %d c = %d " , a, b, c);使用调试级别的一个示例:(假设数据有很多字符)
if (Debug.isActive(Debug.VERBOSE)) { // Debug message long
Debug. printf ( " routine: data received: %s n " , data. c_str ()); // Note: if type is String need c_str()
} else if (Debug.isActive(Debug.DEBUG)) { // Debug message short
Debug. printf ( " routine: data received: %s ... n " , data. substring ( 0 , 20 ). c_str ()); // %.20s not working :-|
}从版本1.5.0开始,调试宏(调试*和rdebug*)自动将称为宏的功能名称和核心ID(仅用于ESP32的核心ID)。
所以:
void foo () {
uint8_t var = 1 ;
debugV ( " this is a debug - var %u " , var);
}
It will show in client (telnet or web app):
(V p:^0000ms) (foo)(C1) this is a debug - var 1
Where:
V -> verbose
p -> profiler time
(foo) -> this is a function name that calls the debug macro
(C1) -> It is running it Core 1 (only for ESP32)
启用串行启用的使用调试的示例
Useful to see messages if setup or
in cause the ESP8266/ESP32 is rebooting (client connection stop before received all messages)
Only for this purposes I suggest it
// Setup after Debug.begin
Debug.setSerialEnabled( true ); // All messages too send to serial too, and can be see in serial monitor为了减少开销,如果不活动,则remotedeBug是断开客户端(telnet或Web应用程序)的连接。
- Please press enter or any key if you need keep the connection
- The default is 5 minutes (You can change it in RemoteDebug.h)
- You can use mDNS to register each node with different name, it helps to connect without know the IP.
请不要忘记使用debug.Sactive子句(如果不使用debug宏)
---> This is very important to reduce overheads and work of debug levels
请参阅基本或高级的样本,以了解如何使用
在高级样本中,我使用了Wifimanager库,Arduinoota和MDN,请查看。
- Ajustment on debugA macro, thanks @jetpax and @cmidgley to add this issue.
- All public configurations (#defines) have moved to RemoteDebugCfg.h, to facilitate changes for anybody.
- Changed examples, with warnings on change any #define in project,
with workarounds if it not work. (thanks to @22MarioZ for added this issue)
- Adjustments if web socket is disabled
- Adjustments in examples, added one for debugger
- Adjustments in silente mode
- Commands from RemoteDebugApp now is treated
- Adjusts to RemoteDebugger support connection by web sockets
- If not disabled, add a web socket server to comunicate with RemoteDebugApp (HTML5 web app)
- The standard telnet still working, to debug with internet offline
- Ajustment on debugA macro, thanks @jetpax to add this issue
- Add empty rprint* macros, if debug is disabled
- Create option DEBUG_DISABLE_AUTO_FUNC
- Create macros to be used for code converter: rprint and rprintln
RemoteDebug now have an code converters to help migrate codes
- Create precompiler DEBUG_DISABLED to compile for production/release,
equal that have in SerialDebug
- Adjustments in examples
- Adjustments for the debugger: it still disable until dbg command, equal to SerialDebug
- The callback will to be called before print debug messages now
- And only if debugger is enabled in RemoteDebugger (command dbg)
- Changed handle debugger logic
- Added support to RemoteDebug addon library: the RemoteDebugger, an simple software debugger, based on SerialDebug
- New color system
- Bug -> sometimes the command is process twice
- Workaround -> check time
- New macros to compatibility with SerialDebug (can use RemoteDebug or SerialDebug) thanks to @phrxmd
- Fixed bug for MAX_TIME_INACTIVE, thanks to @achuchev to add this issue
- Adjustments based on pull request from @jeroenst (to allow serial output with telnet password and setPassword method)
- Serial output is now not allowed if telnet password is enabled
- Few adjustments
- Few adjustment in write logic
- Serial output adjustments (due bug in password logic)
- Correct rdebug macro (thanks @stritti)
- New silent mode (command s)
- Auto function name and ESP32 core id for rdebug* macros
- begin method have a option for port number
- Few adjustments
- Added new rdebug?ln to put auto new line
- Simple text password request feature (disabled by default)
Notes:
It is very simple feature, only text, no cryptography,
and the password is echoed in screen (I not discovery yet how disable it)
telnet use advanced authentication (kerberos, etc.)
Such as now RemoteDebug is not for production (releases),
this kind of authentication will not be done now.
- Adjustments in precompiler macros
- Bug in write with latest ESP8266 SDK
- Port number can be modified in project Arduino (.ino file)
- Few adjustments as ESP32 includes
- Adjustments, as avoid ESP32 include errors
- Telnet port of server can be modified by project
Just put it in your .ino, before the include:
- Shortcuts and client buffering to avoid mysterious delay of ESP networking
- Adjustments and now runs in Esp32 too.
- Adjustments and improvements from Beta versions.
New features:
- Filter
- Colors
- Support to Windows telnet client
- First Beta
- Sometimes (rarely) the connection over telnet becomes very slow.
Especially right after uploading firmware.
Reset command in telnet connection or turn off/on can be resolve it.
But I need find why it occurs
First thanks a lot for Igrr for bring to us the Arduino ESP8266 and to Espressif to Arduino ESP32
Thanks to Links2004 for a good web server socket, used for web app connection.
For the logo: thanks to a freepik and pngtree sites for free icons that have in logo
Resources:
- Example of TelnetServer code in http://www.rudiswiki.de/wiki9/WiFiTelnetServer
- arduinoWebSockets library in https://github.com/Links2004/arduinoWebSockets
从2019-03-03开始访问此文件: