Arduino / ESP32 Logging

.platformio/packages/framework-arduinoespressif32/cores/esp32
esp32-hal-log.h:int log_printf(const char *fmt, ...);
esp32-hal-log.h:#define log_v(format, ...) log_printf(ARDUHAL_LOG_FORMAT(V, format), ##__VA_ARGS__)
esp32-hal-log.h:#define log_d(format, ...) log_printf(ARDUHAL_LOG_FORMAT(D, format), ##__VA_ARGS__)
esp32-hal-log.h:#define log_i(format, ...) log_printf(ARDUHAL_LOG_FORMAT(I, format), ##__VA_ARGS__)
esp32-hal-log.h:#define log_w(format, ...) log_printf(ARDUHAL_LOG_FORMAT(W, format), ##__VA_ARGS__)
esp32-hal-log.h:#define log_e(format, ...) log_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
esp32-hal-uart.c:int log_printf(const char *format, ...)
.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config
--- sdkconfig.h.orig    2017-11-13 14:51:26.776375400 +0100
+++ sdkconfig.h 2017-11-13 14:52:09.400429500 +0100
@@ -58,7 +58,7 @@
 #define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4
 #define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
 #define CONFIG_AUTOSTART_ARDUINO 1
-#define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1
+#define CONFIG_LOG_DEFAULT_LEVEL_VERBOSE 1
 #define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
 #define CONFIG_BTDM_CONTROLLER_RUN_CPU 0
 #define CONFIG_TCPIP_TASK_STACK_SIZE 2560
@@ -71,7 +71,7 @@
 #define CONFIG_BTC_TASK_STACK_SIZE 8192
 #define CONFIG_BLUEDROID_ENABLED 1
 #define CONFIG_ESPTOOLPY_BEFORE "default_reset"
-#define CONFIG_LOG_DEFAULT_LEVEL 1
+#define CONFIG_LOG_DEFAULT_LEVEL 5
 #define CONFIG_TIMER_QUEUE_LENGTH 10
 #define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 0
 #define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
@@ -103,12 +103,12 @@
 #define CONFIG_BROWNOUT_DET 1
 #define CONFIG_ESP32_XTAL_FREQ 0
 #define CONFIG_MONITOR_BAUD_115200B 1
-#define CONFIG_LOG_BOOTLOADER_LEVEL 0
+#define CONFIG_LOG_BOOTLOADER_LEVEL 5
 #define CONFIG_SMP_ENABLE 1
 #define CONFIG_ESPTOOLPY_BEFORE_RESET 1
 #define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
 #define CONFIG_ENABLE_ARDUINO_DEPENDS 1
-#define CONFIG_LOG_BOOTLOADER_LEVEL_NONE 1
+#define CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE 1
 #define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
 #define CONFIG_ESP32_XTAL_FREQ_AUTO 1
 #define CONFIG_TCP_MAXRTX 12

Honor the ESP_LOGx logging macros
Commit: Implement ESP_LOGx override option

An Arduino library for logging to Syslog server in IETF format (RFC 5424) and BSD format (RFC 3164)
Hardware: ESP8266 / ESP32 / Arduino Ethernet / etc.
github.com/arcao/Syslog

Logging library for Arduino, by LunaX – 2010/2011

ESP32 nkolban

Initial commit: 06.09.2017, current HEAD: 25.10.2017
github.com/espressif/esp-idf/components/pthread/pthread.c (History)

Initial commit: 15.11.2016, current HEAD: 12.09.2017
github.com/espressif/esp-idf/components/bt/bluedroid/api/include/esp_gatt_defs.h (History)

Commit: cxx: Add KConfig option for C++ exceptions, disable by default

