joaolopesf / remotedebug Goto Github PK
View Code? Open in Web Editor NEWLibrary for Arduino to debug projects over WiFi, with web app or telnet, with print commands like Serial Monitor
License: MIT License
Library for Arduino to debug projects over WiFi, with web app or telnet, with print commands like Serial Monitor
License: MIT License
When using this code:
Debug.setSerialEnabled(true);
Debug.begin(esp_hostname);
Debug.setResetCmdEnabled(true);
Debug.setCallBackProjectCmds(&processCmdRemoteDebug);
DEBUG("\n");
DEBUG("ESP8266 started...\n");
Serial.println("\n\nHello\n");
Debug.printf("Hello2\n");
The ESP8266 started (and everyting with the debug macro after this code) is not printed when using the DEBUG macro.
The Hello and Hello2 are printed.
What's wrong?
This is a very nice library. I cannot find any license information supplied in the repository. Can you please include the license that you are releasing this code under? Thanks.
While connected through telnet I can rest the device. It is not rebooting however.
Serial output shows a WDT reset (which is the last message and then nothing...)
Sorry for opening an issue for a question - not sure how else to ask.
I have a project where the functionality is split across several cpp files (and an .ino file shell that calls functions from them). They are full of serial debug statements which I would like to replace with your library. (I imagine not a unique scenario)
Could you provide some basic guidance for this scenario and where to do the includes and where to declare the object - I generally work with single file ino files so am not having much luck - all my attempts result in compiler errors. I believe it requires some combination of includes and extern declaration but can't get it working.
See this piece of command line print I extracted. I "highlighted" some weird behaviour with two asterisk characters around the value.
> * Debug: Command recevied: l
> * Show debug level: Off
$ v
> * Debug: Command recevied: v
> * Debug level setted to Verbose
$ l
> * Debug: Command recevied: l
> * Show debug level: **On** <- Okay, it's on but I expected it show v or verbose
$ d
> * Debug: Command recevied: d
> * Debug level setted to Debug
$ l
> * Debug: Command recevied: l
> * Show debug level: **Off** <- How can it be off if I just turned it to debug?
$ d
> * Debug: Command recevied: d
> * Debug level setted to Debug
$ l
> * Debug: Command recevied: l
> * Show debug level: **On** <- I redo setting it to debug and now it it's "on"?
It looks like the value for show debug level get's toggled, but also isn't showing the correct debug status.
Using if ( Debug.isActive( .. ) )
is a bit annoying if you have lots of debug messages.
Using a function like
Debug.printf( debugLevel , "Some string with some format place holders %d %s", some, variables );
code would be cleaner.
it could be implemented as
size_t RemoteDebug::printf (uint8_t debugLevel, const char* format , ...) {
if (isActive (debugLevel)) {
va_list argptr;
va_start (argptr, format);
printf (format, argptr);
va_end (argptr);
}
}
Do you agree?
I'm seeing what looks like a buffer overflow when sending debug messages, that displays the ANSI escape message )see image)
I don't see them ever when RemoteDebug sends 'Project commands", eg u command in image,
but as you can see when debugI for example sends data from my program, sometimes the previous response is repeated with part of the ANSI escape sequence missing and hence appears as text.
Hello,
I have been using your lib for a couple of days and I like it very much.
I have encountered the following (little) problems:
-After resetting the ESP loglevel ist set to 'off', but Errors a still logged.
Is it possible active and deactive RemoveDebug by code?
On my project with ESP8266 there is a html page (by webserver) to set some option.
I'd like add a option to active/deactive RemoteDebug, so I can use it when I need without compile my project.
Is it possible? How?
Is possibile change activection time by code without chance library code (default 5 minutes)?
Would it be possible to add a function which will pause the execution of all code until someone connects to the debugger?
It would be useful in situations where, for example, you have some code that is executed during setup, before you have the chance to connect.
First, thanks for a wonderful utility
I found debugA doesn't display
changed line 247 of RemoteDebug.h from
#define debugA(fmt, ...) rdebugVln(fmt, ##__VA_ARGS__)
to
#define debugA(fmt, ...) rdebugAln(fmt, ##__VA_ARGS__)
and seems to work
Describe the bug
When inside a namespace, I can't use the debugI
, debugV
... shorthands.
Code Example
This prints out the same thing, once via tha long form and once with the debugI
macro.
namespace Example {
void test(const char * prefix) {
#ifndef DEBUG_DISABLED
if (Debug.isActive(Debug.INFO)) {
Debug.printf(prefix, "hi");
}
#endif
debugI(prefix, "hi");
}
};
Now call Example::testWorks("this says %s");
.
Expected behavior
Both ways of printing a debug line should work.
Current behaviour
Here's the compiler output:
some-file: In function 'void Example::test(const char*)':
some-file:29:10: error: expected ')' before 'prefix'
debugI(prefix, "hi");
^
src/RemoteDebug.h:146:84: note: in definition of macro 'rdebugI'
#define rdebugI(fmt, ...) if (Debug.isActive(Debug.INFO)) Debug.printf("(%s) " fmt, __func__, ##__VA_ARGS__)
^
src/RemoteDebug.h:195:26: note: in expansion of macro 'rdebugIln'
#define debugI(fmt, ...) rdebugIln(fmt, ##__VA_ARGS__)
^
some-file:29:3: note: in expansion of macro 'debugI'
debugI(prefix, "hi");
^
Arduino Information:
C++ newb here. Could you please suggest or show small example of how to use logger if code consists of 3 files:
If i import RemoteDebug in lib.cpp, how do i use it later in main.cpp ? In my case there are way more files that needs access to that logger, but because debugV or other methods requires Debug variable i'm not sure how to use it.
You can close this issue anytime :)
After a little more understanding of your code I see the custom callback function that will easily accomplish what I was trying to do with this suggestion in a much better way.
Thank you again...
First, thank you for a great troubleshooting tool!
A have two suggestions. The "m" command only shows the free heap memory which is certainly useful. I have added the flash chip size, sketch size and free sketch space.
//Added the following lines to get more info;
telnetClient.print("* Flash Chip Size: ");
telnetClient.println(ESP.getFlashChipSize());
telnetClient.print("* Sketch Size: ");
telnetClient.println(ESP.getSketchSize());
telnetClient.print("* Free Sketch Space: ");
telnetClient.println(ESP.getFreeSketchSpace());
This could arguably be included in the second but I like them separate.
The second suggestion is to add a flag to enable some output configured in the user's sketch triggered by a command. The existing mechanisms are great for periodic diagnostic messages. I often find the desire for diagnostic information on command.
Added to RemoteDebug.h in the public section:
boolean userInfo;
Added to RemoteDebug.cpp:
help.concat(" u -> trigger user info\r\n");
and
} else if (_command == "u") {
// Set flag to enable output of user configured data
// User must set the flag false
userInfo = true;
telnetClient.printf("* User info triggered:\r\n");
Then the user can add something like this to the loop section:
if(Debug.userInfo) {
// Add code here to output disgnostic information
INFO("User Info Flag detected\n");
Debug.userInfo = false; // Set the flag false to prevent repeating the information
}
Thank you for your great work and consideration of these suggestions.
John
Describe the bug
By default serial only outputs the initial level (debug). When the debug level is changed through telnet the serial level is also changed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The serial console should not be affected by the telnet debug level. It should output all levels by default and it should be possible to change the level for serial logging it in code.
Screenshots
If applicable, add screenshots to help explain your problem.
Arduino Information:
Additional context
None.
processCmdRemoteDebug doest work properly, in line 288
if (Debug.getLastCommand() = "bench1") {
should be "==" instead of "="?
also Debug.ative, ative is typo with active?
The library is amazing! Thank you
Hi,
Ran into an issue where the string "27" is not been displayed correctly on the websocket interface. The serial port and telnet interfaces do not have this problem.
I'm using release 3.05 using PlatformIO, and the remote debug app from here: http://joaolopesf.net/remotedebugapp/
The following test code should reproduce the issue
` //cut down version of the original problem I observerd
double tmp = 0.000043;
tmp *= 6372795.0;
Debug.printf("5, %f\n", tmp);
rdebugE("6, %f\n", tmp);
//Other examples that don't display correctly on the websocket interface
Debug.println("274.030185");
Debug.println(274.030185);
Debug.println(274);`
And got the following on the websocket interface
(E) 5, 4.030185
(E) (distanceBetween) 6, 4.030185
(E) 4.030185
(E) 4.03
(E) 4
And this on the serial port and telnet interface
(E) 5, 274.030185
(E) (distanceBetween) 6, 274.030185
(E) 274.030185
(E) 274.03
(E) 274
Maybe 27 is being interpreted as an escape character or the like.
Hello,
unfortunately the library does not run with the ESP32. Will there be any adjustments?
Boris
The session is automatically closed after 10 minutes and this a problem when debugging.
It should be nice to be able to redefine MAX_TIME_INACTIVE without editing RemoteDebugCfg.h
// Maximum time for inactivity (em milliseconds)
// Default: 10 minutes
// Comment it if you not want this
// Can be by project, just define it before include this file
#ifndef MAX_TIME_INACTIVE // To be added
#define MAX_TIME_INACTIVE 600000
#endif // to be added
I did a small test with a sample sketch:
connected to telnet: OK
quit connection: OK
connected again: OK, small decrease in free heap
quit connection OK
tried to connect again but "connection refused"
I could post my sketch if needed.
Hi there, and thanx for this nice addition. Worx like a charm.
For reasons of obfuscating, I want to set the Telnet port to something other than 23. I designed a solution for this, see included files. I also changed the word 'setted' into 'set' in several places, hope you don't mind.
Keep up the good work!
PjotrekSE
I have updated to current version 1.4 getting now compile errors. E.g.
.piolibdeps\RemoteDebug_ID1266/RemoteDebug.h:180:39: error: expected primary-expression before '...' token
#define rdebug(fmt, ...) rdebugA(fmt, ...)
^
See also travis-build: https://travis-ci.org/stritti/smart-swimming-pool
Hello,
we are using RemoteDebug in our access control system for 3D printers and I would like to ask if websocket client can be also implemented .
As we are still developing our FW and we have no problem with RemoteDebug, we could use some remote logging to our server in local network, which can be done by websocket client. Sometimes I need look at log for information what happened and telnet and web app is good but sometimes connection break and I lost log which is very valuable.
I tried implement websocket client at our server, but this is not good solution for us as we do not use static IP addresses at our printers, this is also for mobility of printer (different places, different networks) so this would be very good solution for us and I believe for some other people as well.
If you can at least point it out what need to be changed to implement this, so we can look at it at try that, but for now I´m bit lost.
Thanks
Looking at the code below the telnet connection will be closed after 1 min of inactivity even when MAX_TIME_INACTIVE is set to different value.
`
#ifdef MAX_TIME_INACTIVE
// Inactivity - close connection if not received commands from user in telnet
// For reduce overheads
uint32_t maxTime = MAX_TIME_INACTIVE; // Normal
if (_password != "") { // Request password - 18/08/08
maxTime = 60000; // One minute to password
}
if ((millis() - _lastTimeCommand) > maxTime) {
TelnetClient.println("* Closing session by inactivity");
TelnetClient.stop();
_connected = false;
_silence = false;
}
#endif`
Describe the bug
WiFiClientSecure.h not found error when using espressif32 platform with PlatformIO
To Reproduce
Just use remotedebug in a project on PlatformIO with espressif32
Expected behavior
The code should work also under these conditions
Additional context
I used the WEBSOCKET_DISABLED switch but as PlatformIO is compiling the /utility directory I also had to add an entry to library.json:
"build": {
"srcFilter": "+<*> -"
},
Now my project works again but of course this is not ideal... Better to fix the code for espressif32 use.
Describe the bug
this code can never output "x=0"
if (x == 1) debugD("x=1");
else debugD("x=0");
but this code works
if (x == 1) {debugD("x=1");}
else {debugD("x=0");}
To Reproduce
Run code snippets above.
Although it can be sniffed by wireshark, a password before entering the debug telnet connection would be nice to prevent unwanted users to open the debug console. The chance that it will be sniffed is pretty low on home lan environments.
Compiling for Wemos D1 Mini using Arduino IDE. I receive the following compiler errors.
/Users/zach/Documents/Arduino/libraries/RemoteDebug/RemoteDebug.cpp: In member function 'void RemoteDebug::begin(String, uint16_t, uint8_t)':
/Users/zach/Documents/Arduino/libraries/RemoteDebug/RemoteDebug.cpp:104:25: error: no matching function for call to 'WiFiServer::begin(uint16_t&)'
TelnetServer.begin(port);
^
/Users/zach/Documents/Arduino/libraries/RemoteDebug/RemoteDebug.cpp:104:25: note: candidate is:
In file included from /Users/zach/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/ESP8266WiFi.h:40:0,
from /Users/zach/Documents/Arduino/libraries/RemoteDebug/RemoteDebug.cpp:65:
/Users/zach/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiServer.h:53:8: note: virtual void WiFiServer::begin()
void begin();
^
/Users/zach/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiServer.h:53:8: note: candidate expects 0 arguments, 1 provided
exit status 1
Error compiling for board WeMos D1 R2 & mini.
I like your idea of remote debugging over telnet. But I see one problem, which is that most of existing libraries use Serial
class to trace things. And this traces will not be seen in telnet connection.
Wouln't be possible to redirect Serial
output to telnet? I mean implementing something to override default logic. In this way existing libraries traces could be debugged over telnet
This looks very nifty!
What I find inconvenient, however, is that the library uses a different interface than your own SerialDebug
library. There we have DebugV()
, printlnD()
, debugHandle()
etc., here we have Debug.printf()
, rprintlnD()
, Debug.handle()
etc.. Because of this inconsistency neither library is a drop-in replacement for the other and you have to keep modifying your code if you want to change the debugging target.
Personally I think I prefer the way it is done here (through a Debug
object and macros that refer to it). But I think either way would be fine, as long as they're consistent.
Describe the bug
When a client connects to the remote debug telnet port after about 20 seconds the esp becomes unresponsive and the watchdog kicks in...
To Reproduce
Steps to reproduce the behavior:
Install Arduino
Upload a sketch containing remote debug ( github.com/jeroenst/espMQTT )
Connect to the telnet port
Wait for esp to hang and watchdog to kick in
Expected behavior
Esp should not hang
Screenshots
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
(setup)
Arduino Information:
OS: Linux Mint 19.1 Tessa
IDE Arduino
IDE Version 1.8.9
Board ESP8266
Additional context
Add any other context about the problem here.
Describe the bug
The switch #define WEBSOCKET_DISABLED true
is not working. I'm trying to use RemoteDebug, but I'm not able to disable WebSocket. I need to disable websocket as I'm using it in my code.
I try also the Advance Example and the behavior is the same.
To Reproduce
Steps to reproduce the behavior:
#define WEBSOCKET_DISABLED true
Expected behavior
If the switch #define WEBSOCKET_DISABLED true
is enabled, the connection with remotedebugapp should not be possible.
Arduino Information:
I would like to be able to get some debug message in the void setup() funtion and even before. Is there any way to do that? I looks like you have to wait for Debug.handle() to run in the void loop() function before any Debug.printf() lines will get executed.
So happy to at least get some Loop() debug with OTA updates.
// Show debug level
void RemoteDebug::showDebugLevel(boolean show) {
_showProfiler = show;
}
--> _showDebugLevel
Hello,
I am using your Remote Debug on several ESPxx Projects.
But I also have some projects with Arduino Mega and Ethernet Shield.
Would it not be possible to use it also with the Arduino?
Boris
Describe the bug
When serial output is enabled each line is started with [0m (shown on arduino serial monitor)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A line on the serial monitor should not start with [0m
Screenshots
If applicable, add screenshots to help explain your problem.
Arduino Information:
Additional context
Add any other context about the problem here.
It may be useful to other readers if you added this to the "Usage" section of the readme"
RemoteDebug Debug;
The "basic" example was not very basic to me, so I followed the Usage section thinking that would be bare minimum, but instead I got errors "Debug not declared in this scope".
I like the implementation. Simple to use.
I want to give a big thumbs up to the suggestion in #18. That would be a big help too.
In RemoteDebug_Advanced.ino
there is references to Debug.ANY
, however, this doesn't exist in RemoteDebug.h
.
Hi,
I am trying to print some values from the startup.
I tried to do it by doing this:
delay(15000); // this gives me time to connect Putty,
rdebugDln("startup done");
delay(1000);
Debug.handle();
delay(5000); // instead of the yield();
But in Putty, I dont see the startup done
, I only see the debug from the loop
.
In the docs you mention that Debug.handle();
should be in loop. But is there a way to also use it in startup
.
Hey, short way debugging without any paramter doenst work. The docu says rdebugV("text") but this is wrong...
Can you add some functionality to change debug serial port?
Is your feature request related to a problem? Please describe.
All messages processed by debug are stored in RAM memory.
So in effect, observing/debugging application causes huge difference in RAM utilisation.
Describe the solution you'd like
Something like:
debugI(F("some message stored in flash"));
Besides: excellent library.
Would it be possible to implement the asynchronous websockets in this library?
I just upgraded my @esp8266 core package to 2.4.2 and found that debug messages of any level no longer display to telnet.
The introductory help message displays and responses to input commands still display too but no messages from my sketches are displayed. This affects the example sketches included in the RemoteDebug library too. For example, the code:
DEBUG_V("* This is a message of debug level VERBOSE\n");
DEBUG_D("* This is a message of debug level DEBUG\n");
DEBUG_I("* This is a message of debug level INFO\n");
DEBUG_W("* This is a message of debug level WARNING\n");
DEBUG_E("* This is a message of debug level ERROR\n");
will not display to telnet. I tested this by editing the example code with my access point ssid and password only, no other changes and doing a compile on first the 2.4.1 version of esp8266 core then with the 2.4.2 core. While both versions compile with no errors at all, debug messages are displayed with version 2.4.1 but not with 2.4.2.
Describe the bug
The domain joaolopesf.net expired on 10/10/2019 and is pending renewal or deletion.
To Reproduce
Navigate browser to http://joaolopesf.net/remotedebugapp.
Expected behavior
Opening http://joaolopesf.net/remotedebugapp shows remote debug web-app.
If you try to build a project that uses the WebSockets library, the files in the RemoteDebug project cause linking errors (multiple definitions of class methods).
I'm writing a library that is using the RemoteDebug library. My library is using WebSockets natively. When building, I get a lot of these linker errors:
.pioenvs/d1_mini/libdf9/libWebSockets_ID549.a(WebSockets.cpp.o): In function `WebSockets::write(WSclient_t*, unsigned char*, unsigned int)':
WebSockets.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPhj+0x10): multiple definition of `WebSockets::write(WSclient_t*, unsigned char*, unsigned int)'
.pioenvs/d1_mini/lib5ee/libRemoteDebug_ID1266.a(WebSockets.cpp.o):WebSockets.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPhj+0x10): first defined here
.pioenvs/d1_mini/libdf9/libWebSockets_ID549.a(WebSockets.cpp.o): In function `WebSockets::sendFrame(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool, bool)':
WebSockets.cpp:(.text._ZN10WebSockets9sendFrameEP10WSclient_t10WSopcode_tPhjbb+0x24): multiple definition of `WebSockets::sendFrame(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool, bool)'
.pioenvs/d1_mini/lib5ee/libRemoteDebug_ID1266.a(WebSockets.cpp.o):WebSockets.cpp:(.text._ZN10WebSockets9sendFrameEP10WSclient_t10WSopcode_tPhjbb+0x24): first defined here
.pioenvs/d1_mini/libdf9/libWebSockets_ID549.a(WebSockets.cpp.o): In function `WebSockets::clientDisconnect(WSclient_t*, unsigned short, char*, unsigned int)':
WebSockets.cpp:(.text._ZN10WebSockets16clientDisconnectEP10WSclient_ttPcj+0x4): multiple definition of `WebSockets::clientDisconnect(WSclient_t*, unsigned short, char*, unsigned int)'
.pioenvs/d1_mini/lib5ee/libRemoteDebug_ID1266.a(WebSockets.cpp.o):WebSockets.cpp:(.text._ZN10WebSockets16clientDisconnectEP10WSclient_ttPcj+0x4): first defined here
.pioenvs/d1_mini/libdf9/libWebSockets_ID549.a(WebSockets.cpp.o): In function `WebSockets::handleWebsocketPayloadCb(WSclient_t*, bool, unsigned char*)':
WebSockets.cpp:(.text._ZN10WebSockets24handleWebsocketPayloadCbEP10WSclient_tbPh+0x18): multiple definition of `WebSockets::handleWebsocketPayloadCb(WSclient_t*, bool, unsigned char*)'
...
Please consider either pulling the WebSockets in as an external dependency (probably works only in PlatformIO) or renaming the WebSockets classes e.g.: WebSockets -> RDWebSockets etc.
Can't compile sample for ESP32, will give the following error:
C:\Users\Evert\Documents\Arduino\libraries\ESP8266-RemoteDebug-Telnet-master\Samples\RemoteDebug_Basic\RemoteDebug_Basic.ino:23:71: fatal error: ESP8266WiFi.h: No such file or directory
Don't get it wifi is working fine with mqtt and webserver.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.