|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en-us"> |
| 3 | + |
| 4 | + <head> |
| 5 | + <link href="http://gmpg.org/xfn/11" rel="profile"> |
| 6 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | + <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
| 8 | + |
| 9 | + <!-- Enable responsiveness on mobile devices--> |
| 10 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"> |
| 11 | + |
| 12 | + <title> |
| 13 | + |
| 14 | + Debugging · ESP8266 Arduino Core |
| 15 | + |
| 16 | + </title> |
| 17 | + |
| 18 | + <!-- CSS --> |
| 19 | + <link rel="stylesheet" href="/Arduino/versions/2.3.0/public/css/poole.css"> |
| 20 | + <link rel="stylesheet" href="/Arduino/versions/2.3.0/public/css/syntax.css"> |
| 21 | + <link rel="stylesheet" href="/Arduino/versions/2.3.0/public/css/hyde.css"> |
| 22 | + <link rel="stylesheet" href="/Arduino/versions/2.3.0/public/css/icons.css"> |
| 23 | + <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface"> |
| 24 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> |
| 25 | + <!-- Icons --> |
| 26 | + <link rel="shortcut icon" href="/Arduino/versions/2.3.0/public/favicon.ico"> |
| 27 | + |
| 28 | + <!-- RSS --> |
| 29 | + <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml"> |
| 30 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
| 31 | + <script src="/Arduino/versions/2.3.0/public/js/toc.js"></script> |
| 32 | + <script type="text/javascript"> |
| 33 | + $(document).ready(function() { |
| 34 | + $('#toc').toc({ listType: 'ul', showSpeed: 0, title: '', headers: 'h1, h2', minimumHeaders: 2 }); |
| 35 | + }); |
| 36 | + </script> |
| 37 | +</head> |
| 38 | + |
| 39 | + |
| 40 | + <body> |
| 41 | + |
| 42 | + <div class="version-bar"> |
| 43 | + This documentation is for version 2.3.0. <a href="http://esp8266.github.io/Arduino/versions">Other versions.</a> |
| 44 | +</div> |
| 45 | + |
| 46 | +<div class="sidebar"> |
| 47 | + <div class="container"> |
| 48 | + <div class="sidebar-about"> |
| 49 | + <h2> |
| 50 | + <a href="http://esp8266.github.io/Arduino"> |
| 51 | + ESP8266 Arduino Core |
| 52 | + </a> |
| 53 | + </h2> |
| 54 | + </div> |
| 55 | + |
| 56 | + <nav class="sidebar-nav"> |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/installing.html">Installation</a> |
| 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 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/reference.html">Reference</a> |
| 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 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/libraries.html">Libraries</a> |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/filesystem.html">File System</a> |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/ota_updates/readme.html">OTA Update</a> |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/boards.html">Supported Hardware</a> |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | + |
| 248 | + <a class="sidebar-nav-item" href="/Arduino/versions/2.3.0/doc/changes.html">Change Log</a> |
| 249 | + |
| 250 | + |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + |
| 257 | + |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | + |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | + |
| 275 | + </nav> |
| 276 | + <p> |
| 277 | + <a href="https://github.com/esp8266/Arduino"><div id="gh-icon"></div>esp8266/Arduino</a> |
| 278 | + </p> |
| 279 | + <p class="lead">Documentation for ESP8266 Arduino Core. Installation instructions, functions and classes reference. |
| 280 | +</p> |
| 281 | + </div> |
| 282 | +</div> |
| 283 | + |
| 284 | + |
| 285 | + <div class="content container"> |
| 286 | + <h2 id="table-of-contents">Table of Contents</h2> |
| 287 | + |
| 288 | +<ul> |
| 289 | +<li><a href="#introduction">Introduction</a> |
| 290 | + |
| 291 | +<ul> |
| 292 | +<li><a href="#requirements">Requirements</a></li> |
| 293 | +<li><a href="#Usage">Usage</a></li> |
| 294 | +</ul></li> |
| 295 | +<li><a href="#Informations">Informations</a> |
| 296 | + |
| 297 | +<ul> |
| 298 | +<li><a href="#for-developers">For Developers</a></li> |
| 299 | +</ul></li> |
| 300 | +</ul> |
| 301 | + |
| 302 | +<h2 id="introduction">Introduction</h2> |
| 303 | + |
| 304 | +<p>Since 2.1.0-rc1 the core includes a Debugging feature that is controllable over the IDE menu.</p> |
| 305 | + |
| 306 | +<p>The new menu points manage the real-time Debug messages.</p> |
| 307 | + |
| 308 | +<h3 id="requirements">Requirements</h3> |
| 309 | + |
| 310 | +<p>For usage of the debugging a Serial connection is required (Serial or Serial1).</p> |
| 311 | + |
| 312 | +<p>The Serial Interface need to be initialized in the <code>setup()</code>.</p> |
| 313 | + |
| 314 | +<p>Set the Serial baud rate as high as possible for your Hardware setup.</p> |
| 315 | + |
| 316 | +<p>Minimum sketch to use debugging: |
| 317 | +```cpp |
| 318 | +void setup() { |
| 319 | + Serial.begin(115200); |
| 320 | +}</p> |
| 321 | + |
| 322 | +<p>void loop() { |
| 323 | +} |
| 324 | +```</p> |
| 325 | + |
| 326 | +<h3 id="usage">Usage</h3> |
| 327 | + |
| 328 | +<ol> |
| 329 | +<li><p>Select the Serial interface for the Debugging messages: |
| 330 | +<img src="debug_port.png" alt="Debug-Port"></p></li> |
| 331 | +<li><p>Select which type / level you want debug messages for: |
| 332 | +<img src="debug_level.png" alt="Debug-Level"></p></li> |
| 333 | +<li><p>Check if the Serial interface is initialized in <code>setup()</code> (see <a href="#requirements">Requirements</a>)</p></li> |
| 334 | +<li><p>Flash sketch</p></li> |
| 335 | +<li><p>Check the Serial Output</p></li> |
| 336 | +</ol> |
| 337 | + |
| 338 | +<h2 id="informations">Informations</h2> |
| 339 | + |
| 340 | +<p>It work with every sketch that enables the Serial interface that is selected as debug port.</p> |
| 341 | + |
| 342 | +<p>The Serial interface can still be used normal in the Sketch.</p> |
| 343 | + |
| 344 | +<p>The debug output is additional and will not disable any interface from usage in the sketch.</p> |
| 345 | + |
| 346 | +<h3 id="for-developers">For Developers</h3> |
| 347 | + |
| 348 | +<p>For the debug handling uses defines.</p> |
| 349 | + |
| 350 | +<p>The defined are set by command line.</p> |
| 351 | + |
| 352 | +<h4 id="debug-port">Debug Port</h4> |
| 353 | + |
| 354 | +<p>The port has the define <code>DEBUG_ESP_PORT</code> possible value: |
| 355 | + - Disabled: define not existing |
| 356 | + - Serial: Serial |
| 357 | + - Serial1: Serial1</p> |
| 358 | + |
| 359 | +<h4 id="debug-level">Debug Level</h4> |
| 360 | + |
| 361 | +<p>All defines for the different levels starts with <code>DEBUG_ESP_</code></p> |
| 362 | + |
| 363 | +<p>a full list can be found here in the <a href="https://github.com/esp8266/Arduino/blob/master/boards.txt#L180">boards.txt</a></p> |
| 364 | + |
| 365 | +<h4 id="example-for-own-debug-messages">Example for own debug messages</h4> |
| 366 | + |
| 367 | +<p>The debug messages will be only shown when the Debug Port in the IDE menu is set.</p> |
| 368 | +<div class="highlight"><pre><code class="language-cpp" data-lang="cpp"><span class="cp">#ifdef DEBUG_ESP_PORT</span> |
| 369 | +<span class="cp">#define DEBUG_MSG(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )</span> |
| 370 | +<span class="cp">#else</span> |
| 371 | +<span class="cp">#define DEBUG_MSG(...) </span> |
| 372 | +<span class="cp">#endif</span> |
| 373 | + |
| 374 | +<span class="kt">void</span> <span class="nf">setup</span><span class="p">()</span> <span class="p">{</span> |
| 375 | + <span class="n">Serial</span><span class="p">.</span><span class="n">begin</span><span class="p">(</span><span class="mi">115200</span><span class="p">);</span> |
| 376 | + |
| 377 | + <span class="n">delay</span><span class="p">(</span><span class="mi">3000</span><span class="p">);</span> |
| 378 | + <span class="n">DEBUG_MSG</span><span class="p">(</span><span class="s">"bootup...</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> |
| 379 | +<span class="p">}</span> |
| 380 | + |
| 381 | +<span class="kt">void</span> <span class="nf">loop</span><span class="p">()</span> <span class="p">{</span> |
| 382 | + <span class="n">DEBUG_MSG</span><span class="p">(</span><span class="s">"loop %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">millis</span><span class="p">());</span> |
| 383 | + <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span> |
| 384 | +<span class="p">}</span> |
| 385 | +</code></pre></div> |
| 386 | + </div> |
| 387 | + </body> |
| 388 | +</html> |
0 commit comments