Add missing support for C++ exceptions #681
[TW#12147] Unable to switch on C++ exception handling -fexceptions #459
IROM_ALIGN AssertionError when using fexceptions #188 (duplicate)

github nkolban

HttpServer.cpp compilation error

github cmmakerclub

github.com/cmmakerclub/esp32-webserver/

PlatformIO

ESP32 BLE Arduino by Neil Kolban
github.com/platformio/platform-espressif32/issues

ESP-IDF:
/c/Users/bachman0/.platformio/packages/framework-espidf/components/esp32/ld/esp32.common.ld

Arduino:
/c/Users/bachman0/.platformio/packages/framework-arduinoespressif32/tools/sdk/ld/esp32.common.ld

$ grep -r tcpip_adapter_init .
./libraries/WiFi/src/WiFiGeneric.cpp:        tcpip_adapter_init();
./tools/sdk/include/tcpip_adapter/tcpip_adapter.h: * tcpip_adapter_init should be called in the start of app_main for only once.
./tools/sdk/include/tcpip_adapter/tcpip_adapter.h:void tcpip_adapter_init(void);
Übereinstimmungen in Binärdatei ./tools/sdk/lib/libtcpip_adapter.a

Arduino Timer

TimerOne & TimerThree Libraries
github.com/PaulStoffregen/TimerOne, TimerOne Library with optimization and expanded hardware support
github.com/PaulStoffregen/TimerThree, TimerThree Library with optimization and expanded hardware support
playground.arduino.cc/Code/Timer1 (alt?!)

Timer, Counter und Interrupts

World of Timers

Ein Arduino weist nicht nur einen einzelnen Timer sondern mehrere Timer auf. Kein Wunder, sind Timer doch essenzielle Grundkomponenten für verschiedene Aufgaben eines Mikrocontrollers.

  • Timer 0 ( 8 Bit) Verwendet für Funktionen wie delay(), millis(), micros()
  • Timer 1 ( 16 Bit) Verwendet von der Servo-Bibliothek
  • Timer 2 ( 8 Bit) Verwendet von der Tone-Bibliothek
  • Timer 3 (16 Bit) Nur Mega
  • Timer 4 (16 Bit) Nur Mega
  • Timer 5 (16 Bit) Nur Mega

Die genannten Timer finden auch für die Umsetzung von “Pulse Width Modulation” Verwendung, wobei folgende Zuordnung herrscht.

Beim Arduino:

  • PWM Pins 5 und 6 kontrolliert durch Timer 0
  • PWM Pins 9 und 10 kontrolliert durch Timer 1
  • PWM Pins 3 und 11 kontrolliert durch Timer 2

Transistor / BJT / MOSFET

  • Junction Field Effect Transistor (JFET)
  • Insulated Gate Field Effect Transistor (IGFET)

Bipolarer Transistor (BJT)

Der Bipolartransistor
Der NPN-Transistoren
Der PNP-Transistoren
Transistors als Schalter
Transistoren
Transistors

Feldeffekttransistor (FET), Sperrschicht-Feldeffekttransistor (JFET)

Der Feldeffekttransistor

MOSFET

MOSFET
MOSFET als Schalter
MOSFET as a Switch
HowTo MOSFETs: Auswählen & Anschließen erklärt
Schaltregler-Bauteile, Leistungs-MOSFET, Speicherspule
N-Kanal MOSFETs

Arduino/AVR Atomic Instruction / Mutex / Semaphore

Arduino\hardware\arduino\avr\cores\arduino\Arduino.h
sei()  ==> interrupts()
cli()  ==> noInterrupts()

oder über das Macro:

ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
  // Do some atomic operation inside here
}

avr-libc

avr/interrupt.h: Interrupts
util/atomic.h: Atomically and Non-Atomically Executed Code Blocks

Arduino

attachInterrupt()
noInterrupts()
interrupts()
ow to “Multithread” an Arduino (Protothreading Tutorial)

Portable

github.com/wizard97/SimplyAtomic: Simple Arduino portable atomic macros (Portable: AVR, ARM, ESP8266, ESP32)

learn.adafruit.com

Multi-tasking the Arduino – Part 1
Multi-tasking the Arduino – Part 2
Multi-tasking the Arduino – Part 3

Questions

Do interrupts interrupt other interrupts on Arduino?

occam-pi

occam-pi in a nutshell
occam (programming language), concurrent programming language that builds on the communicating sequential processes (CSP) process algebra
concurrency.cc – Parallel programming for the rest of us

