Skip to content

debug menu - add documentation #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ generic.menu.DebugLevel.WiFi=WiFi
generic.menu.DebugLevel.WiFi.build.debug_level=-DDEBUG_ESP_WIFI
generic.menu.DebugLevel.HTTPClient=HTTPClient
generic.menu.DebugLevel.HTTPClient.build.debug_level=-DDEBUG_ESP_HTTP_CLIENT
generic.menu.DebugLevel.HTTPClient2=HTTPClient + SSL
generic.menu.DebugLevel.HTTPClient2.build.debug_level=-DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_SSL
generic.menu.DebugLevel.HTTPUpdate=HTTPUpdate
generic.menu.DebugLevel.HTTPUpdate.build.debug_level=-DDEBUG_ESP_HTTP_UPDATE
generic.menu.DebugLevel.HTTPUpdate2=HTTPClient + HTTPUpdate
Expand Down
Binary file added doc/Troubleshooting/debug_level.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Troubleshooting/debug_port.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions doc/Troubleshooting/debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Debugging
---

## Table of Contents
* [Introduction](#introduction)
* [Requirements](#requirements)
* [Usage](#Usage)
* [Informations](#Informations)
* [For Developers](#for-developers)

## Introduction

Since 2.1.0-rc1 the core includes a Debugging feature that is controllable over the IDE menu.

The new menu points manage the real-time Debug messages.

### Requirements

For usage of the debugging a Serial connection is required (Serial or Serial1).

The Serial Interface need to be initialized in the ```setup()```.

Set the Serial baud rate as high as possible for your Hardware setup.

Minimum sketch to use debugging:
```cpp
void setup() {
Serial.begin(115200);
}

void loop() {
}
```

### Usage

1. Select the Serial interface for the Debugging messages:
![Debug-Port](debug_port.png)

2. Select which type / level you want debug messages for:
![Debug-Level](debug_level.png)

3. Check if the Serial interface is initialized in ```setup()``` (see [Requirements](#requirements))

4. Flash sketch

5. Check the Serial Output



## Informations

It work with every sketch that enables the Serial interface that is selected as debug port.

The Serial interface can still be used normal in the Sketch.

The debug output is additional and will not disable any interface from usage in the sketch.

### For Developers

For the debug handling uses defines.

The defined are set by command line.

#### Debug Port

The port has the define ```DEBUG_ESP_PORT``` possible value:
- Disabled: define not existing
- Serial: Serial
- Serial1: Serial1

#### Debug Level

All defines for the different levels starts with ```DEBUG_ESP_```

a full list can be found here in the [boards.txt](https://github.com/esp8266/Arduino/blob/master/boards.txt#L180)

#### Example for own debug messages

The debug messages will be only shown when the Debug Port in the IDE menu is set.

```cpp
#ifdef DEBUG_ESP_PORT
#define DEBUG_MSG(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
#else
#define DEBUG_MSG(...)
#endif

void setup() {
Serial.begin(115200);

delay(3000);
DEBUG_MSG("bootup...\n");
}

void loop() {
DEBUG_MSG("loop %d\n", millis());
delay(1000);
}
```