KiCAD Python Console

cd /c/Users/bachman0/Documents/ZHAW_Module/PA/kicad/python/svg2mod
python svg2mod.py -i ../../images/PA17_bmat_6_V1.svg -o test1 --format pretty
Parsing SVG...
No handler for element {http://www.w3.org/2000/svg}defs
No handler for element {http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}namedview
No handler for element {http://www.w3.org/2000/svg}metadata
transform: translate [0.0, -295.7]
transform: translate [-2.0552455, 280.43471]
Writing module file: test1.kicad_mod

sys.path.append('');
os.chdir('');

sys.argv = ['arg1', 'arg2']
execfile('');

subprocess.call(['./abc.py', arg1, arg2])

# 
execfile('C:\Users\bachman0\Documents\ZHAW_Module\PA\kicad\python\test1.py')
# Traceback (most recent call last):
#   File "<input>", line 1, in <module>
# IOError: [Errno 2] No such file or directory: 'C:\\Users\x08achman0\\Documents\\ZHAW_Module\\PA\\kicad\\python\test1.py'

execfile('C:Users/bachman0/Documents/ZHAW_Module/PA/kicad/python/test1.py')
# Traceback (most recent call last):
#   File "<input>", line 1, in <module>
# IOError: [Errno 2] No such file or directory: 'C:Users/bachman0/Documents/ZHAW_Module/PA/kicad/python/test1.py'

print sys.path
# ['C:\\Program Files\\KiCad\\lib\\python27.zip', 'C:\\Program Files\\KiCad\\lib\\python2.7', 'C:\\Program Files\\KiCad\\lib\\python2.7\\plat-win32', 'C:\\Program
# Files\\KiCad\\lib\\python2.7\\lib-tk', 'C:\\Program Files\\KiCad\\lib\\python2.7\\lib-old', 'C:\\Program Files\\KiCad\\lib\\python2.7\\lib-dynload', 'C:\\building
# \\msys64\\mingw64', 'C:\\Program Files\\KiCad\\lib\\python2.7\\site-packages', 'C:\\Program Files\\KiCad\\lib\\python2.7\\site-packages\\wx-3.0-msw', '.', 
# 'C:/Program Files/KiCad/bin/../share/kicad/scripting/plugins']

execfile('C:/Users/bachman0/Documents/ZHAW_Module/PA/kicad/python/test1.py')
# 0 F.Cu
# [...]

# ex.

import sys
sys.path.append("/home/user/path/to/kicad-python/")
execfile("/home/user/path/to/kicad-python/examples/pcbannotate.py")

os.chdir('C:/Users/bachman0/Documents/ZHAW_Module/PA/kicad/python/svg2mod/')
execfile('svg2mod.py')

subprocess.call(['svg2mod.py', '-h'])
# Traceback (most recent call last):
#   File "<input>", line 1, in <module>
#   File "C:\Program Files\KiCad\lib\python2.7/subprocess.py", line 169, in call
#     return Popen(*popenargs, **kwargs).wait()
#   File "C:\Program Files\KiCad\lib\python2.7/subprocess.py", line 321, in __init__
#     errread, errwrite)
#   File "C:\Program Files\KiCad\lib\python2.7/subprocess.py", line 571, in _execute_child
#     startupinfo)
# WindowsError: [Error 193] %1 ist keine zulässige Win32-Anwendung

print sys.executable
# C:/Program Files/KiCad/bin/kicad.exe

subprocess.call([sys.executable, 'svg2mod.py', '-h'])
# not a good idea

subprocess.call(['python', 'svg2mod.py', '-h'])
# not a good idea

KiCad PCB EDA Suite – Python Plugin Development for Pcbnew

Welcome to KiCad Python API’s documentation!

KiCAD on OS X – How to use python scripts? [solved]

Kicad Scripting Table of Contents
The basics of scripting in pcbnew
modifying pcbnew layout from python

Scripts

github.com/KiCad/kicad-library-utils: KiCad utilities
PCB back annotation in KiCAD with Python