diff --git a/.gitignore b/.gitignore index ccc8fe3..2a125ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +# IDE stuff +control/src/.idea +control/src/cmake-build-debug +control/.Makefile.swp +control/src/CMakeLists.txt + # Prerequisites *.d gnuplotscript.gp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c938911 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Tristan Krause + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ef5f130..2f0f2b5 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ # B15F - Board 15 Famulus Edition +**Hinweis:** +Die Projekt-Dokumentation befindet sich unter [github pages](https://devfix.github.io/b15f/). + ## TODO / Ideen - [X] CLI: Exception catchen, set global error message, raise SIGINT --> ncurses wird richtig beendet - [ ] Monitor: Refresh visualisieren, z.B. - / - \ | - [ ] Main Menu: Informationen ergänzen - [X] Selbsttest bei discard richtig beenden (momentan wird wahrscheinlich WDT angeschmissen, besser global bool für selbsttest-loop) -- [ ] Lizenz -- [ ] gitignore checken -- [ ] readme schreiben +- [x] Lizenz +- [x] gitignore checken +- [x] readme schreiben - [ ] CLI: Farbe? - [ ] globale strings / msg klasse für treiber, ui (z.B. B15F info) - [ ] drv: requests als array organisieren diff --git a/control/.Makefile.swp b/control/.Makefile.swp deleted file mode 100644 index 2f14c9c..0000000 Binary files a/control/.Makefile.swp and /dev/null differ diff --git a/control/examples/main.cpp b/control/examples/main.cpp deleted file mode 100644 index b121dd3..0000000 --- a/control/examples/main.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include "drv/b15f.h" -#include "drv/plottyfile.h" - - -void kennlinieErsterQuadrant() -{ - - B15F& drv = B15F::getInstance(); - PlottyFile pf; - - uint16_t ba[1024]; - uint16_t bb[1024]; - - const uint16_t sample_count = 1024; - const uint16_t delta = 1; - - const uint16_t u_gs_start = 440; - const uint16_t u_gs_delta = 20; - const uint16_t u_gs_end = 600; - - pf.setUnitX("V"); - pf.setUnitY("mA"); - pf.setUnitPara("V"); - pf.setDescX("U_{DS}"); - pf.setDescY("I_D"); - pf.setDescPara("U_{GS}"); - pf.setRefX(5); - pf.setRefY(50); - pf.setParaFirstCurve(u_gs_start); - pf.setParaStepWidth(u_gs_delta); - - uint8_t curve = 0; - - std::cout << "Erfasse Kennlinie erster Quadrant..." << std::endl << std::flush; - - for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) - { - drv.analogWrite1(u_gs); - - drv.analogSequence(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count); - - for(uint16_t k = 0; k < sample_count; k++) - { - uint16_t i_d = ba[k] - bb[k]; - uint16_t u_ds = bb[k]; - pf.addDot(Dot(u_ds, i_d, curve)); - } - - std::cout << "\033[1K\r" << 1e2 * (u_gs - u_gs_start) / (u_gs_end - u_gs_start) << "%" << std::flush; - - curve++; - } - - std::cout << "\033[1K\r" << std::flush; - - // speichern und plotty starten - pf.writeToFile("test_plot"); - pf.startPlotty("test_plot"); -} - -void kennlinieZweiterQuadrant() -{ - B15F& drv = B15F::getInstance(); - PlottyFile pf; - - uint16_t ba[1024]; - uint16_t bb[1024]; - - const uint16_t sample_count = 1024; - const uint16_t delta = 1; - - const uint16_t u_gs_start = 300; - const uint16_t u_gs_delta = 25; - const uint16_t u_gs_end = 700; - - pf.setQuadrant(2); - pf.setUnitX("V"); - pf.setUnitY("mA"); - pf.setUnitPara("V"); - pf.setDescX("U_{GS}"); - pf.setDescY("I_D"); - pf.setDescPara("U_{DS}"); - pf.setRefX(5); - pf.setRefY(50); - pf.setParaFirstCurve(u_gs_start); - pf.setParaStepWidth(u_gs_delta); - - uint8_t curve = 0; - - std::cout << "Erfasse Kennlinie zweiter Quadrant..." << std::endl << std::flush; - - for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) - { - drv.analogWrite1(u_gs); - - drv.analogSequence(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count); - - curve = 0; - for(uint16_t k = 0; k < sample_count; k++) - { - if(ba[k] > bb[k] && bb[k] % 50 == 0 && bb[k] != 0) - { - uint16_t i_d = ba[k] - bb[k]; - pf.addDot(Dot(u_gs, i_d, bb[k] / 50)); - } - curve++; - } - - std::cout << "\033[1K\r" << 1e2 * (u_gs - u_gs_start) / (u_gs_end - u_gs_start) << "%" << std::flush; - } - - std::cout << "\033[1K\r" << std::flush; - - // speichern und plotty starten - pf.writeToFile("test_plot"); - pf.startPlotty("test_plot"); -} - -void testFunktionen() -{ - B15F& drv = B15F::getInstance(); - - std::cout << "DIP-Switch: " << (int) drv.readDipSwitch() << std::endl; - - - drv.digitalWrite0(0xFF); - drv.analogWrite0(128); - std::cout << (int) drv.digitalRead0() << std::endl;; - std::cout << "adc: " << (int) drv.analogRead(4) << std::endl; - - drv.digitalWrite0(0x00); - drv.analogWrite0(0); - std::cout << (int) drv.digitalRead0() << std::endl;; - std::cout << "adc: " << (int) drv.analogRead(4) << std::endl; - - drv.digitalWrite0(0xFF); - drv.analogWrite0(255); - std::cout << (int) drv.digitalRead0() << std::endl; - std::cout << "adc: " << (int) drv.analogRead(4) << std::endl; - - - std::cout << "Kennlinie..." << std::endl; - uint16_t a[1024]; - uint16_t b[1024]; - drv.analogSequence(0, &a[0], 0, 1, &b[0], 0, 0, 1, 1024); - - /*for(uint16_t i= 0; i < sizeof(a) / sizeof(uint16_t); i++) - { - std::cout << (int) i << " : " << a[i] << " " << b[i] << std::endl; - }*/ - -} - -int main() -{ - //testFunktionen(); - //kennlinieZweiterQuadrant(); - - B15F& drv = B15F::getInstance(); - while(1) - { - //uint8_t be0 = drv.digitalRead0(); - //uint8_t be1 = drv.digitalRead1(); - //uint8_t dsw = drv.readDipSwitch(); - drv.analogRead(0); - drv.analogRead(1); - drv.analogRead(2); - drv.analogRead(3); - drv.analogRead(4); - drv.analogRead(5); - drv.analogRead(6); - drv.analogRead(7); - } - - std::cout << "Schluss." << std::endl; -} diff --git a/control/examples/pegel/main.cpp b/control/examples/pegel/main.cpp index 2487217..e216b02 100644 --- a/control/examples/pegel/main.cpp +++ b/control/examples/pegel/main.cpp @@ -3,6 +3,11 @@ #include #include +/* + * Inkrementiert DAC 0 von 0 bis 1023 und speichert zu jeder Ausgabe den Wert von ADC 0 in einem Puffer. + * Die Funktion ADC 0 abhängig von DAC 0 wird als Graph geplottet. + */ + const char PLOT_FILE[] = "plot.bin"; int main() @@ -13,8 +18,9 @@ int main() uint16_t buf[1024]; - const uint16_t sample_count = 1024; + const uint16_t count = 1024; const uint16_t delta = 1; + const uint16_t start = 0; pf.setUnitX("V"); pf.setUnitY("V"); @@ -27,18 +33,17 @@ int main() pf.setParaFirstCurve(0); pf.setParaStepWidth(0); - uint8_t curve = 0; - + const uint8_t curve = 0; - drv.analogSequence(0, &buf[0], 0, 1, nullptr, 0, 0, delta, sample_count); + drv.analogSequence(0, &buf[0], 0, 1, nullptr, 0, start, delta, count); - for(uint16_t x = 0; x < sample_count * delta; x += delta) + for(uint16_t x = 0; x < count; x++) { std::cout << x << " - " << buf[x] << std::endl; pf.addDot(Dot(x, buf[x], curve)); } // speichern und plotty starten - pf.writeToFile(PLOT_FILE); + pf.writeToFile(PLOT_FILE); pf.startPlotty(PLOT_FILE); } diff --git a/control/examples/pwm/Makefile b/control/examples/pwm/Makefile new file mode 100644 index 0000000..8000d6e --- /dev/null +++ b/control/examples/pwm/Makefile @@ -0,0 +1,30 @@ +# Name: Makefile +# Project: B15F (board15 Famulus Edition) +# Author: Tristan Krause +# Creation Date: 2019-05-15 + +# Environment +COMPILER_PATH = g++ + +# Options +CFLAGS = -std=c++17 -O3 -Wall -Wextra +LDFLAGS = -lb15fdrv +OBJECTS = main.o +OUT = main.elf + +COMPILE = $(COMPILER_PATH) $(CFLAGS) + +main: $(OBJECTS) + $(COMPILE) $(OBJECTS) -o $(OUT) $(LDFLAGS) + +help: + @echo "This Makefile has the following targets:" + @echo "make main .... to compile" + @echo "make clean ... to delete objects and executables" + +clean: + @echo "Cleaning..." + rm -f $(OBJECTS) $(OUT) *.bin gnuplotscript.gp + +.cpp.o: + $(COMPILE) -c $< -o $@ diff --git a/control/examples/pwm/main.cpp b/control/examples/pwm/main.cpp new file mode 100644 index 0000000..349ccab --- /dev/null +++ b/control/examples/pwm/main.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +/* + * Erzeugt ein PWM Signal an PB4 mit 100KHz. + * Beste Frequenz: 31300 + */ +int main() +{ + + B15F& drv = B15F::getInstance(); + std::cout << "TOP: " << (int) drv.pwmSetFrequency(31300) << std::endl; + drv.pwmSetValue(127); +} diff --git a/control/examples/register/Makefile b/control/examples/register/Makefile new file mode 100644 index 0000000..8000d6e --- /dev/null +++ b/control/examples/register/Makefile @@ -0,0 +1,30 @@ +# Name: Makefile +# Project: B15F (board15 Famulus Edition) +# Author: Tristan Krause +# Creation Date: 2019-05-15 + +# Environment +COMPILER_PATH = g++ + +# Options +CFLAGS = -std=c++17 -O3 -Wall -Wextra +LDFLAGS = -lb15fdrv +OBJECTS = main.o +OUT = main.elf + +COMPILE = $(COMPILER_PATH) $(CFLAGS) + +main: $(OBJECTS) + $(COMPILE) $(OBJECTS) -o $(OUT) $(LDFLAGS) + +help: + @echo "This Makefile has the following targets:" + @echo "make main .... to compile" + @echo "make clean ... to delete objects and executables" + +clean: + @echo "Cleaning..." + rm -f $(OBJECTS) $(OUT) *.bin gnuplotscript.gp + +.cpp.o: + $(COMPILE) -c $< -o $@ diff --git a/control/examples/register/main.cpp b/control/examples/register/main.cpp new file mode 100644 index 0000000..b90fe5f --- /dev/null +++ b/control/examples/register/main.cpp @@ -0,0 +1,30 @@ +#include +#include + +/* + * Dieses Beispiel erzeugt einen 300ms langen Impuls an PB0. + * + */ +int main() +{ + uint8_t tmp; + B15F& drv = B15F::getInstance(); + + + tmp = drv.getRegister(&DDRB); + tmp |= (1<<0); + drv.setRegister(&DDRB, tmp); + + + tmp = drv.getRegister(&PORTB); + tmp |= (1<<0); + drv.setRegister(&PORTB, tmp); + + + drv.delay_ms(300); + + + tmp = drv.getRegister(&PORTB); + tmp &= ~(1<<0); + drv.setRegister(&PORTB, tmp); +} diff --git a/control/examples/transistor/Makefile b/control/examples/transistor/Makefile new file mode 100644 index 0000000..8000d6e --- /dev/null +++ b/control/examples/transistor/Makefile @@ -0,0 +1,30 @@ +# Name: Makefile +# Project: B15F (board15 Famulus Edition) +# Author: Tristan Krause +# Creation Date: 2019-05-15 + +# Environment +COMPILER_PATH = g++ + +# Options +CFLAGS = -std=c++17 -O3 -Wall -Wextra +LDFLAGS = -lb15fdrv +OBJECTS = main.o +OUT = main.elf + +COMPILE = $(COMPILER_PATH) $(CFLAGS) + +main: $(OBJECTS) + $(COMPILE) $(OBJECTS) -o $(OUT) $(LDFLAGS) + +help: + @echo "This Makefile has the following targets:" + @echo "make main .... to compile" + @echo "make clean ... to delete objects and executables" + +clean: + @echo "Cleaning..." + rm -f $(OBJECTS) $(OUT) *.bin gnuplotscript.gp + +.cpp.o: + $(COMPILE) -c $< -o $@ diff --git a/control/examples/transistor/main.cpp b/control/examples/transistor/main.cpp new file mode 100644 index 0000000..cdfc5c2 --- /dev/null +++ b/control/examples/transistor/main.cpp @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#include + +const char PLOT_FILE[] = "plot.bin"; + +void printProgress(double p) +{ + constexpr double precision = 1e1; + constexpr int width = 20; + const int n = round(width * p); + p = round(1e2 * precision * p) / precision; + std::cout << "\033[1K\r"; + std::cout << "[" << std::string(n, '#') << std::string(width - n, '-') << "] "; + std::cout << std::setfill(' ') << std::setw(5) << std::fixed << std::showpoint << std::setprecision(1) << p << "%" << std::flush; +} + +void kennlinieErsterQuadrant() +{ + // Puffer für Messwerte + uint16_t u_out[1024]; + uint16_t u_drain[1024]; + + // Ansteuerung der U_GS, Anzahl der Werte für U_GS muss kleiner 64 sein, + // da sonst zu großer Kurvenindex entsteht + const uint16_t u_gs_start = 200; + const uint16_t u_gs_delta = 50; + const uint16_t u_gs_end = 600; + + // Ansteuerung durch u_out (ruft Drainstrom i_drain hervor) + const uint16_t seq_start = 0; + const uint16_t seq_delta = 1; + const uint16_t seq_sample_count = 1024; + + B15F& drv = B15F::getInstance(); + PlottyFile pf; + + pf.setUnitX("V"); + pf.setUnitY("mA"); + pf.setUnitPara("V"); + pf.setDescX("U_{DS}"); + pf.setDescY("I_D"); + pf.setDescPara("U_{GS}"); + pf.setRefX(5); + pf.setRefY(50); + pf.setParaFirstCurve(u_gs_start); + pf.setParaStepWidth(u_gs_delta); + + uint8_t curve = 0; + + std::cout << "Erfasse Kennlinie erster Quadrant..." << std::endl; + + for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) + { + drv.analogWrite1(u_gs); + + // Erfasse u_out und u_drain und variiere dabei u_out, die aktuelle U_GS bleibt solange konstant + drv.analogSequence(0, &u_out[0], 0, 1, &u_drain[0], 0, seq_start, seq_delta, seq_sample_count); + + for(uint16_t k = 0; k < seq_sample_count; k++) + { + uint16_t i_drain = u_out[k] - u_drain[k]; + pf.addDot(Dot(u_drain[k], i_drain, curve)); + } + + curve++; + + // Fortschrittsanzeige + printProgress(double(u_gs - u_gs_start) / double(u_gs_end - u_gs_start)); + } + + std::cout << std::endl << std::flush; + + // speichern und plotty starten + pf.writeToFile(PLOT_FILE); + pf.startPlotty(PLOT_FILE); +} + +void kennlinieZweiterQuadrant() +{ + constexpr uint8_t resolution = 50; + + // Puffer für Messwerte + uint16_t u_out[1024]; + uint16_t u_drain[1024]; + + // Ansteuerung der U_GS + const uint16_t u_gs_start = 128; + const uint16_t u_gs_delta = 32; + const uint16_t u_gs_end = 512; + + // Ansteuerung druch u_out (ruft Drainstrom i_drain hervor) + const uint16_t seq_start = 0; + const uint16_t seq_delta = 1; + const uint16_t seq_sample_count = 1024; + + B15F& drv = B15F::getInstance(); + PlottyFile pf; + + pf.setQuadrant(2); + pf.setUnitX("V"); + pf.setUnitY("mA"); + pf.setUnitPara("V"); + pf.setDescX("U_{GS}"); + pf.setDescY("I_D"); + pf.setDescPara("U_{DS}"); + pf.setRefX(5); + pf.setRefY(50); + pf.setParaFirstCurve(u_gs_start); + pf.setParaStepWidth(u_gs_delta); + + uint8_t curve; + + std::cout << "Erfasse Kennlinie zweiter Quadrant..." << std::endl; + + for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) + { + drv.analogWrite1(u_gs); + + // Erfasse u_out und u_drain und variiere dabei u_out, die aktuelle U_GS bleibt solange konstant + drv.analogSequence(0, &u_out[0], 0, 1, &u_drain[0], 0, seq_start, seq_delta, seq_sample_count); + + curve = 0; + for(uint16_t k = 0; k < seq_sample_count; k++) + { + // Speichere nur Werte für i_drain, wo u_drain ein Vielfaches der Auflösung ist + if(u_out[k] > u_drain[k] && u_drain[k] % resolution == 0 && u_drain[k] != 0) + { + uint16_t i_drain = u_out[k] - u_drain[k]; + pf.addDot(Dot(u_gs, i_drain, u_drain[k] / resolution)); + } + curve++; + } + + // Fortschrittsanzeige + printProgress(double(u_gs - u_gs_start) / double(u_gs_end - u_gs_start)); + } + + std::cout << std::endl << std::flush; + + // speichern und plotty starten + pf.writeToFile(PLOT_FILE); + pf.startPlotty(PLOT_FILE); +} + +int main() +{ + kennlinieErsterQuadrant(); + kennlinieZweiterQuadrant(); +} diff --git a/control/src/Makefile b/control/src/Makefile index 4f40fa5..4a22456 100644 --- a/control/src/Makefile +++ b/control/src/Makefile @@ -18,7 +18,7 @@ PATH_TMP_LIB = ../lib/ # outputs OUT_TMP_DRV = $(PATH_TMP_LIB)/libb15fdrv.so -OUT_TMP_CLI = $(PATH_TMP_BIN)/cli.elf +OUT_TMP_CLI = $(PATH_TMP_BIN)/b15fcli OUT_TMP_PLOTTY = $(PATH_TMP_BIN)/plotty OUT_DRV = $(PATH_LIB)/libb15fdrv.so OUT_CLI = $(PATH_BIN)/b15fcli @@ -38,7 +38,9 @@ OBJECTS_CLI = cli.o ui/view.o ui/view_selection.o ui/view_promt.o ui/view_info # *** TARGETS *** -all: drv cli doc +.PHONY: $(OUT_TMP_DRV) clean help + +all: drv cli style drv: $(OBJECTS_DRV) $(OUT_TMP_DRV) @@ -50,8 +52,13 @@ cli: drv $(OBJECTS_CLI) @bash -c 'if [ ! -f "$(OUT_DRV)" ]; then echo -e "\n*** Warning ***: driver not installed\nType \"sudo make install\" to install or update b15fdrv."; fi' doc: - @echo "Creating documentation with doxygen.." + @echo "Creating documentation with doxygen..." $(PATH_DOXYGEN) doxygen-cfg + @echo problems found: `($(PATH_DOXYGEN) doxygen-cfg 3>&2 2>&1 1>&3) 2>/dev/null | wc -l` + +style: + @echo "Formatting source code with astyle..." + astyle --recursive --style=allman *.cpp,*.h,*.c,*.hpp install: @echo "Installing driver..." @@ -61,9 +68,9 @@ install: cp $(OUT_TMP_PLOTTY) $(OUT_PLOTTY) cp drv/*.h $(PATH_INCLUDE) -uninstall: clean +uninstall: @echo "Uninstalling driver..." - rm -rf $(PATH_INCLUDE) $(OUT_DRV) $(OUT_CLI) $(OUT_PLOTTY) + rm -rf $(OUT_DRV) $(OUT_CLI) $(OUT_PLOTTY) $(PATH_INCLUDE) help: @echo "This Makefile compiles the b15f driver lib and command line interface (CLI):" @@ -73,11 +80,12 @@ help: @echo "make install . to install or update the lib and headers on this machine" @echo "make uninstall to remove the lib and headers on this machine" @echo "make clean ... to delete objects and executables" - + clean: @echo "Cleaning..." rm -f $(OBJECTS_DRV) $(OBJECTS_CLI) $(OUT_TMP_CLI) $(OUT_TMP_DRV) rm -rf $(OUT_DOC) + find . -type f -name '*.orig' -delete .cpp.o: $(PATH_COMPILER) $(CFLAGS) -c $< -o $@ diff --git a/control/src/README.md b/control/src/README.md index 99a8a8d..04983b8 100644 --- a/control/src/README.md +++ b/control/src/README.md @@ -1,3 +1,94 @@ -# Einführung -Die wichtigste Klasse für die Steuerung des Board 15 ist [B15F](classB15F.html). -Dort befindet sich auch eine Übersicht der verfügbaren Befehle. +# B15F Benutzerhandbuch +*Hinweis*: Terminal-Befehle sind **fett** gedruckt + +## Installation + +### 1. Abhängigkeiten installieren + (a) **sudo apt-get update** + (b) **sudo apt-get install git avr-libc avrdude libncurses5-dev g++** + +### 2. Das Repository klonen + (a) **cd /home/famulus/** + (b) **git clone "https://github.com/devfix/b15f.git"** + +### 3. Die Firmware installieren + (a) **cd "/home/famulus/b15f/firmware"** + + (b) Passen Sie in der Datei *Makefile* die Option "MCU = ..." an die MCU des vorliegenden Boards an + (*atmega1284* und *atmega1284p* sind nicht identisch!) + + (c) **make** + + Wenn udev richtig konfiguriert wurde: + (d I) **make upload** + Sonst: + (d II) **sudo make upload** + +### 4. Die Steuersoftware (Bibliothek & CLI) installieren + (a) **cd "/home/famulus/b15f/control/src"** + (b) **make** + (Die Warnungen durch doxygen können ignoriert werden.) + + (c) **sudo make install** + +## Aktualisierung + (a) **cd /home/famulus/b15f/** + (b) **git pull --prune** + (c) **cd "/home/famulus/b15f/firmware"** + (d) **make clean** + (e) **cd "/home/famulus/b15f/control/src"** + (f) **make clean** + (g) Installation ab Schritt 3 wiederholen + +## Das CommandLineInterface (CLI) benutzen + (a) Öffnen Sie ein Terminal und maximieren Sie das Fenster + (b) Start des CLI erfolgt durch **b15fcli** + (c) Die Navigation erfolgt durch <Tab>, die Pfeiltasten und <Enter> oder die Maus + (d) Mit <Strg + c> kann das Programm sofort verlassen werden + +## Eigene Programme mit B15F schreiben + +### Grundsätzliches +Die wichtigste Klasse für die Steuerung des Board 15 ist [B15F](https://devfix.github.io/b15f/html/classB15F.html). +Dort befindet sich auch eine Übersicht der verfügbaren Befehle. + +### Beispiele +In dem Verzeichnis [b15f/control/examples](https://github.com/devfix/b15f/tree/master/control/examples) sind einige Beispiele für die Verwendung einzelner B15F Funktionen. +Zu jedem Beispiel gehört eine *main.cpp* mit dem Quellcode und eine *Makefile*-Datei. +Das Beispiel kann mit **make** kompiliert und mit **./main.elf** gestartet werden. + +### Den B15F Treiber verwenden +Benötigt wird der B15F-Header: +`#include ` +und der Header für die plottyfile-Generierung, falls mit Kennlinien gearbeitet werden soll: +`#include ` + +Für die Interaktion wird eine Referenz auf die aktuelle Treiberinstanz gespeichert: +`B15F& drv = B15F::getInstance();` +Falls noch keine existiert, wird automatisch eine erzeugt und Verbindung zum Board hergestellt. + +Ab jetzt können auf dem Object `drv` verschiedene Methoden angewand werden, siehe [B15F](https://devfix.github.io/b15f/html/classB15F.html). + +### Kennlinien mit plottyfile generieren +Die Beschreibung zu Plottyfile befindet sich [hier](https://devfix.github.io/b15f/html/classPlottyFile.html). +Nach dem Include von plottyfile kann ein neues Objekt erzeugt und konfiguriert werden: +```C++ +PlottyFile pf; +pf.setUnitX("V"); +pf.setUnitY("V"); +pf.setUnitPara("V"); +pf.setDescX("U_{OUT}"); +pf.setDescY("U_{IN}"); +pf.setDescPara(""); +pf.setRefX(5); +pf.setRefY(5); +pf.setParaFirstCurve(0); +pf.setParaStepWidth(0); +``` +Messpunkte können anschließend hinzugefügt werden. +Dabei gehören Punkte mit dem gleichen Index für `curve` (*uint8_t*) zur selben Kurve und erhalten durch Plotty automatisch die gleiche Farbe. +```C++ +pf.addDot(Dot(x, y, curve)); +``` +`x` und `y` sind *uint16_t*, also keine Gleitkommazahlen. + diff --git a/control/src/cli.cpp b/control/src/cli.cpp index aa57de7..6abc7a2 100644 --- a/control/src/cli.cpp +++ b/control/src/cli.cpp @@ -1,4 +1,4 @@ -#define B15F_CLI_DEBUG +//#define B15F_CLI_DEBUG #include #include // sudo apt-get install libncurses5-dev @@ -24,91 +24,92 @@ volatile bool t_refresh_active = false; void signal_handler(int signal) { - if(signal == SIGWINCH) - { - win_changed_cooldown = 10; // 100ms - - if (!t_refresh_active) - { - if(t_refresh.joinable()) - t_refresh.join(); - t_refresh_active = true; - t_refresh = std::thread([](){ - - while(win_changed_cooldown--) - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - - t_refresh_active = false; - - if(win_stack.size()) - win_stack.back()->repaint(); - - }); - } - - } - else if(signal == SIGINT) - { - cleanup(); - std::cout << "SIGINT - Abbruch." << std::endl; - exit(EXIT_FAILURE); - } + if(signal == SIGWINCH) + { + win_changed_cooldown = 10; // 100ms + + if (!t_refresh_active) + { + if(t_refresh.joinable()) + t_refresh.join(); + t_refresh_active = true; + t_refresh = std::thread([]() + { + + while(win_changed_cooldown--) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + t_refresh_active = false; + + if(win_stack.size()) + win_stack.back()->repaint(); + + }); + } + + } + else if(signal == SIGINT) + { + cleanup(); + std::cout << "SIGINT - Abbruch." << std::endl; + exit(EXIT_FAILURE); + } } void abort_handler(std::exception& ex) { - ViewInfo* view = new ViewInfo(); - view->setTitle("Fehler"); - std::string msg(ex.what()); - msg += "\n\nBeende in 5 Sekunden."; - view->setText(msg.c_str()); - view->setLabelClose(""); - view->repaint(); - - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - - cleanup(); - std::cerr << std::endl << "*** EXCEPTION ***" << std::endl << ex.what() << std::endl; - exit(EXIT_FAILURE); + ViewInfo* view = new ViewInfo(); + view->setTitle("Fehler"); + std::string msg(ex.what()); + msg += "\n\nBeende in 5 Sekunden."; + view->setText(msg.c_str()); + view->setLabelClose(""); + view->repaint(); + + std::this_thread::sleep_for(std::chrono::milliseconds(5000)); + + cleanup(); + std::cerr << std::endl << "*** EXCEPTION ***" << std::endl << ex.what() << std::endl; + exit(EXIT_FAILURE); } void init() { - // init b15 driver - B15F::getInstance(); + // init b15 driver + B15F::getInstance(); #ifndef B15F_CLI_DEBUG - std::cout << std::endl << "Starte in 3s ..." << std::endl; - sleep(3); + std::cout << std::endl << "Starte in 3s ..." << std::endl; + sleep(3); #endif - B15F::setAbortHandler(&abort_handler); - - // init all ncurses stuff - initscr(); - start_color(); - curs_set(0); // 0: invisible, 1: normal, 2: very visible - clear(); - noecho(); - cbreak(); // Line buffering disabled. pass on everything - mousemask(ALL_MOUSE_EVENTS, NULL); - - // connect signals to handler - signal(SIGWINCH, signal_handler); - signal(SIGINT, signal_handler); - - // set view context - View::setWinContext(newwin(25, 85, 0, 0)); + B15F::setAbortHandler(&abort_handler); + + // init all ncurses stuff + initscr(); + start_color(); + curs_set(0); // 0: invisible, 1: normal, 2: very visible + clear(); + noecho(); + cbreak(); // Line buffering disabled. pass on everything + mousemask(ALL_MOUSE_EVENTS, NULL); + + // connect signals to handler + signal(SIGWINCH, signal_handler); + signal(SIGINT, signal_handler); + + // set view context + View::setWinContext(newwin(25, 85, 0, 0)); } int main() { - init(); - - int exit_code = EXIT_SUCCESS; - - show_main(0); - - cleanup(); - - return exit_code; + init(); + + int exit_code = EXIT_SUCCESS; + + show_main(0); + + cleanup(); + + return exit_code; } diff --git a/control/src/doxygen-cfg b/control/src/doxygen-cfg index 7093299..a4533e1 100644 --- a/control/src/doxygen-cfg +++ b/control/src/doxygen-cfg @@ -1260,7 +1260,7 @@ HTML_COLORSTYLE_GAMMA = 80 # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_TIMESTAMP = NO +HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that @@ -1279,7 +1279,7 @@ HTML_DYNAMIC_MENUS = YES # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_DYNAMIC_SECTIONS = NO +HTML_DYNAMIC_SECTIONS = YES # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand diff --git a/control/src/drv/b15f.cpp b/control/src/drv/b15f.cpp index 17114b6..b07cbbc 100644 --- a/control/src/drv/b15f.cpp +++ b/control/src/drv/b15f.cpp @@ -1,319 +1,464 @@ #include "b15f.h" -B15F* B15F::instance = nullptr; +B15F *B15F::instance = nullptr; errorhandler_t B15F::errorhandler = nullptr; B15F::B15F() { - init(); + init(); } void B15F::init() { - - std::string device = exec("bash -c 'ls /dev/ttyUSB*'"); - while(device.find(' ') != std::string::npos || device.find('\n') != std::string::npos || device.find('\t') != std::string::npos) - device.pop_back(); - - if(device.length() == 0) - abort("Adapter nicht gefunden"); - - std::cout << PRE << "Verwende Adapter: " << device << std::endl; - - - - std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush; - usart.setBaudrate(BAUDRATE); - usart.openDevice(device); - std::cout << "OK" << std::endl; - - - std::cout << PRE << "Teste Verbindung... " << std::flush; - uint8_t tries = 3; - while(tries--) - { - // verwerfe Daten, die µC noch hat - //discard(); - - if(!testConnection()) - continue; - - if(!testIntConv()) - continue; - - break; - } - if(tries == 0) - abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?"); - std::cout << "OK" << std::endl; - - - // Gib board info aus - std::vector info = getBoardInfo(); - std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")" << std::endl; + std::string device = exec("bash -c 'ls /dev/ttyUSB*'"); + while (device.find(' ') != std::string::npos || device.find('\n') != std::string::npos || + device.find('\t') != std::string::npos) + device.pop_back(); + + if (device.length() == 0) + abort("Adapter nicht gefunden"); + + std::cout << PRE << "Verwende Adapter: " << device << std::endl; + + + std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush; + usart.setBaudrate(BAUDRATE); + usart.openDevice(device); + std::cout << "OK" << std::endl; + + + std::cout << PRE << "Teste Verbindung... " << std::flush; + uint8_t tries = 3; + while (tries--) + { + // verwerfe Daten, die µC noch hat + //discard(); + + if (!testConnection()) + continue; + + if (!testIntConv()) + continue; + + break; + } + if (tries == 0) + abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?"); + std::cout << "OK" << std::endl; + + + // Gib board info aus + std::vector info = getBoardInfo(); + std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")" + << std::endl; } void B15F::reconnect() { - uint8_t tries = RECONNECT_TRIES; - while(tries--) - { - delay_ms(RECONNECT_TIMEOUT); - discard(); - - if(testConnection()) - return; - } - - abort("Verbindung kann nicht repariert werden"); + uint8_t tries = RECONNECT_TRIES; + while (tries--) + { + delay_ms(RECONNECT_TIMEOUT); + discard(); + + if (testConnection()) + return; + } + + abort("Verbindung kann nicht repariert werden"); } void B15F::discard(void) { - try - { - usart.clearOutputBuffer(); - for(uint8_t i = 0; i < 16; i++) - { - usart.writeByte(RQ_DISC); // sende discard Befehl (verwerfe input) - delay_ms(4); - } - usart.clearInputBuffer(); - } - catch(std::exception& ex) - { - abort(ex); - } + try + { + uint8_t rq[] = + { + RQ_DISC + }; + + usart.clearOutputBuffer(); + for (uint8_t i = 0; i < 16; i++) + { + usart.transmit(&rq[0], 0, sizeof(rq)); // sende discard Befehl (verwerfe input) + delay_ms(4); + } + usart.clearInputBuffer(); + } + catch (std::exception &ex) + { + abort(ex); + } } bool B15F::testConnection() { - // erzeuge zufälliges Byte - srand(time(NULL)); - uint8_t dummy = rand() % 256; - - usart.writeByte(RQ_TEST); - usart.writeByte(dummy); - - uint8_t aw = usart.readByte(); - uint8_t mirror = usart.readByte(); - - return aw == MSG_OK && mirror == dummy; + // erzeuge zufälliges Byte + srand(time(NULL)); + uint8_t dummy = rand() % 256; + + uint8_t rq[] = + { + RQ_TEST, + dummy + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw[2]; + usart.receive(&aw[0], 0, sizeof(aw)); + + return aw[0] == MSG_OK && aw[1] == dummy; } bool B15F::testIntConv() { - srand(time(NULL)); - uint16_t dummy = rand() % (0xFFFF / 3); - - usart.writeByte(RQ_INT); - usart.writeInt(dummy); - - uint16_t aw = usart.readInt(); - return aw == dummy * 3; + srand(time(NULL)); + uint16_t dummy = rand() % (0xFFFF / 3); + + uint8_t rq[] = + { + RQ_INT, + static_cast(dummy & 0xFF), + static_cast(dummy >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + + return aw == dummy * 3; } std::vector B15F::getBoardInfo(void) { - std::vector info; - - usart.writeByte(RQ_INFO); - - uint8_t n = usart.readByte(); - while(n--) - { - uint8_t len = usart.readByte(); - std::string str; - - while(len--) { - str += static_cast(usart.readByte()); - } - - info.push_back(str); - } - - uint8_t aw = usart.readByte(); - if(aw != MSG_OK) - abort("Board Info fehlerhalft: code " + std::to_string((int) aw)); - - return info; + std::vector info; + + uint8_t rq[] = + { + RQ_INFO + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t n; + usart.receive(&n, 0, sizeof(n)); + while (n--) + { + uint8_t len; + usart.receive(&len, 0, sizeof(len)); + + char str[len + 1]; + str[len] = '\0'; + usart.receive(reinterpret_cast(&str[0]), 0, len); + + info.push_back(std::string(str)); + } + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + if (aw != MSG_OK) + abort("Board Info fehlerhalft: code " + std::to_string((int) aw)); + + return info; } bool B15F::activateSelfTestMode() { - usart.writeByte(RQ_ST); - - uint8_t aw = usart.readByte(); - return aw == MSG_OK; + uint8_t rq[] = + { + RQ_ST + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; } bool B15F::digitalWrite0(uint8_t port) { - usart.writeByte(RQ_BA0); - usart.writeByte(port); - - uint8_t aw = usart.readByte(); - delay_us(10); - return aw == MSG_OK; + uint8_t rq[] = + { + RQ_BA0, + port + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; } bool B15F::digitalWrite1(uint8_t port) { - usart.writeByte(RQ_BA1); - usart.writeByte(port); - - uint8_t aw = usart.readByte(); - delay_us(10); - return aw == MSG_OK; + uint8_t rq[] = + { + RQ_BA1, + port + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; } uint8_t B15F::digitalRead0() { - usart.clearInputBuffer(); - usart.writeByte(RQ_BE0); - uint8_t byte = usart.readByte(); - delay_us(10); - return byte; + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_BE0 + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; } uint8_t B15F::digitalRead1() { - usart.clearInputBuffer(); - usart.writeByte(RQ_BE1); - uint8_t byte = usart.readByte(); - delay_us(10); - return byte; + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_BE1 + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; } uint8_t B15F::readDipSwitch() { - usart.clearInputBuffer(); - usart.writeByte(RQ_DSW); - uint8_t byte = usart.readByte(); - delay_us(10); - return byte; + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_DSW + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; } bool B15F::analogWrite0(uint16_t value) { - usart.writeByte(RQ_AA0); - usart.writeInt(value); - - uint8_t aw = usart.readByte(); - delay_us(10); - return aw == MSG_OK; + uint8_t rq[] = + { + RQ_AA0, + static_cast(value & 0xFF), + static_cast(value >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; } bool B15F::analogWrite1(uint16_t value) { - usart.writeByte(RQ_AA1); - usart.writeInt(value); - - uint8_t aw = usart.readByte(); - delay_us(10); - return aw == MSG_OK; + uint8_t rq[] = + { + RQ_AA1, + static_cast(value & 0xFF), + static_cast(value >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; } uint16_t B15F::analogRead(uint8_t channel) { - usart.clearInputBuffer(); - if(channel > 7) - abort("Bad ADC channel: " + std::to_string(channel)); - - uint8_t rq[] = { - RQ_ADC, - channel - }; - - int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000); - if(n_sent != sizeof(rq)) - abort("Sent failed"); - - uint16_t adc = usart.readInt(); - - if(adc > 1023) - abort("Bad ADC data detected (1)"); - return adc; + usart.clearInputBuffer(); + if (channel > 7) + abort("Bad ADC channel: " + std::to_string(channel)); + + uint8_t rq[] = + { + RQ_ADC, + channel + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + + if (aw > 1023) + abort("Bad ADC data detected (1)"); + return aw; } -void B15F::analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count) +void +B15F::analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, + uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count) { - // check pointers - buffer_a += offset_a; - buffer_b += offset_b; - - - usart.clearInputBuffer(); - usart.writeByte(RQ_ADC_DAC_STROKE); - usart.writeByte(channel_a); - usart.writeByte(channel_b); - usart.writeInt(start); - usart.writeInt(static_cast(delta)); - usart.writeInt(count); - - for(uint16_t i = 0; i < count; i++) - { - if(buffer_a) - { - buffer_a[i] = usart.readInt(); - - if(buffer_a[i] > 1023) // check for broken usart connection - abort("Bad ADC data detected (2)"); - } - else - { - usart.readInt(); - } - - if(buffer_b) - { - buffer_b[i] = usart.readInt(); - - if(buffer_b[i] > 1023) // check for broken usart connection - abort("Bad ADC data detected (3)"); - } - else - { - usart.readInt(); - } - } - - uint8_t aw = usart.readByte(); - if(aw != MSG_OK) - abort("Sequenz unterbrochen"); - - delay_us(10); + // prepare pointers + buffer_a += offset_a; + buffer_b += offset_b; + + + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_ADC_DAC_STROKE, + channel_a, + channel_b, + static_cast(start & 0xFF), + static_cast(start >> 8), + static_cast(delta & 0xFF), + static_cast(delta >> 8), + static_cast(count & 0xFF), + static_cast(count >> 8) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + for (uint16_t i = 0; i < count; i++) + { + if (buffer_a) + { + usart.receive(reinterpret_cast(&buffer_a[i]), 0, 2); + + if (buffer_a[i] > 1023) // check for broken usart connection + abort("Bad ADC data detected (2)"); + } + else + { + usart.drop(2); + } + + if (buffer_b) + { + usart.receive(reinterpret_cast(&buffer_b[i]), 0, 2); + + if (buffer_b[i] > 1023) // check for broken usart connection + abort("Bad ADC data detected (3)"); + } + else + { + usart.drop(2); + } + } + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + if(aw != MSG_OK) + abort("Sequenz unterbrochen"); } +uint8_t B15F::pwmSetFrequency(uint32_t freq) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_PWM_SET_FREQ, + static_cast((freq >> 0) & 0xFF), + static_cast((freq >> 8) & 0xFF), + static_cast((freq >> 16) & 0xFF), + static_cast((freq >> 24) & 0xFF) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + +bool B15F::pwmSetValue(uint8_t value) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_PWM_SET_VALUE, + value + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +bool B15F::setRegister(volatile uint8_t* adr, uint8_t val) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_SET_REG, + static_cast(reinterpret_cast(adr)), + val + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == val; +} + +uint8_t B15F::getRegister(volatile uint8_t* adr) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_GET_REG, + static_cast(reinterpret_cast(adr)) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + + void B15F::delay_ms(uint16_t ms) { - std::this_thread::sleep_for(std::chrono::milliseconds(ms)); + std::this_thread::sleep_for(std::chrono::milliseconds(ms)); } void B15F::delay_us(uint16_t us) { - std::this_thread::sleep_for(std::chrono::microseconds(us)); + std::this_thread::sleep_for(std::chrono::microseconds(us)); } - -B15F& B15F::getInstance(void) -{ - if(!instance) - instance = new B15F(); - return *instance; +B15F &B15F::getInstance(void) +{ + if (!instance) + instance = new B15F(); + + return *instance; } // https://stackoverflow.com/a/478960 -std::string B15F::exec(std::string cmd) { +std::string B15F::exec(std::string cmd) +{ std::array buffer; std::string result; std::unique_ptr pipe(popen(cmd.c_str(), "r"), pclose); - if (!pipe) { + if (!pipe) + { throw std::runtime_error("popen() failed!"); } - while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + { result += buffer.data(); } return result; @@ -321,22 +466,23 @@ std::string B15F::exec(std::string cmd) { void B15F::abort(std::string msg) { - DriverException ex(msg); - abort(ex); + DriverException ex(msg); + abort(ex); } -void B15F::abort(std::exception& ex) + +void B15F::abort(std::exception &ex) { - if(errorhandler) - errorhandler(ex); - else - { - std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl; - std::cout << ex.what() << std::endl; - throw DriverException(ex.what()); - } + if (errorhandler) + errorhandler(ex); + else + { + std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl; + std::cout << ex.what() << std::endl; + throw DriverException(ex.what()); + } } void B15F::setAbortHandler(errorhandler_t func) { - errorhandler = func; + errorhandler = func; } diff --git a/control/src/drv/b15f.h b/control/src/drv/b15f.h index dc06e43..9eb8e35 100644 --- a/control/src/drv/b15f.h +++ b/control/src/drv/b15f.h @@ -18,219 +18,263 @@ #include "driverexception.h" #include "timeoutexception.h" +// wichtig für die Register-Zugriffe +#define _AVR_IO_H_ 1 // Erzwinge die Inklusion +#include "/usr/lib/avr/include/avr/sfr_defs.h" +#include "/usr/lib/avr/include/avr/iom1284p.h" + typedef std::function errorhandler_t; +/*! main driver class */ + class B15F { private: - // privater Konstruktor - B15F(void); + // privater Konstruktor + B15F(void); public: - - /************************************* - * Grundfunktionen des B15F Treibers * - *************************************/ - - /** - * Versucht die Verbindung zum B15 wiederherzustellen - * \throws DriverException - */ - void reconnect(void); - - /** - * Verwirft Daten im USART Puffer auf dieser Maschine und B15 - * \throws DriverException - */ - void discard(void); - - /** - * Testet die USART Verbindung auf Funktion - * \throws DriverException - */ - bool testConnection(void); - - /** - * Testet die Integer Konvertierung der USART Verbindung - * \throws DriverException - */ - bool testIntConv(void); - - /** - * Liefert Informationen zur aktuellen Firmware des B15 - * \throws DriverException - */ - std::vector getBoardInfo(void); - - /** - * Lässt den Treiber für eine angegebene Zeit pausieren - * \param ms Verzögerung in Millisekunden - */ - void delay_ms(uint16_t ms); - - /** - * Lässt den Treiber für eine angegebene Zeit pausieren - * \param us Verzögerung in Microsekunden - */ - void delay_us(uint16_t us); - - /** - * Liefert eine Referenz zur aktuellen Treiber-Instanz - * @throws DriverException - */ - static B15F& getInstance(void); - - /** - * Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück - * \param cmd Der Befehl - */ - static std::string exec(std::string cmd); - /** - * Multithread sicherer Abbruch des B15F-Treibers - * \param msg Beschreibung der Abbruchursache - */ - static void abort(std::string msg); + /************************************* + * Grundfunktionen des B15F Treibers * + *************************************/ - /** - * Multithread sicherer Abbruch des B15F-Treibers - * \param ex Exception als Abbruchursache - */ - static void abort(std::exception& ex); + /** + * Versucht die Verbindung zum B15 wiederherzustellen + * \throws DriverException + */ + void reconnect(void); - /** - * Setzt eine Fehlerbehandlungsroutine für den Treiberabbruch (abort) - * \param func Funktion, die Exception als Parameter bekommt - */ - static void setAbortHandler(errorhandler_t func); + /** + * Verwirft Daten im USART Puffer auf dieser Maschine und B15 + * \throws DriverException + */ + void discard(void); - /*************************************/ - - - - /************************* - * Steuerbefehle für B15 * - *************************/ - - /** - * Versetzt das Board in den Selbsttest-Modus - * WICHTIG: Es darf dabei nichts an den Klemmen angeschlossen sein! - * \throws DriverException - */ - bool activateSelfTestMode(void); - - /** - * Setzt den Wert des digitalen Ausgabeports 0 - * \param port Wert für gesamten Port - * \throws DriverException - */ - bool digitalWrite0(uint8_t); - - /** - * Setzt den Wert des digitalen Ausgabeports 1 - * \param port Wert für gesamten Port - * \throws DriverException - */ - bool digitalWrite1(uint8_t); - - /** - * Liest den Wert des digitalen Eingabeports 0 - * \return Wert für gesamten Port - * \throws DriverException - */ - uint8_t digitalRead0(void); - - /** - * Liest den Wert des digitalen Eingabeports 1 - * \return Wert für gesamten Port - * \throws DriverException - */ - uint8_t digitalRead1(void); - - /** - * Liest den Wert des digitalen Eingabeports, an dem der DIP-switch angeschlossen ist (S7) - * \return Wert für gesamten Port - * \throws DriverException - */ - uint8_t readDipSwitch(void); - - /** - * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 0 - * \param port 10-Bit Wert - * \throws DriverException - */ - bool analogWrite0(uint16_t); - - /** - * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 1 - * \param port 10-Bit Wert - * \throws DriverException - */ - bool analogWrite1(uint16_t); - - /** - * Liest den Wert des Analog-Digital-Converters (ADC / ADU) - * \param channel Kanalwahl von 0 - 7 - * \throws DriverException - */ - uint16_t analogRead(uint8_t channel); - - /** - * DAC 0 wird auf den Startwert gesetzt und dann schrittweise um Delta inkrementiert. - * Für jeden eingestelleten DAC-Wert werden zwei ADCs (channel_a und channel_b) angesprochen und die Werte übermittelt. - * Die Werte werden in buffer_a für Kanal a und buffer_b für Kanal b gespeichert. - * \param channel_a Auswahl des ADC a, von 0 - 7 - * \param buffer_a Speichertort für Werte des Kanals a - * \param offset_a Anzahl an Werten des Kanals a, die im Speicher übersprungen werden sollen - * \param channel_b Auswahl des ADC b, von 0 - 7 - * \param buffer_b Speichertort für Werte des Kanals b - * \param offset_b Anzahl an Werten des Kanals b, die im Speicher übersprungen werden - * \param start Startwert des DACs - * \param delta Schrittweite, mit welcher der DAC inkrementiert wird - * \param count Anzahl an Inkrementierungen - * \throws DriverException - */ - void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count); - - /*************************/ + /** + * Testet die USART Verbindung auf Funktion + * \throws DriverException + */ + bool testConnection(void); + + /** + * Testet die Integer Konvertierung der USART Verbindung + * \throws DriverException + */ + bool testIntConv(void); + + /** + * Liefert Informationen zur aktuellen Firmware des B15 + * \throws DriverException + */ + std::vector getBoardInfo(void); + + /** + * Lässt den Treiber für eine angegebene Zeit pausieren + * \param ms Verzögerung in Millisekunden + */ + void delay_ms(uint16_t ms); + + /** + * Lässt den Treiber für eine angegebene Zeit pausieren + * \param us Verzögerung in Microsekunden + */ + void delay_us(uint16_t us); + + /** + * Liefert eine Referenz zur aktuellen Treiber-Instanz + * @throws DriverException + */ + static B15F& getInstance(void); + + /** + * Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück + * \param cmd Der Befehl + */ + static std::string exec(std::string cmd); + + /** + * Multithread sicherer Abbruch des B15F-Treibers + * \param msg Beschreibung der Abbruchursache + */ + static void abort(std::string msg); + + /** + * Multithread sicherer Abbruch des B15F-Treibers + * \param ex Exception als Abbruchursache + */ + static void abort(std::exception& ex); + + /** + * Setzt eine Fehlerbehandlungsroutine für den Treiberabbruch (abort) + * \param func Funktion, die Exception als Parameter bekommt + */ + static void setAbortHandler(errorhandler_t func); + + /*************************************/ - // CONSTANTS - const std::string PRE = "[B15F] "; - constexpr static uint8_t MSG_OK = 0xFF; - constexpr static uint8_t MSG_FAIL = 0xFE; - constexpr static uint16_t RECONNECT_TIMEOUT = 64; // ms - constexpr static uint16_t WDT_TIMEOUT = 15; // ms - constexpr static uint8_t RECONNECT_TRIES = 3; - constexpr static uint32_t BAUDRATE = 57600; + + /************************* + * Steuerbefehle für B15 * + *************************/ + + /** + * Versetzt das Board in den Selbsttest-Modus + * WICHTIG: Es darf dabei nichts an den Klemmen angeschlossen sein! + * \throws DriverException + */ + bool activateSelfTestMode(void); + + /** + * Setzt den Wert des digitalen Ausgabeports 0 + * \param port Wert für gesamten Port + * \throws DriverException + */ + bool digitalWrite0(uint8_t); + + /** + * Setzt den Wert des digitalen Ausgabeports 1 + * \param port Wert für gesamten Port + * \throws DriverException + */ + bool digitalWrite1(uint8_t); + + /** + * Liest den Wert des digitalen Eingabeports 0 + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t digitalRead0(void); + + /** + * Liest den Wert des digitalen Eingabeports 1 + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t digitalRead1(void); + + /** + * Liest den Wert des digitalen Eingabeports, an dem der DIP-switch angeschlossen ist (S7) + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t readDipSwitch(void); + + /** + * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 0 + * \param port 10-Bit Wert + * \throws DriverException + */ + bool analogWrite0(uint16_t port); + + /** + * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 1 + * \param port 10-Bit Wert + * \throws DriverException + */ + bool analogWrite1(uint16_t port); + + /** + * Liest den Wert des Analog-Digital-Converters (ADC / ADU) + * \param channel Kanalwahl von 0 - 7 + * \throws DriverException + */ + uint16_t analogRead(uint8_t channel); + + /** + * DAC 0 wird auf den Startwert gesetzt und dann schrittweise um Delta inkrementiert. + * Für jeden eingestelleten DAC-Wert werden zwei ADCs (channel_a und channel_b) angesprochen und die Werte übermittelt. + * Die Werte werden in buffer_a für Kanal a und buffer_b für Kanal b gespeichert. + * \param channel_a Auswahl des ADC a, von 0 - 7 + * \param buffer_a Speichertort für Werte des Kanals a + * \param offset_a Anzahl an Werten des Kanals a, die im Speicher übersprungen werden sollen + * \param channel_b Auswahl des ADC b, von 0 - 7 + * \param buffer_b Speichertort für Werte des Kanals b + * \param offset_b Anzahl an Werten des Kanals b, die im Speicher übersprungen werden + * \param start Startwert des DACs + * \param delta Schrittweite, mit welcher der DAC inkrementiert wird + * \param count Anzahl an Inkrementierungen + * \throws DriverException + */ + void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count); + + /** + * Setzt die Register so, dass näherungsweise die gewünschte Frequenz erzeugt wird. + * Ist freq == 0 wird PWM deaktiviert. + * Standardfrequenz: 31300 (empfohlen, da dann TOP == 255) + * \param freq PWM Frequenz + * \return Top Wert des PWM Value für die gesetzte Frequenz + * \throws DriverException + */ + uint8_t pwmSetFrequency(uint32_t freq); + + /** + * Setzt den PWM Wert. + * \param value PWM Wert [0..0xFF] + * \throws DriverException + */ + bool pwmSetValue(uint8_t value); + + /** + * Setzt direkt den Wert eines MCU Registers. + * *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen! + * \param adr Speicheradresse des Registers + * \param val Neuer Wert für das Register + * \throws DriverException + */ + bool setRegister(volatile uint8_t* adr, uint8_t val); + + /** + * Liefert den Wert eines MCU Registers. + * \param adr Speicheradresse des Registers + * \throws DriverException + */ + uint8_t getRegister(volatile uint8_t* adr); + + /*************************/ + + + // CONSTANTS + const std::string PRE = "[B15F] "; //!< B15F stdout prefix + constexpr static uint8_t MSG_OK = 0xFF; //!< Value to acknowledge a received command + constexpr static uint8_t MSG_FAIL = 0xFE; //!< Value to reject a received command + constexpr static uint16_t RECONNECT_TIMEOUT = 64; //!< Time in ms after which a reconnect attempt aborts + constexpr static uint16_t WDT_TIMEOUT = 15; //!< Time in ms after which the watch dog timer resets the MCU + constexpr static uint8_t RECONNECT_TRIES = 3; //!< Maximum count of reconnect attempts after which the driver stops + constexpr static uint32_t BAUDRATE = 57600; //!< USART baudrate for communication with the MCU private: - - /** - * Initialisiert und testet die Verbindung zum B15 - * \throws DriverException - */ - void init(void); - USART usart; - static B15F* instance; - static errorhandler_t errorhandler; - - // REQUESTS - constexpr static uint8_t RQ_DISC = 0; - constexpr static uint8_t RQ_TEST = 1; - constexpr static uint8_t RQ_INFO = 2; - constexpr static uint8_t RQ_INT = 3; - constexpr static uint8_t RQ_ST = 4; - constexpr static uint8_t RQ_BA0 = 5; - constexpr static uint8_t RQ_BA1 = 6; - constexpr static uint8_t RQ_BE0 = 7; - constexpr static uint8_t RQ_BE1 = 8; - constexpr static uint8_t RQ_DSW = 9; - constexpr static uint8_t RQ_AA0 = 10; - constexpr static uint8_t RQ_AA1 = 11; - constexpr static uint8_t RQ_ADC = 12; - constexpr static uint8_t RQ_ADC_DAC_STROKE = 13; + /** + * Initialisiert und testet die Verbindung zum B15 + * \throws DriverException + */ + void init(void); + + USART usart; + static B15F* instance; + static errorhandler_t errorhandler; + + // REQUESTS + constexpr static uint8_t RQ_DISC = 0; + constexpr static uint8_t RQ_TEST = 1; + constexpr static uint8_t RQ_INFO = 2; + constexpr static uint8_t RQ_INT = 3; + constexpr static uint8_t RQ_ST = 4; + constexpr static uint8_t RQ_BA0 = 5; + constexpr static uint8_t RQ_BA1 = 6; + constexpr static uint8_t RQ_BE0 = 7; + constexpr static uint8_t RQ_BE1 = 8; + constexpr static uint8_t RQ_DSW = 9; + constexpr static uint8_t RQ_AA0 = 10; + constexpr static uint8_t RQ_AA1 = 11; + constexpr static uint8_t RQ_ADC = 12; + constexpr static uint8_t RQ_ADC_DAC_STROKE = 13; + constexpr static uint8_t RQ_PWM_SET_FREQ = 14; + constexpr static uint8_t RQ_PWM_SET_VALUE = 15; + constexpr static uint8_t RQ_SET_REG = 16; + constexpr static uint8_t RQ_GET_REG = 17; }; #endif // B15F_H diff --git a/control/src/drv/dot.cpp b/control/src/drv/dot.cpp index 29e80fd..0edb0b4 100644 --- a/control/src/drv/dot.cpp +++ b/control/src/drv/dot.cpp @@ -2,21 +2,21 @@ Dot::Dot(uint16_t x, uint16_t y, uint8_t curve) : x(x), y(y), curve(curve) { - if(curve >= 64) - throw std::range_error("Kurvenindex muss im Bereich [0, 63] liegen"); + if(curve >= 64) + throw std::range_error("Kurvenindex muss im Bereich [0, 63] liegen"); } uint16_t Dot::getX() const { - return x; + return x; } uint16_t Dot::getY() const { - return y; + return y; } uint8_t Dot::getCurve(void) const { - return curve; + return curve; } diff --git a/control/src/drv/dot.h b/control/src/drv/dot.h index 3f2b7f0..48f3493 100644 --- a/control/src/drv/dot.h +++ b/control/src/drv/dot.h @@ -4,17 +4,37 @@ #include #include +/** + * Immutable dot class with x and y coordinate and curve index. + * Dots with the same curve index get the same color by plotty. + */ + class Dot { public: - Dot(uint16_t x, uint16_t y, uint8_t curve); - uint16_t getX(void) const; - uint16_t getY(void) const; - uint8_t getCurve(void) const; - + /** + * Constructor with x and y coordinate and curve index. + */ + Dot(uint16_t x, uint16_t y, uint8_t curve); + + /** + * Returns the x coordinate. + */ + uint16_t getX(void) const; + + /** + * Returns the y coordinate. + */ + uint16_t getY(void) const; + + /** + * Returns the curve index. + */ + uint8_t getCurve(void) const; + private: - uint16_t x, y; - uint8_t curve; + uint16_t x, y; + uint8_t curve; }; diff --git a/control/src/drv/driverexception.h b/control/src/drv/driverexception.h index 18a88a9..cc6764b 100644 --- a/control/src/drv/driverexception.h +++ b/control/src/drv/driverexception.h @@ -5,28 +5,30 @@ // SOURCE: https://stackoverflow.com/a/8152888 +/*! Exception driver problems, for instance incompatible firmware version. */ + class DriverException: public std::exception { public: - explicit DriverException(const char* message) : msg_(message) - { - } + explicit DriverException(const char* message) : msg_(message) + { + } - explicit DriverException(const std::string& message) : msg_(message) - { - } + explicit DriverException(const std::string& message) : msg_(message) + { + } - virtual ~DriverException() throw () - { - } + virtual ~DriverException() throw () + { + } - virtual const char* what() const throw () - { - return msg_.c_str(); - } + virtual const char* what() const throw () + { + return msg_.c_str(); + } protected: - std::string msg_; + std::string msg_; }; #endif // DRIVEREXCEPTION_H diff --git a/control/src/drv/plottyfile.cpp b/control/src/drv/plottyfile.cpp index 1f2b955..f426fb4 100644 --- a/control/src/drv/plottyfile.cpp +++ b/control/src/drv/plottyfile.cpp @@ -2,197 +2,200 @@ void PlottyFile::addDot(Dot& dot) { - dots.push_back(dot); + dots.push_back(dot); } void PlottyFile::addDot(Dot dot) { - dots.push_back(dot); + dots.push_back(dot); } void PlottyFile::setFunctionType(FunctionType function_type) { - this->function_type = function_type; + this->function_type = function_type; } void PlottyFile::setQuadrant(uint8_t quadrant) { - if(quadrant < 1 || quadrant > 4) - throw std::range_error("Ungueltiger Quadrant"); - this->quadrant = quadrant; + if(quadrant < 1 || quadrant > 4) + throw std::range_error("Ungueltiger Quadrant"); + this->quadrant = quadrant; } void PlottyFile::setRefX(uint16_t ref_x) { - this->ref_x = ref_x; + this->ref_x = ref_x; } void PlottyFile::setRefY(uint16_t ref_y) { - this->ref_y = ref_y; + this->ref_y = ref_y; } void PlottyFile::setParaFirstCurve(uint16_t para_first) { - this->para_first = para_first; + this->para_first = para_first; } void PlottyFile::setParaStepWidth(uint16_t para_stepwidth) { - this->para_stepwidth = para_stepwidth; + this->para_stepwidth = para_stepwidth; } void PlottyFile::setUnitX(std::string unit_x) { - this->unit_x = unit_x; + this->unit_x = unit_x; } void PlottyFile::setDescX(std::string desc_x) { - this->desc_x = desc_x; + this->desc_x = desc_x; } void PlottyFile::setUnitY(std::string unit_y) { - this->unit_y = unit_y; + this->unit_y = unit_y; } void PlottyFile::setDescY(std::string desc_y) { - this->desc_y = desc_y; + this->desc_y = desc_y; } void PlottyFile::setUnitPara(std::string unit_para) { - this->unit_para = unit_para; + this->unit_para = unit_para; } void PlottyFile::setDescPara(std::string desc_para) { - this->desc_para = desc_para; + this->desc_para = desc_para; } - + FunctionType PlottyFile::getFunctionType() const { - return function_type; + return function_type; } uint8_t PlottyFile::getQuadrant() const { - return quadrant; + return quadrant; } uint16_t PlottyFile::getRefX() const { - return ref_x; + return ref_x; } uint16_t PlottyFile::getRefY() const { - return ref_y; + return ref_y; } uint16_t PlottyFile::getParaFirstCurve() const { - return para_first; + return para_first; } uint16_t PlottyFile::getParaStepWidth() const { - return para_stepwidth; + return para_stepwidth; } std::string PlottyFile::getUnitX() const { - return unit_x; + return unit_x; } std::string PlottyFile::getDescX() const { - return desc_x; + return desc_x; } std::string PlottyFile::getUnitY() const { - return unit_y; + return unit_y; } std::string PlottyFile::getDescY() const { - return desc_y; + return desc_y; } std::string PlottyFile::getUnitPara() const { - return unit_para; + return unit_para; } std::string PlottyFile::getDescPara() const { - return desc_para; + return desc_para; } void PlottyFile::prepStr(std::string& str, uint8_t len) { - if(str.length() > len) - throw std::runtime_error("Zu grosser String."); - - if(str.length() != len) - str += '\n'; - - while(str.length() < len) - str += '\0'; + if(str.length() > len) + throw std::runtime_error("Zu grosser String."); + + if(str.length() != len) + str += '\n'; + + while(str.length() < len) + str += '\0'; } void PlottyFile::writeToFile(std::string filename) -{ - prepStr(unit_x, STR_LEN_SHORT); - prepStr(desc_x, STR_LEN_LARGE); - prepStr(unit_y, STR_LEN_SHORT); - prepStr(desc_y, STR_LEN_LARGE); - prepStr(unit_para, STR_LEN_SHORT); - prepStr(desc_para, STR_LEN_LARGE); - - std::ofstream file(filename); - - // write file header - file.write(reinterpret_cast(&command), 1); - file.write(head.c_str(), head.length()); - file.write(filetype.c_str(), filetype.length()); - file.write(reinterpret_cast(&version), 2); - file.write(reinterpret_cast(&subversion), 2); - file.put(static_cast(function_type)); - file.write(reinterpret_cast(&quadrant), 1); - file.write(reinterpret_cast(&ref_x), 2); - file.write(reinterpret_cast(&ref_y), 2); - file.write(reinterpret_cast(¶_first), 2); - file.write(reinterpret_cast(¶_stepwidth), 2); - file.write(unit_x.c_str(), unit_x.length()); - file.write(desc_x.c_str(), desc_x.length()); - file.write(unit_y.c_str(), unit_y.length()); - file.write(desc_y.c_str(), desc_y.length()); - file.write(unit_para.c_str(), unit_para.length()); - file.write(desc_para.c_str(), desc_para.length()); - file.write(reinterpret_cast(&eof), 1); - - // make sure header size is 256 Byte - while(file.tellp() < 256) - file.put(0); - - for(Dot& dot : dots) - { - file.put((dot.getX() >> 8) | (static_cast(dot.getCurve()) << 2)); - file.put(dot.getX() & 0xFF); - file.put(dot.getY() >> 8); - file.put(dot.getY() & 0xFF); - } - - file.close(); +{ + if(dots.empty()) + throw std::length_error("Es wurden keine Punkte gespeichert."); + + prepStr(unit_x, STR_LEN_SHORT); + prepStr(desc_x, STR_LEN_LARGE); + prepStr(unit_y, STR_LEN_SHORT); + prepStr(desc_y, STR_LEN_LARGE); + prepStr(unit_para, STR_LEN_SHORT); + prepStr(desc_para, STR_LEN_LARGE); + + std::ofstream file(filename); + + // write file header + file.write(reinterpret_cast(&command), 1); + file.write(head.c_str(), head.length()); + file.write(filetype.c_str(), filetype.length()); + file.write(reinterpret_cast(&version), 2); + file.write(reinterpret_cast(&subversion), 2); + file.put(static_cast(function_type)); + file.write(reinterpret_cast(&quadrant), 1); + file.write(reinterpret_cast(&ref_x), 2); + file.write(reinterpret_cast(&ref_y), 2); + file.write(reinterpret_cast(¶_first), 2); + file.write(reinterpret_cast(¶_stepwidth), 2); + file.write(unit_x.c_str(), unit_x.length()); + file.write(desc_x.c_str(), desc_x.length()); + file.write(unit_y.c_str(), unit_y.length()); + file.write(desc_y.c_str(), desc_y.length()); + file.write(unit_para.c_str(), unit_para.length()); + file.write(desc_para.c_str(), desc_para.length()); + file.write(reinterpret_cast(&eof), 1); + + // make sure header size is 256 Byte + while(file.tellp() < 256) + file.put(0); + + for(Dot& dot : dots) + { + file.put((dot.getX() >> 8) | (static_cast(dot.getCurve()) << 2)); + file.put(dot.getX() & 0xFF); + file.put(dot.getY() >> 8); + file.put(dot.getY() & 0xFF); + } + + file.close(); } void PlottyFile::startPlotty(std::string filename) { - int code = system(("plotty --in " + filename).c_str()); - if(code) - throw std::runtime_error("Fehler beim Aufruf von plotty"); + int code = system(("plotty --in " + filename).c_str()); + if(code) + throw std::runtime_error("Fehler beim Aufruf von plotty"); } diff --git a/control/src/drv/plottyfile.h b/control/src/drv/plottyfile.h index 17b02eb..16a38d3 100644 --- a/control/src/drv/plottyfile.h +++ b/control/src/drv/plottyfile.h @@ -5,75 +5,205 @@ #include #include #include +#include #include "dot.h" enum FunctionType { - CurveFamily = 'S', - Curve = 'C', - Level = 'P' -}; + CurveFamily = 'S', + Curve = 'C', + Level = 'P' +}; + +/*! Wrapper class for convenient plot file creation, needed to display graphs using plotty. */ class PlottyFile { public: - void addDot(Dot& dot); - void addDot(Dot dot); - - void setFunctionType(FunctionType); - void setQuadrant(uint8_t); - void setRefX(uint16_t); - void setRefY(uint16_t); - void setParaFirstCurve(uint16_t); - void setParaStepWidth(uint16_t); - void setUnitX(std::string); - void setDescX(std::string); - void setUnitY(std::string); - void setDescY(std::string); - void setUnitPara(std::string); - void setDescPara(std::string); - - FunctionType getFunctionType(void) const; - uint8_t getQuadrant(void) const; - uint16_t getRefX(void) const; - uint16_t getRefY(void) const; - uint16_t getParaFirstCurve(void) const; - uint16_t getParaStepWidth(void) const; - std::string getUnitX(void) const; - std::string getDescX(void) const; - std::string getUnitY(void) const; - std::string getDescY(void) const; - std::string getUnitPara(void) const; - std::string getDescPara(void) const; - - void writeToFile(std::string filename); - void startPlotty(std::string filename); + /** + * Adds a dot to the plotty file. + * \param dot the dot + */ + void addDot(Dot& dot); + + /** + * Adds a dot by reference to the plotty file. + * \param dot the dot + */ + void addDot(Dot dot); + + /** + * Sets the FunctionType of this plotty file. + * \param function_type enum value + */ + void setFunctionType(FunctionType function_type); + + /** + * Sets the quadrant of this plot. + * \param quadrant quadrant number (1..4) + */ + void setQuadrant(uint8_t quadrant); + + /** + * Sets reference (max) value of the x axis + * \param ref_x reference value + */ + void setRefX(uint16_t ref_x); + + /** + * Sets reference (max) value of the y axis + * \param ref_y reference value + */ + void setRefY(uint16_t ref_y); + + /** + * Sets initial value of the parameter. + * Gets used together with the stepwith to label the curves. + * \param para_first initial parameter value + */ + void setParaFirstCurve(uint16_t para_first); + + /** + * Sets the stepwith the parameter got increased with each curve. + * \param para_first parameter stepwith + */ + void setParaStepWidth(uint16_t para_stepwidth); + + /** + * Sets the unit of the x axis. + * \param para_first unit + */ + void setUnitX(std::string unit_x); + + /** + * Sets the description of the x axis. + * \param para_first description + */ + void setDescX(std::string desc_x); + + /** + * Sets the unit of the y axis. + * \param para_first unit + */ + void setUnitY(std::string unit_y); + + /** + * Sets the description of the y axis. + * \param para_first description + */ + void setDescY(std::string desc_y); + + /** + * Sets the unit of the parameter. + * \param para_first unit + */ + void setUnitPara(std::string unit_para); + /** + * Sets the description of the parameter. + * \param para_first description + */ + void setDescPara(std::string desc_para); + + + + /** + * \return the FunctionType + */ + FunctionType getFunctionType(void) const; + + /** + * \return the quadrant + */ + uint8_t getQuadrant(void) const; + + /** + * \return x reference (max) value + */ + uint16_t getRefX(void) const; + + /** + * \return y reference (max) value + */ + uint16_t getRefY(void) const; + + /** + * \return initial parameter value + */ + uint16_t getParaFirstCurve(void) const; + + /** + * \return parameter stepwith + */ + uint16_t getParaStepWidth(void) const; + + /** + * \return unit of x axis + */ + std::string getUnitX(void) const; + + /** + * \return description of x axis + */ + std::string getDescX(void) const; + + /** + * \return unit of y axis + */ + std::string getUnitY(void) const; + + /** + * \return description of y axis + */ + std::string getDescY(void) const; + + /** + * \return unit of parameter + */ + std::string getUnitPara(void) const; + + /** + * \return description of parameter + */ + std::string getDescPara(void) const; + + + /** + * Saves the PlottyFile in a binary format, ready to open with plotty. + * \param filename desired plot path + */ + void writeToFile(std::string filename); + + /** + * Starts plotty with a plot file. + * \param filename plot path + */ + void startPlotty(std::string filename); private: - void prepStr(std::string& str, uint8_t len); + void prepStr(std::string& str, uint8_t len); - std::vector dots; + std::vector dots; - int8_t command = 0x1D; - const std::string head = "HTWK-HWLab"; - const std::string filetype = "MD"; - int16_t version = 1; - int16_t subversion = 0; - FunctionType function_type = FunctionType::Curve; - uint8_t quadrant = 1; - uint16_t ref_x = 1023; - uint16_t ref_y = 1023; - uint16_t para_first = 1; - uint16_t para_stepwidth = 1; - std::string unit_x; - std::string desc_x; - std::string unit_y; - std::string desc_y; - std::string unit_para; - std::string desc_para; - const uint8_t eof = 0xD; - - constexpr static uint8_t STR_LEN_SHORT = 10; - constexpr static uint8_t STR_LEN_LARGE = 20; + int8_t command = 0x1D; + const std::string head = "HTWK-HWLab"; + const std::string filetype = "MD"; + int16_t version = 1; + int16_t subversion = 0; + FunctionType function_type = FunctionType::Curve; + uint8_t quadrant = 1; + uint16_t ref_x = 1023; + uint16_t ref_y = 1023; + uint16_t para_first = 1; + uint16_t para_stepwidth = 1; + std::string unit_x; + std::string desc_x; + std::string unit_y; + std::string desc_y; + std::string unit_para; + std::string desc_para; + const uint8_t eof = 0xD; + + constexpr static uint8_t STR_LEN_SHORT = 10; + constexpr static uint8_t STR_LEN_LARGE = 20; }; #endif // PLOTTYFILE_H diff --git a/control/src/drv/timeoutexception.h b/control/src/drv/timeoutexception.h index 159ec7b..d59fe24 100644 --- a/control/src/drv/timeoutexception.h +++ b/control/src/drv/timeoutexception.h @@ -2,34 +2,45 @@ #define TIMEOUTEXCEPTION_H #include +#include -// SOURCE: https://stackoverflow.com/a/8152888 +/*! Exception for USART related timeouts. */ class TimeoutException: public std::exception { public: - explicit TimeoutException(const char* message, int timeout) : TimeoutException(std::string(message), timeout) - { - } + /** + * Constructor + * @param message as c-string + */ + explicit TimeoutException(const char* message) : msg(message) + { + } - explicit TimeoutException(const std::string& message, int timeout) : msg(message), m_timeout(timeout) - { - if(!msg.length()) - msg = "Timeout reached (" + std::to_string(m_timeout) + ")"; - } + /** + * Constructor + * @param message as c++-string + */ + explicit TimeoutException(const std::string& message) : msg(message) + { + } - virtual ~TimeoutException() throw () - { - } + /** + * Standard-destructor + */ + virtual ~TimeoutException() = default; - virtual const char* what() const throw () - { - return msg.c_str(); - } + /** + * Get failure description + * @return error message as c-string + */ + virtual const char* what() const throw () + { + return msg.c_str(); + } protected: - std::string msg; - int m_timeout; + std::string msg; //!< failure description }; #endif // TIMEOUTEXCEPTION_H diff --git a/control/src/drv/usart.cpp b/control/src/drv/usart.cpp index a18de62..259fbdb 100644 --- a/control/src/drv/usart.cpp +++ b/control/src/drv/usart.cpp @@ -1,324 +1,139 @@ +#include #include "usart.h" +USART::~USART() +{ + closeDevice(); +} + void USART::openDevice(std::string device) { - file_desc = open(device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY /* | O_NONBLOCK*/); - if(file_desc <= 0) - throw USARTException("Fehler beim Öffnen des Gerätes"); - - struct termios options; - int code = tcgetattr(file_desc, &options); - if(code) - throw USARTException("Fehler beim Lesen der Geräteparameter"); - - options.c_cflag = CS8 | CLOCAL | CREAD; - options.c_iflag = IGNPAR; - options.c_oflag = 0; - options.c_lflag = 0; - options.c_cc[VMIN] = 0; // #bytes read returns at least - options.c_cc[VTIME] = timeout; + // Benutze blockierenden Modus + file_desc = open(device.c_str(), O_RDWR | O_NOCTTY);// | O_NDELAY + if (file_desc <= 0) + throw USARTException("Fehler beim Öffnen des Gerätes"); + + struct termios options; + int code = tcgetattr(file_desc, &options); + if (code) + throw USARTException("Fehler beim Lesen der Geräteparameter"); + + options.c_cflag = CS8 | CLOCAL | CREAD; + options.c_iflag = IGNPAR; + options.c_oflag = 0; + options.c_lflag = 0; + options.c_cc[VMIN] = 0; + options.c_cc[VTIME] = timeout; code = cfsetspeed(&options, baudrate); - if(code) - throw USARTException("Fehler beim Setzen der Baudrate"); - - code = tcsetattr(file_desc, TCSANOW, &options); - if(code) - throw USARTException("Fehler beim Setzen der Geräteparameter"); - - clearOutputBuffer(); - clearInputBuffer(); + if (code) + throw USARTException("Fehler beim Setzen der Baudrate"); + + code = tcsetattr(file_desc, TCSANOW, &options); + if (code) + throw USARTException("Fehler beim Setzen der Geräteparameter"); + + code = fcntl(file_desc, F_SETFL, 0); // blockierender Modus + if (code) + throw USARTException("Fehler beim Aktivieren des blockierenden Modus'"); + + clearOutputBuffer(); + clearInputBuffer(); } - + void USART::closeDevice() { - int code = close(file_desc); - if(code) - throw USARTException("Fehler beim Schließen des Gerätes"); + if (file_desc > 0) + { + int code = close(file_desc); + if (code) + throw USARTException("Fehler beim Schließen des Gerätes"); + file_desc = -1; + } } - + void USART::clearInputBuffer() { - int code = tcflush(file_desc, TCIFLUSH); - if(code) - throw USARTException("Fehler beim Leeren des Eingangspuffers"); + int code = tcflush(file_desc, TCIFLUSH); + if (code) + throw USARTException("Fehler beim Leeren des Eingangspuffers"); } - + void USART::clearOutputBuffer() { - int code = tcflush(file_desc, TCOFLUSH); - if(code) - throw USARTException("Fehler beim Leeren des Ausgangspuffers"); + int code = tcflush(file_desc, TCOFLUSH); + if (code) + throw USARTException("Fehler beim Leeren des Ausgangspuffers"); } - + void USART::flushOutputBuffer() { - int code = tcdrain(file_desc); - if(code) - throw USARTException("Fehler beim Versenden des Ausgangspuffers"); + int code = tcdrain(file_desc); + if (code) + throw USARTException("Fehler beim Versenden des Ausgangspuffers"); } -void USART::printStatistics() +void USART::transmit(uint8_t *buffer, uint16_t offset, uint8_t len) { - double pz = 1e2 * n_blocks_failed / n_blocks_total; - pz = std::round(pz * 1e2) / 1e2; - std::cout << "blocks total: " << n_blocks_total << " ok: " << (n_blocks_total - n_blocks_failed) << " failed: " << n_blocks_failed << " (" << pz << "%)" << std::endl; + int code = write(file_desc, buffer + offset, len); + if (code != len) + throw USARTException( + std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) + + ", " + strerror(code) + " (code " + std::to_string(code) + " / " + std::to_string(len) + ")"); } -void USART::writeByte(uint8_t b) +void USART::receive(uint8_t *buffer, uint16_t offset, uint8_t len) { - int sent = write(file_desc, &b, 1); - if(sent != 1) - { - std::cout << "WARNUNG: Fehler beim Senden (" << sent << "): writeByte(), wiederhole..." << std::endl; - usleep(100000); - sent = write(file_desc, &b, 1); - if(sent != 1) - throw USARTException("Fehler beim Senden: writeByte()"); - } - -} - -void USART::writeInt(uint16_t d) -{ - int sent = write(file_desc, reinterpret_cast(&d), 2); - if(sent != 2) - throw USARTException("Fehler beim Senden: writeInt()"); + int bytes_avail, code; + auto start = std::chrono::steady_clock::now(); + auto end = std::chrono::steady_clock::now(); + do + { + code = ioctl(file_desc, FIONREAD, &bytes_avail); + if (code) + throw USARTException( + std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) + + ", " + strerror(code) + " (code " + std::to_string(code) + ")"); + + end = std::chrono::steady_clock::now(); + long elapsed = + std::chrono::duration_cast(end - start).count() / 100; // in Dezisekunden + if (elapsed >= timeout) + throw TimeoutException( + std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) + + ", " + std::to_string(elapsed) + " / " + std::to_string(timeout) + " ds"); + } + while (bytes_avail < len); + + code = read(file_desc, buffer + offset, len); + if (code != len) + throw USARTException( + std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) + + ", " + strerror(code) + " (code " + std::to_string(code) + " / " + std::to_string(len) + ")"); } - - -int USART::read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout) +void USART::drop(uint8_t len) { - uint32_t elapsed = 0; - int n_read = -1; - auto start = std::chrono::steady_clock::now(); - auto end = start; - while(elapsed < timeout) - { - n_read = read(file_desc, buffer + offset, len); - if (n_read == len) - return n_read; - - end = std::chrono::steady_clock::now(); - elapsed = std::chrono::duration_cast(end - start).count(); - } - - return 0; -} - -int USART::write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout) -{ - uint32_t elapsed = 0; - int n_sent = -1; - auto start = std::chrono::steady_clock::now(); - auto end = start; - while(elapsed < timeout) - { - n_sent = write(file_desc, buffer + offset, len); - flushOutputBuffer(); - if (n_sent == len) - return n_sent; - - end = std::chrono::steady_clock::now(); - elapsed = std::chrono::duration_cast(end - start).count(); - } - - return n_sent; -} - -void USART::writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len) -{ - uint8_t crc; - uint8_t aw; - const uint16_t us_per_bit = (1000000 / baudrate) * 16; - const uint16_t n_total = len + 3; - - n_blocks_total++; - bool failed = false; - - do - { - // calc crc - crc = 0; - for(uint8_t i = 0; i < len; i++) - { - crc ^= buffer[i]; - for (uint8_t k = 0; k < 8; k++) - { - if (crc & 1) - crc ^= CRC7_POLY; - crc >>= 1; - } - } - - // construct block - block_buffer[0] = len; - std::memcpy(&block_buffer[1], buffer + offset, len); - block_buffer[len + 1] = crc; - block_buffer[len + 2] = BLOCK_END; - - // send block - clearOutputBuffer(); - clearInputBuffer(); - int n_sent = write_timeout(&block_buffer[0], 0, len + 3, us_per_bit * n_total); - if(n_sent != n_total) - throw std::runtime_error("fatal (send): " + std::to_string(n_sent)); - - /*for(uint8_t i = 0; i < len + 3; i++) - { - write_timeout(&block_buffer[i], 0, 1, us_per_bit * n_total); - //tcdrain(file_desc); - //usleep(1000); - }*/ - - // flush output data - tcdrain(file_desc); - - //usleep(us_per_bit * n_total * 10); - - // check response - int n_read = read_timeout(&aw, 0, 1, us_per_bit * n_blocks_total * 10); - for(uint16_t i = 0; i < 255 && n_read != 1; i++) - { - writeByte(0x80); // Stoppzeichen für Block - if(tcdrain(file_desc)) - { - std::cout << "drain failed" << std::endl; - } - std::cout << "WARNING: read error (" << n_read << "), retry #" << (int) i << std::endl; - usleep(us_per_bit*100); - n_read = read_timeout(&aw, 0, 1, us_per_bit); - } - - if(n_read != 1) - throw std::runtime_error("fatal: " + std::to_string(n_read)); - - //clearInputBuffer(); - - if(aw != 0xFF) { - if(!failed) - n_blocks_failed++; - failed = true; - std::cout << "block failed, retry" << std::endl; - } - } - while(aw != 0xFF); - - //std::cout << "OK" << std::endl; -} - -uint8_t USART::readByte(void) -{ - char b; - auto start = std::chrono::steady_clock::now(); - auto end = start; - uint16_t elapsed = 0; - while(elapsed < timeout * 100) - { - int code = read(file_desc, &b, 1); - if (code > 0) - return static_cast(b); - - end = std::chrono::steady_clock::now(); - elapsed = std::chrono::duration_cast(end - start).count(); - } - - throw TimeoutException("Verbindung unterbrochen.", timeout); -} - -uint16_t USART::readInt(void) -{ - return readByte() | readByte() << 8; -} - -bool USART::readBlock(uint8_t* buffer, uint16_t offset) -{ - uint8_t len = readByte(); - uint8_t crc = 0; - buffer += offset; - - uint32_t block_timeout = timeout / 10; - - // wait for block - int n_ready; - uint16_t elapsed = 0; - auto start = std::chrono::steady_clock::now(); - auto end = start; - while(elapsed < block_timeout) - { - int code = ioctl(file_desc, FIONREAD, &n_ready); - if(code != 0) - { - std::cout << "n_ready code: " << code << std::endl; - return false; - } - - if(n_ready >= len + 1) - break; - - end = std::chrono::steady_clock::now(); - elapsed = std::chrono::duration_cast(end - start).count(); - } - if(elapsed >= timeout) - { - std::cout << "block timeout: " << std::endl; - return false; - } - - while(len--) - { - *buffer = readByte(); - - crc ^= *buffer++; - for (uint8_t i = 0; i < 8; i++) - { - if (crc & 1) - crc ^= CRC7_POLY; - crc >>= 1; - } - } - - crc ^= readByte(); - for (uint8_t i = 0; i < 8; i++) - { - if (crc & 1) - crc ^= CRC7_POLY; - crc >>= 1; - } - - if(TEST == 1) - crc = 1; - if(TEST > 100) - TEST = 0; - - if (crc == 0) - { - writeByte(0xFF); - return true; - } - else - { - writeByte(0xFE); - return false; - } + // Kann bestimmt noch eleganter gelöst werden + uint8_t dummy[len]; + receive(&dummy[0], 0, len); } uint32_t USART::getBaudrate() { - return baudrate; + return baudrate; } uint8_t USART::getTimeout() { - return timeout; + return timeout; } - + void USART::setBaudrate(uint32_t baudrate) { - this->baudrate = baudrate; + this->baudrate = baudrate; } void USART::setTimeout(uint8_t timeout) { - this->timeout = timeout; + this->timeout = timeout; } diff --git a/control/src/drv/usart.h b/control/src/drv/usart.h index b33019a..8ba889c 100644 --- a/control/src/drv/usart.h +++ b/control/src/drv/usart.h @@ -1,150 +1,139 @@ #ifndef USART_H #define USART_H -#include #include #include -#include -#include #include -#include +#include #include -#include +#include +#include #include "usartexception.h" #include "timeoutexception.h" +/*! C++ Wrapper class for termios usart library. */ + class USART { public: - - /************************************************* - * Methoden für die Verwaltung der Schnittstelle * - *************************************************/ - - /** - * Öffnet die USART Schnittstelle - * \param device Linux-Gerätepfad - * \throws USARTException - */ - void openDevice(std::string device); - - /** - * Schließt die USART Schnittstelle - * \throws USARTException - */ - void closeDevice(void); - - /** - * Verwirft Daten, die bereits im Puffer liegen, aber noch nicht gelesen wurden - * \throws USARTException - */ - void clearInputBuffer(void); - - /** - * Verwirft Daten, die bereits im Puffer liegen, aber noch nicht gesendet wurden - * \throws USARTException - */ - void clearOutputBuffer(void); - - /** - * Schreibt Daten, die bereits im Puffer liegen, aber noch nicht gesendet wurden - * \throws USARTException - */ - void flushOutputBuffer(void); - - /** - * Gibt Anzahl an erfolgreichen und fehlgeschlagenen Block-Übertragungen an - */ - void printStatistics(void); - - /*************************************************/ - - - - /************************************* - * Methoden für die Datenübertragung * - *************************************/ - - /** - * Sendet ein Byte über die USART Schnittstelle - * \param b das zu sendende Byte - * \throws USARTException - */ - void writeByte(uint8_t b); - - /** - * Sendet ein Integer über die USART Schnittstelle - * \param b das zu sendende Byte - * \throws USARTException - */ - void writeInt(uint16_t d); - - /** - * Empfängt ein Byte über die USART Schnittstelle - * \throws USARTException - */ - uint8_t readByte(void); - - /** - * Empfängt ein Integer über die USART Schnittstelle - * \throws USARTException - */ - uint16_t readInt(void); - - int read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout); - int write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout); - void writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len); - bool readBlock(uint8_t* buffer, uint16_t offset); - - /*************************************/ - - - - /*************************************** - * Methoden für einstellbare Parameter * - ***************************************/ - - /** - * Liefert die eingestellte Baudrate - * Änderungen werden erst nach einem open() wirksam - */ - uint32_t getBaudrate(void); - - /** - * Liefert den eingestellten Timeout (in Dezisekunden) - * Änderungen werden erst nach einem open() wirksam - */ - uint8_t getTimeout(void); - - /** - * Setzt die Baudrate - * Änderungen werden erst nach einem open() wirksam - */ - void setBaudrate(uint32_t baudrate); - - /** - * Setzt den Timeout (in Dezisekunden) - * Änderungen werden erst nach einem open() wirksam - */ - void setTimeout(uint8_t timeout); - - /***************************************/ - - constexpr static uint8_t CRC7_POLY = 0x91; - constexpr static uint8_t MAX_BLOCK_SIZE = 64; - constexpr static uint8_t BLOCK_END = 0x80; + + /************************************************* + * Methoden für die Verwaltung der Schnittstelle * + *************************************************/ + + /** + * Standard-Konstruktor + */ + explicit USART() = default; + + /** + * Destructor, ruft automatisch closeDevice() auf + */ + virtual ~USART(void); + + /** + * Öffnet die USART Schnittstelle + * \param device Linux-Gerätepfad + * \throws USARTException + */ + void openDevice(std::string device); + + /** + * Schließt die USART Schnittstelle + * \throws USARTException + */ + void closeDevice(void); + + /** + * Verwirft Daten, die bereits im Puffer liegen, aber noch nicht gelesen wurden + * \throws USARTException + */ + void clearInputBuffer(void); + + /** + * Verwirft Daten, die bereits im Puffer liegen, aber noch nicht gesendet wurden + * \throws USARTException + */ + void clearOutputBuffer(void); + + /** + * Schreibt Daten, die bereits im Puffer liegen, aber noch nicht gesendet wurden + * \throws USARTException + */ + void flushOutputBuffer(void); + + /*************************************************/ + + + + /************************************* + * Methoden für die Datenübertragung * + *************************************/ + + /** + * Sends n bytes from the buffer over USART + * \param buffer target buffer + * \param offset in buffer (mostly 0) + * \param len count of bytes to send + * \throws USARTException + */ + void transmit(uint8_t *buffer, uint16_t offset, uint8_t len); + + /** + * Receives n bytes from USART and writes them into the buffer + * \param buffer target buffer + * \param offset in buffer (mostly 0) + * \param len count of bytes to receive + * \throws USARTException + */ + void receive(uint8_t *buffer, uint16_t offset, uint8_t len); + + /** + * Receives n bytes but discards them + * \param len count of bytes to receive + * \throws USARTException + */ + void drop(uint8_t len); + + /*************************************/ + + + + /*************************************** + * Methoden für einstellbare Parameter * + ***************************************/ + + /** + * Liefert die eingestellte Baudrate + * Änderungen werden erst nach einem open() wirksam + */ + uint32_t getBaudrate(void); + + /** + * Liefert den eingestellten Timeout (in Dezisekunden) + * Änderungen werden erst nach einem open() wirksam + */ + uint8_t getTimeout(void); + + /** + * Setzt die Baudrate + * Änderungen werden erst nach openDevice() wirksam + */ + void setBaudrate(uint32_t baudrate); + + /** + * Setzt den Timeout (in Dezisekunden) + * Änderungen werden erst nach openDevice() wirksam + */ + void setTimeout(uint8_t timeout); + + /***************************************/ + private: - - int file_desc = -1; // Linux Dateideskriptor - uint32_t baudrate = 9600; // Standard-Baudrate, sollte mit setBaudrate() überschrieben werden! - int TEST = 0; - uint8_t timeout = 10; // in Dezisekunden - uint8_t block_buffer[MAX_BLOCK_SIZE + 3]; - - // debug statistics - uint32_t n_blocks_total = 0; - uint32_t n_blocks_failed = 0; + + int file_desc = -1; //!< Linux Dateideskriptor + uint32_t baudrate = 9600; //!< Standard-Baudrate, sollte mit setBaudrate() überschrieben werden! + uint8_t timeout = 10; //!< in Dezisekunden }; - #endif // USART_H diff --git a/control/src/drv/usartexception.h b/control/src/drv/usartexception.h index 840ce6c..68f5b0d 100644 --- a/control/src/drv/usartexception.h +++ b/control/src/drv/usartexception.h @@ -4,30 +4,43 @@ #include #include -// SOURCE: https://stackoverflow.com/a/8152888 +/*! Exception for USART problems, for instance buffer overflow. */ class USARTException: public std::exception { public: - explicit USARTException(const char* message) : msg(message) - { - } + /** + * Constructor + * @param message as c-string + */ + explicit USARTException(const char* message) : msg(message) + { + } - explicit USARTException(const std::string& message) : msg(message) - { - } + /** + * Constructor + * @param message as c++-string + */ + explicit USARTException(const std::string& message) : msg(message) + { + } - virtual ~USARTException() throw () - { - } + /** + * Standard-destructor + */ + virtual ~USARTException() = default; - virtual const char* what() const throw () - { - return msg.c_str(); - } + /** + * Get failure description + * @return error message as c-string + */ + virtual const char* what() const throw () + { + return msg.c_str(); + } protected: - std::string msg; + std::string msg; //!< failure description }; #endif // USARTEXCEPTION_H diff --git a/control/src/ui/ui.cpp b/control/src/ui/ui.cpp index f1c1556..cb2198c 100644 --- a/control/src/ui/ui.cpp +++ b/control/src/ui/ui.cpp @@ -6,277 +6,277 @@ std::thread t_refresh; void show_main(int) { - ViewSelection* view = new ViewSelection(); - view->setTitle("B15F - Command Line Interface"); - view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor); - view->addChoice("[ Digitale Ausgabe BE0 ]", &show_digital_output0); - view->addChoice("[ Digitale Ausgabe BE1 ]", &show_digital_output1); - view->addChoice("[ Analoge Ausgabe AA0 ]", &show_analog_output0); - view->addChoice("[ Analoge Ausgabe AA1 ]", &show_analog_output1); - view->addChoice("[ Selbsttest des B15 ]", &show_selftest_info); - view->addChoice("[ Informationen ]", &show_info); - view->addChoice("", nullptr); - view->addChoice("[ Beenden ]", &finish); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewSelection* view = new ViewSelection(); + view->setTitle("B15F - Command Line Interface"); + view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor); + view->addChoice("[ Digitale Ausgabe BE0 ]", &show_digital_output0); + view->addChoice("[ Digitale Ausgabe BE1 ]", &show_digital_output1); + view->addChoice("[ Analoge Ausgabe AA0 ]", &show_analog_output0); + view->addChoice("[ Analoge Ausgabe AA1 ]", &show_analog_output1); + view->addChoice("[ Selbsttest des B15 ]", &show_selftest_info); + view->addChoice("[ Informationen ]", &show_info); + view->addChoice("", nullptr); + view->addChoice("[ Beenden ]", &finish); + view->repaint(); + + win_stack.push_back(view); + input(0); } void input(int) { - call_t nextCall; - int key; - do - { - key = wgetch(View::getWinContext()); - win_stack.back()->repaint(); - nextCall = win_stack.back()->keypress(key); - - if(key == -1) - view_back(key); - - if(nextCall) - nextCall(key); - } - while(win_stack.size()); + call_t nextCall; + int key; + do + { + key = wgetch(View::getWinContext()); + win_stack.back()->repaint(); + nextCall = win_stack.back()->keypress(key); + + if(key == -1) + view_back(key); + + if(nextCall) + nextCall(key); + } + while(win_stack.size()); } void view_back(int) { - if(win_stack.size()) - { - delete win_stack.back(); - win_stack.pop_back(); - } - if(win_stack.size()) - win_stack.back()->repaint(); + if(win_stack.size()) + { + delete win_stack.back(); + win_stack.pop_back(); + } + if(win_stack.size()) + win_stack.back()->repaint(); } void finish(int) { - cleanup(); - exit(EXIT_SUCCESS); + cleanup(); + exit(EXIT_SUCCESS); } void cleanup() { - if(t_refresh.joinable()) - t_refresh.join(); - clrtoeol(); - refresh(); - endwin(); + if(t_refresh.joinable()) + t_refresh.join(); + clrtoeol(); + refresh(); + endwin(); } void show_info(int) { - ViewInfo* view = new ViewInfo(); - view->setTitle("Info"); - view->setText("Informationen zu Board 15 Famulus Edition\nEs war einmal..."); - view->setLabelClose("[ Zurueck ]"); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewInfo* view = new ViewInfo(); + view->setTitle("Info"); + view->setText("Informationen zu Board 15 Famulus Edition\nEs war einmal..."); + view->setLabelClose("[ Zurueck ]"); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_monitor(int) { - ViewMonitor* view = new ViewMonitor(); - view->setTitle("Monitor"); - view->setText("\nErfasse Messwerte..."); - view->setLabelClose("[ Zurueck ]"); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewMonitor* view = new ViewMonitor(); + view->setTitle("Monitor"); + view->setText("\nErfasse Messwerte..."); + view->setLabelClose("[ Zurueck ]"); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_invalid_port_input(int) { - ViewInfo* view = new ViewInfo(); - view->setTitle("Falsche Eingabe"); - view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, FF] an."); - view->setLabelClose("[ Schliessen ]"); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewInfo* view = new ViewInfo(); + view->setTitle("Falsche Eingabe"); + view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, FF] an."); + view->setLabelClose("[ Schliessen ]"); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_invalid_dac_input(int) { - ViewInfo* view = new ViewInfo(); - view->setTitle("Falsche Eingabe"); - view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, 1023] an."); - view->setLabelClose("[ Schliessen ]"); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewInfo* view = new ViewInfo(); + view->setTitle("Falsche Eingabe"); + view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, 1023] an."); + view->setLabelClose("[ Schliessen ]"); + view->repaint(); + + win_stack.push_back(view); + input(0); } void write_digital_output0(int) { - try - { - int d = std::stoi(static_cast(win_stack.back())->getInput(), 0, 16); - if(d > 255 || 0 > d) - throw std::invalid_argument("bad value"); - uint8_t port = static_cast(d); - - B15F& drv = B15F::getInstance(); - drv.digitalWrite0(port); - view_back(0); - } - catch(std::invalid_argument& ex) - { - show_invalid_port_input(0); - } + try + { + int d = std::stoi(static_cast(win_stack.back())->getInput(), 0, 16); + if(d > 255 || 0 > d) + throw std::invalid_argument("bad value"); + uint8_t port = static_cast(d); + + B15F& drv = B15F::getInstance(); + drv.digitalWrite0(port); + view_back(0); + } + catch(std::invalid_argument& ex) + { + show_invalid_port_input(0); + } } void write_digital_output1(int) { - try - { - int d = std::stoi(static_cast(win_stack.back())->getInput(), 0, 16); - if(d > 255 || 0 > d) - throw std::invalid_argument("bad value"); - uint8_t port = static_cast(d); - - B15F& drv = B15F::getInstance(); - drv.digitalWrite1(port); - view_back(0); - } - catch(std::invalid_argument& ex) - { - show_invalid_port_input(0); - } + try + { + int d = std::stoi(static_cast(win_stack.back())->getInput(), 0, 16); + if(d > 255 || 0 > d) + throw std::invalid_argument("bad value"); + uint8_t port = static_cast(d); + + B15F& drv = B15F::getInstance(); + drv.digitalWrite1(port); + view_back(0); + } + catch(std::invalid_argument& ex) + { + show_invalid_port_input(0); + } } void write_analog_output0(int) { - try - { - uint16_t port = std::stoi(static_cast(win_stack.back())->getInput()); - if(port > 1023) - throw std::invalid_argument("bad value"); - - B15F& drv = B15F::getInstance(); - drv.analogWrite0(port); - view_back(0); - } - catch(std::invalid_argument& ex) - { - show_invalid_dac_input(0); - } + try + { + uint16_t port = std::stoi(static_cast(win_stack.back())->getInput()); + if(port > 1023) + throw std::invalid_argument("bad value"); + + B15F& drv = B15F::getInstance(); + drv.analogWrite0(port); + view_back(0); + } + catch(std::invalid_argument& ex) + { + show_invalid_dac_input(0); + } } void write_analog_output1(int) { - try - { - uint16_t port = std::stoi(static_cast(win_stack.back())->getInput()); - if(port > 1023) - throw std::invalid_argument("bad value"); - - B15F& drv = B15F::getInstance(); - drv.analogWrite1(port); - view_back(0); - } - catch(std::invalid_argument& ex) - { - show_invalid_dac_input(0); - } + try + { + uint16_t port = std::stoi(static_cast(win_stack.back())->getInput()); + if(port > 1023) + throw std::invalid_argument("bad value"); + + B15F& drv = B15F::getInstance(); + drv.analogWrite1(port); + view_back(0); + } + catch(std::invalid_argument& ex) + { + show_invalid_dac_input(0); + } } void show_digital_output0(int) { - ViewPromt* view = new ViewPromt(); - view->setTitle("Digitale Ausgabe BE0"); - view->setMessage("\nAusgabe Port-Wert (hex): 0x"); - view->setCancel("[ Zurueck ]", true); - view->setConfirm("[ OK ]", &write_digital_output0); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewPromt* view = new ViewPromt(); + view->setTitle("Digitale Ausgabe BE0"); + view->setMessage("\nAusgabe Port-Wert (hex): 0x"); + view->setCancel("[ Zurueck ]", true); + view->setConfirm("[ OK ]", &write_digital_output0); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_digital_output1(int) { - ViewPromt* view = new ViewPromt(); - view->setTitle("Digitale Ausgabe BE1"); - view->setMessage("\nAusgabe Port-Wert (hex): 0x"); - view->setCancel("[ Zurueck ]", true); - view->setConfirm("[ OK ]", &write_digital_output1); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewPromt* view = new ViewPromt(); + view->setTitle("Digitale Ausgabe BE1"); + view->setMessage("\nAusgabe Port-Wert (hex): 0x"); + view->setCancel("[ Zurueck ]", true); + view->setConfirm("[ OK ]", &write_digital_output1); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_analog_output0(int) { - ViewPromt* view = new ViewPromt(); - view->setTitle("Analoge Ausgabe AA0"); - view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): "); - view->setCancel("[ Zurueck ]", true); - view->setConfirm("[ OK ]", &write_analog_output0); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewPromt* view = new ViewPromt(); + view->setTitle("Analoge Ausgabe AA0"); + view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): "); + view->setCancel("[ Zurueck ]", true); + view->setConfirm("[ OK ]", &write_analog_output0); + view->repaint(); + + win_stack.push_back(view); + input(0); } void show_analog_output1(int) { - ViewPromt* view = new ViewPromt(); - view->setTitle("Analoge Ausgabe AA1"); - view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): "); - view->setCancel("[ Zurueck ]", true); - view->setConfirm("[ OK ]", &write_analog_output1); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewPromt* view = new ViewPromt(); + view->setTitle("Analoge Ausgabe AA1"); + view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): "); + view->setCancel("[ Zurueck ]", true); + view->setConfirm("[ OK ]", &write_analog_output1); + view->repaint(); + + win_stack.push_back(view); + input(0); } void start_selftest(int) { - B15F& drv = B15F::getInstance(); - drv.activateSelfTestMode(); - - ViewInfo* view = new ViewInfo(); - view->setTitle("Selbsttest aktiv"); - view->setText("Das B15 befindet sich jetzt im Selbsttestmodus.\n \nSelbsttest:\nZu Beginn geht der Reihe nach jede LED von BA0 bis BA1 an.\nDanach leuchten die LEDs an AA0 und AA1 kurz auf.\nZum Schluss spiegelt in einer Endlosschleife:\n* BA0 Port BE0\n* BA1 die DIP-Schalter S7\n* AA0 ADC0\n* AA1 ADC1"); - view->setLabelClose("[ Selbsttest Beenden ]"); - view->setCall(&stop_selftest); - view->repaint(); - - win_stack.push_back(view); - input(0); + B15F& drv = B15F::getInstance(); + drv.activateSelfTestMode(); + + ViewInfo* view = new ViewInfo(); + view->setTitle("Selbsttest aktiv"); + view->setText("Das B15 befindet sich jetzt im Selbsttestmodus.\n \nSelbsttest:\nZu Beginn geht der Reihe nach jede LED von BA0 bis BA1 an.\nDanach leuchten die LEDs an AA0 und AA1 kurz auf.\nZum Schluss spiegelt in einer Endlosschleife:\n* BA0 Port BE0\n* BA1 die DIP-Schalter S7\n* AA0 ADC0\n* AA1 ADC1"); + view->setLabelClose("[ Selbsttest Beenden ]"); + view->setCall(&stop_selftest); + view->repaint(); + + win_stack.push_back(view); + input(0); } void stop_selftest(int) { - B15F& drv = B15F::getInstance(); - drv.discard(); - drv.delay_ms(B15F::WDT_TIMEOUT); - drv.reconnect(); - drv.digitalWrite0(0); - drv.digitalWrite1(0); + B15F& drv = B15F::getInstance(); + drv.discard(); + drv.delay_ms(B15F::WDT_TIMEOUT); + drv.reconnect(); + drv.digitalWrite0(0); + drv.digitalWrite1(0); } void show_selftest_info(int) { - ViewInfo* view = new ViewInfo(); - view->setTitle("Selbsttest"); - view->setText("Bitte entfernen Sie jetzt alle Draehte von den Anschlussklemmen und bestaetigen\nmit Enter."); - view->setLabelClose("[ Weiter ]"); - view->setCall(&start_selftest); - view->repaint(); - - win_stack.push_back(view); - input(0); + ViewInfo* view = new ViewInfo(); + view->setTitle("Selbsttest"); + view->setText("Bitte entfernen Sie jetzt alle Draehte von den Anschlussklemmen und bestaetigen\nmit Enter."); + view->setLabelClose("[ Weiter ]"); + view->setCall(&start_selftest); + view->repaint(); + + win_stack.push_back(view); + input(0); } diff --git a/control/src/ui/view.cpp b/control/src/ui/view.cpp index af3e590..8154379 100644 --- a/control/src/ui/view.cpp +++ b/control/src/ui/view.cpp @@ -4,12 +4,12 @@ WINDOW* View::win = nullptr; View::View() { - if(!win) - { - B15F::abort("View::win not initialized, missing context"); - } - getmaxyx(win, height, width); // init width and height - keypad(win, TRUE); + if(!win) + { + B15F::abort("View::win not initialized, missing context"); + } + getmaxyx(win, height, width); // init width and height + keypad(win, TRUE); } View::~View() @@ -18,12 +18,12 @@ View::~View() void View::setWinContext(WINDOW* win) { - View::win = win; + View::win = win; } WINDOW* View::getWinContext() { - return win; + return win; } // from: https://stackoverflow.com/a/37454181 @@ -46,33 +46,33 @@ std::vector View::str_split(const std::string& str, const std::stri void View::setTitle(std::string title) { - this->title = title; + this->title = title; } void View::repaint() { - // get screen size - struct winsize size; - if (ioctl(0, TIOCGWINSZ, (char *) &size) < 0) - throw std::runtime_error("TIOCGWINSZ error"); - - - start_x = floor((size.ws_col - width) / 2.); - start_y = floor((size.ws_row - height) / 2.); - - curs_set(0); // hide cursor - mvwin(win, start_y, start_x); - clear(); - wclear(win); - - // generic draw - box(win, 0, 0); - int offset_x = (width - title.length()) / 2; - mvwprintw(win, 1, offset_x, "%s", title.c_str()); - - // specific draw - draw(); + // get screen size + struct winsize size; + if (ioctl(0, TIOCGWINSZ, (char *) &size) < 0) + throw std::runtime_error("TIOCGWINSZ error"); - refresh(); - wrefresh(win); + + start_x = floor((size.ws_col - width) / 2.); + start_y = floor((size.ws_row - height) / 2.); + + curs_set(0); // hide cursor + mvwin(win, start_y, start_x); + clear(); + wclear(win); + + // generic draw + box(win, 0, 0); + int offset_x = (width - title.length()) / 2; + mvwprintw(win, 1, offset_x, "%s", title.c_str()); + + // specific draw + draw(); + + refresh(); + wrefresh(win); } diff --git a/control/src/ui/view.h b/control/src/ui/view.h index 1445035..a63043b 100644 --- a/control/src/ui/view.h +++ b/control/src/ui/view.h @@ -14,32 +14,34 @@ extern std::string ERR_MSG; typedef std::function call_t; +/*! Base class for multiple views with the ncurses user interface. */ + class View { public: - View(void); - virtual ~View(void); - - static void setWinContext(WINDOW* win); - static WINDOW* getWinContext(void); - static std::vector str_split(const std::string& str, const std::string delim); - - virtual void setTitle(std::string title); - - virtual void repaint(void); - - virtual void draw(void) = 0; - virtual call_t keypress(int& key) = 0; - - + View(void); + virtual ~View(void); + + static void setWinContext(WINDOW* win); + static WINDOW* getWinContext(void); + static std::vector str_split(const std::string& str, const std::string delim); + + virtual void setTitle(std::string title); + + virtual void repaint(void); + + virtual void draw(void) = 0; + virtual call_t keypress(int& key) = 0; + + protected: - int width, height; - int start_x = 0, start_y = 0; - std::string title; - std::vector calls; - - static WINDOW* win; - constexpr static int KEY_ENT = 10; + int width, height; + int start_x = 0, start_y = 0; + std::string title; + std::vector calls; + + static WINDOW* win; + constexpr static int KEY_ENT = 10; }; #endif // VIEW_H diff --git a/control/src/ui/view_info.cpp b/control/src/ui/view_info.cpp index 056ef0f..5adabbc 100644 --- a/control/src/ui/view_info.cpp +++ b/control/src/ui/view_info.cpp @@ -2,62 +2,62 @@ ViewInfo::ViewInfo() { - calls.push_back(nullptr); + calls.push_back(nullptr); } void ViewInfo::setText(std::string text) { - this->text = text; + this->text = text; } void ViewInfo::setLabelClose(std::string label) { - this->label_close = label; + this->label_close = label; } void ViewInfo::setCall(call_t call) { - calls[0] = call; + calls[0] = call; } void ViewInfo::draw() { - int li = 0; - for(std::string line : str_split(text, "\n")) - mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str()); - - close_offset_x = (width - label_close.length()) / 2; - close_offset_y = height - 2; - - wattron(win, A_REVERSE); - mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str()); - wattroff(win, A_REVERSE); + int li = 0; + for(std::string line : str_split(text, "\n")) + mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str()); + + close_offset_x = (width - label_close.length()) / 2; + close_offset_y = height - 2; + + wattron(win, A_REVERSE); + mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str()); + wattroff(win, A_REVERSE); } call_t ViewInfo::keypress(int& key) { - switch(key) - { - - case KEY_MOUSE: - { - // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml - MEVENT event; - if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) - { - size_t column = start_x + close_offset_x; - size_t row = start_y + close_offset_y; - size_t mouse_x = event.x, mouse_y = event.y; - if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length()) - key = -1; // do return from view - } - break; - } - case KEY_ENT: - key = -1; // do return from view - break; - default: - break; - } - return calls[0]; + switch(key) + { + + case KEY_MOUSE: + { + // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml + MEVENT event; + if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + { + size_t column = start_x + close_offset_x; + size_t row = start_y + close_offset_y; + size_t mouse_x = event.x, mouse_y = event.y; + if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length()) + key = -1; // do return from view + } + break; + } + case KEY_ENT: + key = -1; // do return from view + break; + default: + break; + } + return calls[0]; } diff --git a/control/src/ui/view_info.h b/control/src/ui/view_info.h index be5cbf4..7a3eb4b 100644 --- a/control/src/ui/view_info.h +++ b/control/src/ui/view_info.h @@ -3,23 +3,25 @@ #include "view.h" +/*! View for simple text message output. */ + class ViewInfo : public View { public: - ViewInfo(void); - virtual void setText(std::string text); - virtual void setLabelClose(std::string label);; - virtual void setCall(call_t call); - virtual void draw(void) override; - virtual call_t keypress(int& key) override; + ViewInfo(void); + virtual void setText(std::string text); + virtual void setLabelClose(std::string label);; + virtual void setCall(call_t call); + virtual void draw(void) override; + virtual call_t keypress(int& key) override; protected: - std::string text; - std::string label_close; - int close_offset_x = 0; - int close_offset_y = 0; - constexpr static int text_offset_x = 2; - constexpr static int text_offset_y = 3; + std::string text; + std::string label_close; + int close_offset_x = 0; + int close_offset_y = 0; + constexpr static int text_offset_x = 2; + constexpr static int text_offset_y = 3; }; #endif // VIEW_INFO diff --git a/control/src/ui/view_monitor.cpp b/control/src/ui/view_monitor.cpp index 8697eef..f309b6f 100644 --- a/control/src/ui/view_monitor.cpp +++ b/control/src/ui/view_monitor.cpp @@ -1,139 +1,139 @@ #include "view_monitor.h" ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this) -{ +{ } call_t ViewMonitor::keypress(int& key) { - switch(key) - { - - case KEY_MOUSE: - { - // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml - MEVENT event; - bool hit = false; - if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) - { - size_t column = start_x + close_offset_x; - size_t row = start_y + close_offset_y; - size_t mouse_x = event.x, mouse_y = event.y; - if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length()) - hit = true; - } - if(!hit) - break; - - // fall through to next case - [[fallthrough]]; - } - case KEY_ENT: - run_worker = false; - key = -1; // do return from view - wclear(win); - wrefresh(win); - t_worker.join(); - break; - default: - break; - } - return calls[0]; + switch(key) + { + + case KEY_MOUSE: + { + // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml + MEVENT event; + bool hit = false; + if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + { + size_t column = start_x + close_offset_x; + size_t row = start_y + close_offset_y; + size_t mouse_x = event.x, mouse_y = event.y; + if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length()) + hit = true; + } + if(!hit) + break; + + // fall through to next case + [[fallthrough]]; + } + case KEY_ENT: + run_worker = false; + key = -1; // do return from view + wclear(win); + wrefresh(win); + t_worker.join(); + break; + default: + break; + } + return calls[0]; } std::string ViewMonitor::fancyDigitalString(uint8_t& b) { - std::stringstream str; - str << std::bitset<8>(b).to_string(); - str << " "; - str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec; - return str.str(); + std::stringstream str; + str << std::bitset<8>(b).to_string(); + str << " "; + str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec; + return str.str(); } std::string ViewMonitor::fancyAnalogString(uint16_t& v) { - std::stringstream str; - double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0; - - str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V "; - - str << "["; - uint8_t p = round(v * 40.0 / 1023.0); - for(uint8_t i = 0; i < p; i++) - str << "X"; - for(uint8_t i = 0; i < 40 - p; i++) - str << " "; - str << "]" << std::endl; - - return str.str(); + std::stringstream str; + double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0; + + str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V "; + + str << "["; + uint8_t p = round(v * 40.0 / 1023.0); + for(uint8_t i = 0; i < p; i++) + str << "X"; + for(uint8_t i = 0; i < 40 - p; i++) + str << " "; + str << "]" << std::endl; + + return str.str(); } void ViewMonitor::worker() { - B15F& drv = B15F::getInstance(); - while(run_worker) - { - try - { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - uint8_t be0 = drv.digitalRead0(); - uint8_t be1 = drv.digitalRead1(); - uint8_t dsw = drv.readDipSwitch(); - uint16_t adc[8]; - for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) - adc[i] = drv.analogRead(i); - - - std::stringstream str; - - // hline - for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) - if(i % 2 == 0) - str << "-"; - else - str << " "; - str << std::endl; - - str << "Digitale Enigaenge:" << std::endl; - str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl; - str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl; - str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl; - - // hline - for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) - if(i % 2 == 0) - str << "-"; - else - str << " "; - str << std::endl; - - str << "Analoge Eingaenge:" << std::endl; - for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) - { - str << "Kanal " << std::to_string((int) i) << ": "; - str << fancyAnalogString(adc[i]) << std::endl; - } - - text = str.str(); - repaint(); - } - catch(DriverException& ex) - { - std::cout << "DriverException: " << ex.what() << std::endl; - drv.delay_ms(1000); - } - catch(...) - { - try - { - drv.reconnect(); - } - catch(...) - { - B15F::abort("yoho meine dudes"); - return; - } - } - } + B15F& drv = B15F::getInstance(); + while(run_worker) + { + try + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + uint8_t be0 = drv.digitalRead0(); + uint8_t be1 = drv.digitalRead1(); + uint8_t dsw = drv.readDipSwitch(); + uint16_t adc[8]; + for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) + adc[i] = drv.analogRead(i); + + + std::stringstream str; + + // hline + for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) + if(i % 2 == 0) + str << "-"; + else + str << " "; + str << std::endl; + + str << "Digitale Enigaenge:" << std::endl; + str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl; + str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl; + str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl; + + // hline + for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) + if(i % 2 == 0) + str << "-"; + else + str << " "; + str << std::endl; + + str << "Analoge Eingaenge:" << std::endl; + for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) + { + str << "Kanal " << std::to_string((int) i) << ": "; + str << fancyAnalogString(adc[i]) << std::endl; + } + + text = str.str(); + repaint(); + } + catch(DriverException& ex) + { + std::cout << "DriverException: " << ex.what() << std::endl; + drv.delay_ms(1000); + } + catch(...) + { + try + { + drv.reconnect(); + } + catch(...) + { + B15F::abort("yoho meine dudes"); + return; + } + } + } } diff --git a/control/src/ui/view_monitor.h b/control/src/ui/view_monitor.h index 33552bf..9ab39b5 100644 --- a/control/src/ui/view_monitor.h +++ b/control/src/ui/view_monitor.h @@ -8,22 +8,24 @@ #include "view_info.h" #include "../drv/b15f.h" +/*! View to display all B15 inputs. */ + class ViewMonitor : public ViewInfo { - + public: - ViewMonitor(void); - virtual call_t keypress(int& key) override; + ViewMonitor(void); + virtual call_t keypress(int& key) override; private: - std::string fancyDigitalString(uint8_t& b); - std::string fancyAnalogString(uint16_t& v); + std::string fancyDigitalString(uint8_t& b); + std::string fancyAnalogString(uint16_t& v); protected: - virtual void worker(void); - volatile bool run_worker = true; - std::thread t_worker; - + virtual void worker(void); + volatile bool run_worker = true; + std::thread t_worker; + }; #endif // VIEW_MONITOR_H diff --git a/control/src/ui/view_promt.cpp b/control/src/ui/view_promt.cpp index bd57829..3705aaf 100644 --- a/control/src/ui/view_promt.cpp +++ b/control/src/ui/view_promt.cpp @@ -2,120 +2,120 @@ void ViewPromt::draw() { - curs_set(1); // show cursor - - int li = text_offset_y; - int ci = 0; - for(std::string line : str_split(message + input, "\n")) - { - mvwprintw(win, ++li, text_offset_x, "%s", line.c_str()); - ci = line.length() + text_offset_x; - } - - button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2; - button_offset_y = height - text_offset_y; - - if(selection == 0) - { - wattron(win, A_REVERSE); - mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str()); - wattroff(win, A_REVERSE); - mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str()); - mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str()); - } - else - { - mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str()); - mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str()); - wattron(win, A_REVERSE); - mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str()); - wattroff(win, A_REVERSE); - } - wmove(win, li, ci); + curs_set(1); // show cursor + + int li = text_offset_y; + int ci = 0; + for(std::string line : str_split(message + input, "\n")) + { + mvwprintw(win, ++li, text_offset_x, "%s", line.c_str()); + ci = line.length() + text_offset_x; + } + + button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2; + button_offset_y = height - text_offset_y; + + if(selection == 0) + { + wattron(win, A_REVERSE); + mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str()); + wattroff(win, A_REVERSE); + mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str()); + mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str()); + } + else + { + mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str()); + mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str()); + wattron(win, A_REVERSE); + mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str()); + wattroff(win, A_REVERSE); + } + wmove(win, li, ci); } void ViewPromt::setMessage(std::string message) { - this->message = message; + this->message = message; } void ViewPromt::setConfirm(std::string name, std::function call) { - label_confirm = name; - call_confirm = call; + label_confirm = name; + call_confirm = call; } void ViewPromt::setCancel(std::string name, bool cancelable) { - label_cancel = name; - this->cancelable = cancelable; + label_cancel = name; + this->cancelable = cancelable; } std::string ViewPromt::getInput() { - return input; + return input; } std::function ViewPromt::keypress(int& key) -{ - std::function ret = nullptr; - switch(key) - { - case KEY_BACKSPACE: - if(input.length()) - input.pop_back(); - break; - case '\t': - case KEY_LEFT: - case KEY_RIGHT: - selection = (selection + 1 ) % 2; - break; - case KEY_MOUSE: - { - // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml - MEVENT event; - bool hit = false; - if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) - { - size_t column_start = start_x + button_offset_x; - size_t row_start = start_y + button_offset_y; - size_t mouse_x = event.x, mouse_y = event.y; - if(mouse_y == row_start) - { - if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length()) - { - if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED) - hit = true; - selection = 0; - } - if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length()) - { - if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED) - hit = true; - selection = 1; - } - } - } - if(!hit) - break; - - // fall through to next case - [[fallthrough]]; - } - case KEY_ENT: - if(selection == 0) // exit - key = -1; // do return from view - else - ret = call_confirm; - break; - default: - break; - } - - if(key >= ' ' && key <= '~') - input += (char) key; - - if(key != KEY_ENT) +{ + std::function ret = nullptr; + switch(key) + { + case KEY_BACKSPACE: + if(input.length()) + input.pop_back(); + break; + case '\t': + case KEY_LEFT: + case KEY_RIGHT: + selection = (selection + 1 ) % 2; + break; + case KEY_MOUSE: + { + // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml + MEVENT event; + bool hit = false; + if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + { + size_t column_start = start_x + button_offset_x; + size_t row_start = start_y + button_offset_y; + size_t mouse_x = event.x, mouse_y = event.y; + if(mouse_y == row_start) + { + if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length()) + { + if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED) + hit = true; + selection = 0; + } + if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length()) + { + if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED) + hit = true; + selection = 1; + } + } + } + if(!hit) + break; + + // fall through to next case + [[fallthrough]]; + } + case KEY_ENT: + if(selection == 0) // exit + key = -1; // do return from view + else + ret = call_confirm; + break; + default: + break; + } + + if(key >= ' ' && key <= '~') + input += (char) key; + + if(key != KEY_ENT) repaint(); - return ret; + return ret; } diff --git a/control/src/ui/view_promt.h b/control/src/ui/view_promt.h index fb74100..a43ae5b 100644 --- a/control/src/ui/view_promt.h +++ b/control/src/ui/view_promt.h @@ -5,28 +5,30 @@ #include #include "view.h" +/*! View for basic user text input. */ + class ViewPromt : public View { public: - virtual void draw(void) override; - virtual void setMessage(std::string message); - virtual void setConfirm(std::string name, call_t call); - virtual void setCancel(std::string name, bool cancelable); - virtual std::string getInput(void); - virtual call_t keypress(int& key) override; + virtual void draw(void) override; + virtual void setMessage(std::string message); + virtual void setConfirm(std::string name, call_t call); + virtual void setCancel(std::string name, bool cancelable); + virtual std::string getInput(void); + virtual call_t keypress(int& key) override; protected: - size_t selection = 1; - std::string input; - std::string message = "Input"; - std::string label_confirm = "[ OK ]"; - std::string sep = " "; - std::string label_cancel = "[ Cancel ]"; - call_t call_confirm = nullptr; - bool cancelable = true; - int button_offset_x = 0, button_offset_y = 0; - constexpr static int text_offset_x = 2; - constexpr static int text_offset_y = 2; + size_t selection = 1; + std::string input; + std::string message = "Input"; + std::string label_confirm = "[ OK ]"; + std::string sep = " "; + std::string label_cancel = "[ Cancel ]"; + call_t call_confirm = nullptr; + bool cancelable = true; + int button_offset_x = 0, button_offset_y = 0; + constexpr static int text_offset_x = 2; + constexpr static int text_offset_y = 2; }; #endif // VIEW_PROMT_H diff --git a/control/src/ui/view_selection.cpp b/control/src/ui/view_selection.cpp index 454c3ab..e0899cd 100644 --- a/control/src/ui/view_selection.cpp +++ b/control/src/ui/view_selection.cpp @@ -2,75 +2,75 @@ void ViewSelection::draw() { - //curs_set(0); // hide cursor - for(size_t i = 0; i < choices.size(); i++) - { - if(selection == i) - wattron(win, A_REVERSE); - mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str()); - if(selection == i) - wattroff(win, A_REVERSE); - } + //curs_set(0); // hide cursor + for(size_t i = 0; i < choices.size(); i++) + { + if(selection == i) + wattron(win, A_REVERSE); + mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str()); + if(selection == i) + wattroff(win, A_REVERSE); + } } void ViewSelection::addChoice(std::string name, call_t call) { - choices.push_back(name); - calls.push_back(call); + choices.push_back(name); + calls.push_back(call); } call_t ViewSelection::keypress(int& key) { - call_t ret = nullptr; - switch(key) - { - case KEY_UP: - do - selection = (selection - 1 + choices.size()) % choices.size(); - while(!choices[selection].length() && choices.size()); - break; - - case '\t': - case KEY_DOWN: - do - selection = (selection + 1) % choices.size(); - while(!choices[selection].length() && choices.size()); - break; - - case KEY_MOUSE: - { - // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml - MEVENT event; - bool hit = false; - if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) - { - size_t column_start = start_x + choice_offset_x; - size_t row_start = start_y + choice_offset_y; - size_t mouse_x = event.x, mouse_y = event.y; - for(size_t i = 0; i < choices.size(); i++) - if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length()) - { - if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED) - hit = true; - selection = i; - } - } - if(!hit) - break; - - // fall through to next case - [[fallthrough]]; - } - - case KEY_ENT: - if(selection == choices.size() - 1) // exit - key = -1; // do return from view - else - ret = calls[selection]; - break; - default: - break; - } - repaint(); - return ret; + call_t ret = nullptr; + switch(key) + { + case KEY_UP: + do + selection = (selection - 1 + choices.size()) % choices.size(); + while(!choices[selection].length() && choices.size()); + break; + + case '\t': + case KEY_DOWN: + do + selection = (selection + 1) % choices.size(); + while(!choices[selection].length() && choices.size()); + break; + + case KEY_MOUSE: + { + // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml + MEVENT event; + bool hit = false; + if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + { + size_t column_start = start_x + choice_offset_x; + size_t row_start = start_y + choice_offset_y; + size_t mouse_x = event.x, mouse_y = event.y; + for(size_t i = 0; i < choices.size(); i++) + if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length()) + { + if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED) + hit = true; + selection = i; + } + } + if(!hit) + break; + + // fall through to next case + [[fallthrough]]; + } + + case KEY_ENT: + if(selection == choices.size() - 1) // exit + key = -1; // do return from view + else + ret = calls[selection]; + break; + default: + break; + } + repaint(); + return ret; } diff --git a/control/src/ui/view_selection.h b/control/src/ui/view_selection.h index 4963f73..d97e062 100644 --- a/control/src/ui/view_selection.h +++ b/control/src/ui/view_selection.h @@ -5,20 +5,22 @@ #include #include "view.h" +/*! View for user selection input. */ + class ViewSelection : public View { public: - virtual void draw(void) override; - virtual void addChoice(std::string name, call_t call); - virtual call_t keypress(int& key) override; - + virtual void draw(void) override; + virtual void addChoice(std::string name, call_t call); + virtual call_t keypress(int& key) override; + protected: - size_t selection = 0; - std::vector choices; - - constexpr static int choice_offset_x = 2; - constexpr static int choice_offset_y = 3; + size_t selection = 0; + std::vector choices; + + constexpr static int choice_offset_x = 2; + constexpr static int choice_offset_y = 3; }; #endif // VIEW_SELECTION_H diff --git a/docs/atmegaiom1284p.h b/docs/atmegaiom1284p.h new file mode 100644 index 0000000..905029d --- /dev/null +++ b/docs/atmegaiom1284p.h @@ -0,0 +1,1219 @@ +/* Copyright (c) 2007 Atmel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +/* $Id: iom1284p.h 2225 2011-03-02 16:27:26Z arcanum $ */ + +/* avr/iom1284p.h - definitions for ATmega1284P. */ + +/* This file should only be included from , never directly. */ + +#ifndef _AVR_IO_H_ +# error "Include instead of this file." +#endif + +#ifndef _AVR_IOXXX_H_ +# define _AVR_IOXXX_H_ "iom1284p.h" +#else +# error "Attempt to include more than one file." +#endif + + +#ifndef _AVR_IOM1284P_H_ +#define _AVR_IOM1284P_H_ 1 + + +/* Registers and associated bit numbers */ + +#define PINA _SFR_IO8(0x00) +#define PINA0 0 +#define PINA1 1 +#define PINA2 2 +#define PINA3 3 +#define PINA4 4 +#define PINA5 5 +#define PINA6 6 +#define PINA7 7 + +#define DDRA _SFR_IO8(0x01) +#define DDA0 0 +#define DDA1 1 +#define DDA2 2 +#define DDA3 3 +#define DDA4 4 +#define DDA5 5 +#define DDA6 6 +#define DDA7 7 + +#define PORTA _SFR_IO8(0x02) +#define PORTA0 0 +#define PORTA1 1 +#define PORTA2 2 +#define PORTA3 3 +#define PORTA4 4 +#define PORTA5 5 +#define PORTA6 6 +#define PORTA7 7 + +#define PINB _SFR_IO8(0x03) +#define PINB0 0 +#define PINB1 1 +#define PINB2 2 +#define PINB3 3 +#define PINB4 4 +#define PINB5 5 +#define PINB6 6 +#define PINB7 7 + +#define DDRB _SFR_IO8(0x04) +#define DDB0 0 +#define DDB1 1 +#define DDB2 2 +#define DDB3 3 +#define DDB4 4 +#define DDB5 5 +#define DDB6 6 +#define DDB7 7 + +#define PORTB _SFR_IO8(0x05) +#define PORTB0 0 +#define PORTB1 1 +#define PORTB2 2 +#define PORTB3 3 +#define PORTB4 4 +#define PORTB5 5 +#define PORTB6 6 +#define PORTB7 7 + +#define PINC _SFR_IO8(0x06) +#define PINC0 0 +#define PINC1 1 +#define PINC2 2 +#define PINC3 3 +#define PINC4 4 +#define PINC5 5 +#define PINC6 6 +#define PINC7 7 + +#define DDRC _SFR_IO8(0x07) +#define DDC0 0 +#define DDC1 1 +#define DDC2 2 +#define DDC3 3 +#define DDC4 4 +#define DDC5 5 +#define DDC6 6 +#define DDC7 7 + +#define PORTC _SFR_IO8(0x08) +#define PORTC0 0 +#define PORTC1 1 +#define PORTC2 2 +#define PORTC3 3 +#define PORTC4 4 +#define PORTC5 5 +#define PORTC6 6 +#define PORTC7 7 + +#define PIND _SFR_IO8(0x09) +#define PIND0 0 +#define PIND1 1 +#define PIND2 2 +#define PIND3 3 +#define PIND4 4 +#define PIND5 5 +#define PIND6 6 +#define PIND7 7 + +#define DDRD _SFR_IO8(0x0A) +#define DDD0 0 +#define DDD1 1 +#define DDD2 2 +#define DDD3 3 +#define DDD4 4 +#define DDD5 5 +#define DDD6 6 +#define DDD7 7 + +#define PORTD _SFR_IO8(0x0B) +#define PORTD0 0 +#define PORTD1 1 +#define PORTD2 2 +#define PORTD3 3 +#define PORTD4 4 +#define PORTD5 5 +#define PORTD6 6 +#define PORTD7 7 + +#define TIFR0 _SFR_IO8(0x15) +#define TOV0 0 +#define OCF0A 1 +#define OCF0B 2 + +#define TIFR1 _SFR_IO8(0x16) +#define TOV1 0 +#define OCF1A 1 +#define OCF1B 2 +#define ICF1 5 + +#define TIFR2 _SFR_IO8(0x17) +#define TOV2 0 +#define OCF2A 1 +#define OCF2B 2 + +#define TIFR3 _SFR_IO8(0x18) +#define TOV3 0 +#define OCF3A 1 +#define OCF3B 2 +#define ICF3 5 + +#define PCIFR _SFR_IO8(0x1B) +#define PCIF0 0 +#define PCIF1 1 +#define PCIF2 2 +#define PCIF3 3 + +#define EIFR _SFR_IO8(0x1C) +#define INTF0 0 +#define INTF1 1 +#define INTF2 2 + +#define EIMSK _SFR_IO8(0x1D) +#define INT0 0 +#define INT1 1 +#define INT2 2 + +#define GPIOR0 _SFR_IO8(0x1E) +#define GPIOR00 0 +#define GPIOR01 1 +#define GPIOR02 2 +#define GPIOR03 3 +#define GPIOR04 4 +#define GPIOR05 5 +#define GPIOR06 6 +#define GPIOR07 7 + +#define EECR _SFR_IO8(0x1F) +#define EERE 0 +#define EEPE 1 +#define EEMPE 2 +#define EERIE 3 +#define EEPM0 4 +#define EEPM1 5 + +#define EEDR _SFR_IO8(0x20) +#define EEDR0 0 +#define EEDR1 1 +#define EEDR2 2 +#define EEDR3 3 +#define EEDR4 4 +#define EEDR5 5 +#define EEDR6 6 +#define EEDR7 7 + +#define EEAR _SFR_IO16(0x21) + +#define EEARL _SFR_IO8(0x21) +#define EEAR0 0 +#define EEAR1 1 +#define EEAR2 2 +#define EEAR3 3 +#define EEAR4 4 +#define EEAR5 5 +#define EEAR6 6 +#define EEAR7 7 + +#define EEARH _SFR_IO8(0x22) +#define EEAR8 0 +#define EEAR9 1 +#define EEAR10 2 +#define EEAR11 3 + +#define GTCCR _SFR_IO8(0x23) +#define PSRSYNC 0 +#define PSRASY 1 +#define TSM 7 + +#define TCCR0A _SFR_IO8(0x24) +#define WGM00 0 +#define WGM01 1 +#define COM0B0 4 +#define COM0B1 5 +#define COM0A0 6 +#define COM0A1 7 + +#define TCCR0B _SFR_IO8(0x25) +#define CS00 0 +#define CS01 1 +#define CS02 2 +#define WGM02 3 +#define FOC0B 6 +#define FOC0A 7 + +#define TCNT0 _SFR_IO8(0x26) +#define TCNT0_0 0 +#define TCNT0_1 1 +#define TCNT0_2 2 +#define TCNT0_3 3 +#define TCNT0_4 4 +#define TCNT0_5 5 +#define TCNT0_6 6 +#define TCNT0_7 7 + +#define OCR0A _SFR_IO8(0x27) +#define OCR0A_0 0 +#define OCR0A_1 1 +#define OCR0A_2 2 +#define OCR0A_3 3 +#define OCR0A_4 4 +#define OCR0A_5 5 +#define OCR0A_6 6 +#define OCR0A_7 7 + +#define OCR0B _SFR_IO8(0x28) +#define OCR0B_0 0 +#define OCR0B_1 1 +#define OCR0B_2 2 +#define OCR0B_3 3 +#define OCR0B_4 4 +#define OCR0B_5 5 +#define OCR0B_6 6 +#define OCR0B_7 7 + +#define GPIOR1 _SFR_IO8(0x2A) +#define GPIOR10 0 +#define GPIOR11 1 +#define GPIOR12 2 +#define GPIOR13 3 +#define GPIOR14 4 +#define GPIOR15 5 +#define GPIOR16 6 +#define GPIOR17 7 + +#define GPIOR2 _SFR_IO8(0x2B) +#define GPIOR20 0 +#define GPIOR21 1 +#define GPIOR22 2 +#define GPIOR23 3 +#define GPIOR24 4 +#define GPIOR25 5 +#define GPIOR26 6 +#define GPIOR27 7 + +#define SPCR _SFR_IO8(0x2C) +#define SPR0 0 +#define SPR1 1 +#define CPHA 2 +#define CPOL 3 +#define MSTR 4 +#define DORD 5 +#define SPE 6 +#define SPIE 7 + +#define SPSR _SFR_IO8(0x2D) +#define SPI2X 0 +#define WCOL 6 +#define SPIF 7 + +#define SPDR _SFR_IO8(0x2E) +#define SPDR0 0 +#define SPDR1 1 +#define SPDR2 2 +#define SPDR3 3 +#define SPDR4 4 +#define SPDR5 5 +#define SPDR6 6 +#define SPDR7 7 + +#define ACSR _SFR_IO8(0x30) +#define ACIS0 0 +#define ACIS1 1 +#define ACIC 2 +#define ACIE 3 +#define ACI 4 +#define ACO 5 +#define ACBG 6 +#define ACD 7 + +#define OCDR _SFR_IO8(0x31) +#define OCDR0 0 +#define OCDR1 1 +#define OCDR2 2 +#define OCDR3 3 +#define OCDR4 4 +#define OCDR5 5 +#define OCDR6 6 +#define OCDR7 7 + +#define SMCR _SFR_IO8(0x33) +#define SE 0 +#define SM0 1 +#define SM1 2 +#define SM2 3 + +#define MCUSR _SFR_IO8(0x34) +#define PORF 0 +#define EXTRF 1 +#define BORF 2 +#define WDRF 3 +#define JTRF 4 + +#define MCUCR _SFR_IO8(0x35) +#define IVCE 0 +#define IVSEL 1 +#define PUD 4 +#define BODSE 5 +#define BODS 6 +#define JTD 7 + +#define SPMCSR _SFR_IO8(0x37) +#define SPMEN 0 +#define PGERS 1 +#define PGWRT 2 +#define BLBSET 3 +#define RWWSRE 4 +#define SIGRD 5 +#define RWWSB 6 +#define SPMIE 7 + +#define RAMPZ _SFR_IO8(0x3B) +#define RAMPZ0 0 + +#define WDTCSR _SFR_MEM8(0x60) +#define WDP0 0 +#define WDP1 1 +#define WDP2 2 +#define WDE 3 +#define WDCE 4 +#define WDP3 5 +#define WDIE 6 +#define WDIF 7 + +#define CLKPR _SFR_MEM8(0x61) +#define CLKPS0 0 +#define CLKPS1 1 +#define CLKPS2 2 +#define CLKPS3 3 +#define CLKPCE 7 + +#define PRR0 _SFR_MEM8(0x64) +#define PRADC 0 +#define PRUSART0 1 +#define PRSPI 2 +#define PRTIM1 3 +#define PRUSART1 4 +#define PRTIM0 5 +#define PRTIM2 6 +#define PRTWI 7 + +#define __AVR_HAVE_PRR0 ((1< + + + + + + +B15F: cmake-build-debug/CMakeFiles/3.14.3/CompilerIdC/CMakeCCompilerId.c Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
CMakeCCompilerId.c
+
+
+
1 #ifdef __cplusplus
2 # error "A C++ compiler has been selected for C."
3 #endif
4 
5 #if defined(__18CXX)
6 # define ID_VOID_MAIN
7 #endif
8 #if defined(__CLASSIC_C__)
9 /* cv-qualifiers did not exist in K&R C */
10 # define const
11 # define volatile
12 #endif
13 
14 
15 /* Version number components: V=Version, R=Revision, P=Patch
16  Version date components: YYYY=Year, MM=Month, DD=Day */
17 
18 #if defined(__INTEL_COMPILER) || defined(__ICC)
19 # define COMPILER_ID "Intel"
20 # if defined(_MSC_VER)
21 # define SIMULATE_ID "MSVC"
22 # endif
23 /* __INTEL_COMPILER = VRP */
24 # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
25 # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
26 # if defined(__INTEL_COMPILER_UPDATE)
27 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
28 # else
29 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
30 # endif
31 # if defined(__INTEL_COMPILER_BUILD_DATE)
32 /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
33 # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
34 # endif
35 # if defined(_MSC_VER)
36 /* _MSC_VER = VVRR */
37 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
38 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
39 # endif
40 
41 #elif defined(__PATHCC__)
42 # define COMPILER_ID "PathScale"
43 # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
44 # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
45 # if defined(__PATHCC_PATCHLEVEL__)
46 # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
47 # endif
48 
49 #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
50 # define COMPILER_ID "Embarcadero"
51 # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
52 # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
53 # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
54 
55 #elif defined(__BORLANDC__)
56 # define COMPILER_ID "Borland"
57 /* __BORLANDC__ = 0xVRR */
58 # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
59 # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
60 
61 #elif defined(__WATCOMC__) && __WATCOMC__ < 1200
62 # define COMPILER_ID "Watcom"
63 /* __WATCOMC__ = VVRR */
64 # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
65 # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
66 # if (__WATCOMC__ % 10) > 0
67 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
68 # endif
69 
70 #elif defined(__WATCOMC__)
71 # define COMPILER_ID "OpenWatcom"
72 /* __WATCOMC__ = VVRP + 1100 */
73 # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
74 # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
75 # if (__WATCOMC__ % 10) > 0
76 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
77 # endif
78 
79 #elif defined(__SUNPRO_C)
80 # define COMPILER_ID "SunPro"
81 # if __SUNPRO_C >= 0x5100
82 /* __SUNPRO_C = 0xVRRP */
83 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
84 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
85 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
86 # else
87 /* __SUNPRO_CC = 0xVRP */
88 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
89 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
90 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
91 # endif
92 
93 #elif defined(__HP_cc)
94 # define COMPILER_ID "HP"
95 /* __HP_cc = VVRRPP */
96 # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
97 # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
98 # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
99 
100 #elif defined(__DECC)
101 # define COMPILER_ID "Compaq"
102 /* __DECC_VER = VVRRTPPPP */
103 # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
104 # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
105 # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
106 
107 #elif defined(__IBMC__) && defined(__COMPILER_VER__)
108 # define COMPILER_ID "zOS"
109 # if defined(__ibmxl__)
110 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
111 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
112 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
113 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
114 # else
115 /* __IBMC__ = VRP */
116 # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
117 # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
118 # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
119 # endif
120 
121 
122 #elif defined(__ibmxl__) || (defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800)
123 # define COMPILER_ID "XL"
124 # if defined(__ibmxl__)
125 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
126 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
127 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
128 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
129 # else
130 /* __IBMC__ = VRP */
131 # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
132 # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
133 # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
134 # endif
135 
136 
137 #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
138 # define COMPILER_ID "VisualAge"
139 # if defined(__ibmxl__)
140 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
141 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
142 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
143 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
144 # else
145 /* __IBMC__ = VRP */
146 # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
147 # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
148 # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
149 # endif
150 
151 
152 #elif defined(__PGI)
153 # define COMPILER_ID "PGI"
154 # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
155 # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
156 # if defined(__PGIC_PATCHLEVEL__)
157 # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
158 # endif
159 
160 #elif defined(_CRAYC)
161 # define COMPILER_ID "Cray"
162 # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
163 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
164 
165 #elif defined(__TI_COMPILER_VERSION__)
166 # define COMPILER_ID "TI"
167 /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
168 # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
169 # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
170 # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
171 
172 #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
173 # define COMPILER_ID "Fujitsu"
174 
175 #elif defined(__ghs__)
176 # define COMPILER_ID "GHS"
177 /* __GHS_VERSION_NUMBER = VVVVRP */
178 # ifdef __GHS_VERSION_NUMBER
179 # define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
180 # define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
181 # define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
182 # endif
183 
184 #elif defined(__TINYC__)
185 # define COMPILER_ID "TinyCC"
186 
187 #elif defined(__BCC__)
188 # define COMPILER_ID "Bruce"
189 
190 #elif defined(__SCO_VERSION__)
191 # define COMPILER_ID "SCO"
192 
193 #elif defined(__ARMCC_VERSION) && !defined(__clang__)
194 # define COMPILER_ID "ARMCC"
195 #if __ARMCC_VERSION >= 1000000
196 /* __ARMCC_VERSION = VRRPPPP */
197 # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
198 # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
199 # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
200 #else
201 /* __ARMCC_VERSION = VRPPPP */
202 # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
203 # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
204 # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
205 #endif
206 
207 
208 #elif defined(__clang__) && defined(__apple_build_version__)
209 # define COMPILER_ID "AppleClang"
210 # if defined(_MSC_VER)
211 # define SIMULATE_ID "MSVC"
212 # endif
213 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
214 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
215 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
216 # if defined(_MSC_VER)
217 /* _MSC_VER = VVRR */
218 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
219 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
220 # endif
221 # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
222 
223 #elif defined(__clang__)
224 # define COMPILER_ID "Clang"
225 # if defined(_MSC_VER)
226 # define SIMULATE_ID "MSVC"
227 # endif
228 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
229 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
230 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
231 # if defined(_MSC_VER)
232 /* _MSC_VER = VVRR */
233 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
234 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
235 # endif
236 
237 #elif defined(__GNUC__)
238 # define COMPILER_ID "GNU"
239 # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
240 # if defined(__GNUC_MINOR__)
241 # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
242 # endif
243 # if defined(__GNUC_PATCHLEVEL__)
244 # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
245 # endif
246 
247 #elif defined(_MSC_VER)
248 # define COMPILER_ID "MSVC"
249 /* _MSC_VER = VVRR */
250 # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
251 # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
252 # if defined(_MSC_FULL_VER)
253 # if _MSC_VER >= 1400
254 /* _MSC_FULL_VER = VVRRPPPPP */
255 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
256 # else
257 /* _MSC_FULL_VER = VVRRPPPP */
258 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
259 # endif
260 # endif
261 # if defined(_MSC_BUILD)
262 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
263 # endif
264 
265 #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
266 # define COMPILER_ID "ADSP"
267 #if defined(__VISUALDSPVERSION__)
268 /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
269 # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
270 # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
271 # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
272 #endif
273 
274 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
275 # define COMPILER_ID "IAR"
276 # if defined(__VER__) && defined(__ICCARM__)
277 # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
278 # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
279 # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
280 # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
281 # elif defined(__VER__) && defined(__ICCAVR__)
282 # define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
283 # define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
284 # define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
285 # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
286 # endif
287 
288 #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
289 # define COMPILER_ID "SDCC"
290 # if defined(__SDCC_VERSION_MAJOR)
291 # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
292 # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
293 # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
294 # else
295 /* SDCC = VRP */
296 # define COMPILER_VERSION_MAJOR DEC(SDCC/100)
297 # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
298 # define COMPILER_VERSION_PATCH DEC(SDCC % 10)
299 # endif
300 
301 #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
302 # define COMPILER_ID "MIPSpro"
303 # if defined(_SGI_COMPILER_VERSION)
304 /* _SGI_COMPILER_VERSION = VRP */
305 # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
306 # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
307 # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
308 # else
309 /* _COMPILER_VERSION = VRP */
310 # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
311 # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
312 # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
313 # endif
314 
315 
316 /* These compilers are either not known or too old to define an
317  identification macro. Try to identify the platform and guess that
318  it is the native compiler. */
319 #elif defined(__hpux) || defined(__hpua)
320 # define COMPILER_ID "HP"
321 
322 #else /* unknown compiler */
323 # define COMPILER_ID ""
324 #endif
325 
326 /* Construct the string literal in pieces to prevent the source from
327  getting matched. Store it in a pointer rather than an array
328  because some compilers will just produce instructions to fill the
329  array rather than assigning a pointer to a static array. */
330 char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
331 #ifdef SIMULATE_ID
332 char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
333 #endif
334 
335 #ifdef __QNXNTO__
336 char const* qnxnto = "INFO" ":" "qnxnto[]";
337 #endif
338 
339 #if defined(__CRAYXE) || defined(__CRAYXC)
340 char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
341 #endif
342 
343 #define STRINGIFY_HELPER(X) #X
344 #define STRINGIFY(X) STRINGIFY_HELPER(X)
345 
346 /* Identify known platforms by name. */
347 #if defined(__linux) || defined(__linux__) || defined(linux)
348 # define PLATFORM_ID "Linux"
349 
350 #elif defined(__CYGWIN__)
351 # define PLATFORM_ID "Cygwin"
352 
353 #elif defined(__MINGW32__)
354 # define PLATFORM_ID "MinGW"
355 
356 #elif defined(__APPLE__)
357 # define PLATFORM_ID "Darwin"
358 
359 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
360 # define PLATFORM_ID "Windows"
361 
362 #elif defined(__FreeBSD__) || defined(__FreeBSD)
363 # define PLATFORM_ID "FreeBSD"
364 
365 #elif defined(__NetBSD__) || defined(__NetBSD)
366 # define PLATFORM_ID "NetBSD"
367 
368 #elif defined(__OpenBSD__) || defined(__OPENBSD)
369 # define PLATFORM_ID "OpenBSD"
370 
371 #elif defined(__sun) || defined(sun)
372 # define PLATFORM_ID "SunOS"
373 
374 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
375 # define PLATFORM_ID "AIX"
376 
377 #elif defined(__hpux) || defined(__hpux__)
378 # define PLATFORM_ID "HP-UX"
379 
380 #elif defined(__HAIKU__)
381 # define PLATFORM_ID "Haiku"
382 
383 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
384 # define PLATFORM_ID "BeOS"
385 
386 #elif defined(__QNX__) || defined(__QNXNTO__)
387 # define PLATFORM_ID "QNX"
388 
389 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
390 # define PLATFORM_ID "Tru64"
391 
392 #elif defined(__riscos) || defined(__riscos__)
393 # define PLATFORM_ID "RISCos"
394 
395 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
396 # define PLATFORM_ID "SINIX"
397 
398 #elif defined(__UNIX_SV__)
399 # define PLATFORM_ID "UNIX_SV"
400 
401 #elif defined(__bsdos__)
402 # define PLATFORM_ID "BSDOS"
403 
404 #elif defined(_MPRAS) || defined(MPRAS)
405 # define PLATFORM_ID "MP-RAS"
406 
407 #elif defined(__osf) || defined(__osf__)
408 # define PLATFORM_ID "OSF1"
409 
410 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
411 # define PLATFORM_ID "SCO_SV"
412 
413 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
414 # define PLATFORM_ID "ULTRIX"
415 
416 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
417 # define PLATFORM_ID "Xenix"
418 
419 #elif defined(__WATCOMC__)
420 # if defined(__LINUX__)
421 # define PLATFORM_ID "Linux"
422 
423 # elif defined(__DOS__)
424 # define PLATFORM_ID "DOS"
425 
426 # elif defined(__OS2__)
427 # define PLATFORM_ID "OS2"
428 
429 # elif defined(__WINDOWS__)
430 # define PLATFORM_ID "Windows3x"
431 
432 # else /* unknown platform */
433 # define PLATFORM_ID
434 # endif
435 
436 #elif defined(__INTEGRITY)
437 # if defined(INT_178B)
438 # define PLATFORM_ID "Integrity178"
439 
440 # else /* regular Integrity */
441 # define PLATFORM_ID "Integrity"
442 # endif
443 
444 #else /* unknown platform */
445 # define PLATFORM_ID
446 
447 #endif
448 
449 /* For windows compilers MSVC and Intel we can determine
450  the architecture of the compiler being used. This is because
451  the compilers do not have flags that can change the architecture,
452  but rather depend on which compiler is being used
453 */
454 #if defined(_WIN32) && defined(_MSC_VER)
455 # if defined(_M_IA64)
456 # define ARCHITECTURE_ID "IA64"
457 
458 # elif defined(_M_X64) || defined(_M_AMD64)
459 # define ARCHITECTURE_ID "x64"
460 
461 # elif defined(_M_IX86)
462 # define ARCHITECTURE_ID "X86"
463 
464 # elif defined(_M_ARM64)
465 # define ARCHITECTURE_ID "ARM64"
466 
467 # elif defined(_M_ARM)
468 # if _M_ARM == 4
469 # define ARCHITECTURE_ID "ARMV4I"
470 # elif _M_ARM == 5
471 # define ARCHITECTURE_ID "ARMV5I"
472 # else
473 # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
474 # endif
475 
476 # elif defined(_M_MIPS)
477 # define ARCHITECTURE_ID "MIPS"
478 
479 # elif defined(_M_SH)
480 # define ARCHITECTURE_ID "SHx"
481 
482 # else /* unknown architecture */
483 # define ARCHITECTURE_ID ""
484 # endif
485 
486 #elif defined(__WATCOMC__)
487 # if defined(_M_I86)
488 # define ARCHITECTURE_ID "I86"
489 
490 # elif defined(_M_IX86)
491 # define ARCHITECTURE_ID "X86"
492 
493 # else /* unknown architecture */
494 # define ARCHITECTURE_ID ""
495 # endif
496 
497 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
498 # if defined(__ICCARM__)
499 # define ARCHITECTURE_ID "ARM"
500 
501 # elif defined(__ICCAVR__)
502 # define ARCHITECTURE_ID "AVR"
503 
504 # else /* unknown architecture */
505 # define ARCHITECTURE_ID ""
506 # endif
507 
508 #elif defined(__ghs__)
509 # if defined(__PPC64__)
510 # define ARCHITECTURE_ID "PPC64"
511 
512 # elif defined(__ppc__)
513 # define ARCHITECTURE_ID "PPC"
514 
515 # elif defined(__ARM__)
516 # define ARCHITECTURE_ID "ARM"
517 
518 # elif defined(__x86_64__)
519 # define ARCHITECTURE_ID "x64"
520 
521 # elif defined(__i386__)
522 # define ARCHITECTURE_ID "X86"
523 
524 # else /* unknown architecture */
525 # define ARCHITECTURE_ID ""
526 # endif
527 #else
528 # define ARCHITECTURE_ID
529 #endif
530 
531 /* Convert integer to decimal digit literals. */
532 #define DEC(n) \
533  ('0' + (((n) / 10000000)%10)), \
534  ('0' + (((n) / 1000000)%10)), \
535  ('0' + (((n) / 100000)%10)), \
536  ('0' + (((n) / 10000)%10)), \
537  ('0' + (((n) / 1000)%10)), \
538  ('0' + (((n) / 100)%10)), \
539  ('0' + (((n) / 10)%10)), \
540  ('0' + ((n) % 10))
541 
542 /* Convert integer to hex digit literals. */
543 #define HEX(n) \
544  ('0' + ((n)>>28 & 0xF)), \
545  ('0' + ((n)>>24 & 0xF)), \
546  ('0' + ((n)>>20 & 0xF)), \
547  ('0' + ((n)>>16 & 0xF)), \
548  ('0' + ((n)>>12 & 0xF)), \
549  ('0' + ((n)>>8 & 0xF)), \
550  ('0' + ((n)>>4 & 0xF)), \
551  ('0' + ((n) & 0xF))
552 
553 /* Construct a string literal encoding the version number components. */
554 #ifdef COMPILER_VERSION_MAJOR
555 char const info_version[] =
556 {
557  'I', 'N', 'F', 'O', ':',
558  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
559  COMPILER_VERSION_MAJOR,
560 # ifdef COMPILER_VERSION_MINOR
561  '.', COMPILER_VERSION_MINOR,
562 # ifdef COMPILER_VERSION_PATCH
563  '.', COMPILER_VERSION_PATCH,
564 # ifdef COMPILER_VERSION_TWEAK
565  '.', COMPILER_VERSION_TWEAK,
566 # endif
567 # endif
568 # endif
569  ']','\0'
570 };
571 #endif
572 
573 /* Construct a string literal encoding the internal version number. */
574 #ifdef COMPILER_VERSION_INTERNAL
575 char const info_version_internal[] =
576 {
577  'I', 'N', 'F', 'O', ':',
578  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
579  'i','n','t','e','r','n','a','l','[',
580  COMPILER_VERSION_INTERNAL,']','\0'
581 };
582 #endif
583 
584 /* Construct a string literal encoding the version number components. */
585 #ifdef SIMULATE_VERSION_MAJOR
586 char const info_simulate_version[] =
587 {
588  'I', 'N', 'F', 'O', ':',
589  's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
590  SIMULATE_VERSION_MAJOR,
591 # ifdef SIMULATE_VERSION_MINOR
592  '.', SIMULATE_VERSION_MINOR,
593 # ifdef SIMULATE_VERSION_PATCH
594  '.', SIMULATE_VERSION_PATCH,
595 # ifdef SIMULATE_VERSION_TWEAK
596  '.', SIMULATE_VERSION_TWEAK,
597 # endif
598 # endif
599 # endif
600  ']','\0'
601 };
602 #endif
603 
604 /* Construct the string literal in pieces to prevent the source from
605  getting matched. Store it in a pointer rather than an array
606  because some compilers will just produce instructions to fill the
607  array rather than assigning a pointer to a static array. */
608 char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
609 char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
610 
611 
612 
613 
614 #if !defined(__STDC__)
615 # if (defined(_MSC_VER) && !defined(__clang__)) \
616  || (defined(__ibmxl__) || defined(__IBMC__))
617 # define C_DIALECT "90"
618 # else
619 # define C_DIALECT
620 # endif
621 #elif __STDC_VERSION__ >= 201000L
622 # define C_DIALECT "11"
623 #elif __STDC_VERSION__ >= 199901L
624 # define C_DIALECT "99"
625 #else
626 # define C_DIALECT "90"
627 #endif
628 const char* info_language_dialect_default =
629  "INFO" ":" "dialect_default[" C_DIALECT "]";
630 
631 /*--------------------------------------------------------------------------*/
632 
633 #ifdef ID_VOID_MAIN
634 void main() {}
635 #else
636 # if defined(__CLASSIC_C__)
637 int main(argc, argv) int argc;
638 char *argv[];
639 # else
640 int main(int argc, char* argv[])
641 # endif
642 {
643  int require = 0;
644  require += info_compiler[argc];
645  require += info_platform[argc];
646  require += info_arch[argc];
647 #ifdef COMPILER_VERSION_MAJOR
648  require += info_version[argc];
649 #endif
650 #ifdef COMPILER_VERSION_INTERNAL
651  require += info_version_internal[argc];
652 #endif
653 #ifdef SIMULATE_ID
654  require += info_simulate[argc];
655 #endif
656 #ifdef SIMULATE_VERSION_MAJOR
657  require += info_simulate_version[argc];
658 #endif
659 #if defined(__CRAYXE) || defined(__CRAYXC)
660  require += info_cray[argc];
661 #endif
662  require += info_language_dialect_default[argc];
663  (void)argv;
664  return require;
665 }
666 #endif
+ + + + diff --git a/docs/html/CMakeCXXCompilerId_8cpp_source.html b/docs/html/CMakeCXXCompilerId_8cpp_source.html new file mode 100644 index 0000000..1965e96 --- /dev/null +++ b/docs/html/CMakeCXXCompilerId_8cpp_source.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/3.14.3/CompilerIdCXX/CMakeCXXCompilerId.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
CMakeCXXCompilerId.cpp
+
+
+
1 /* This source file must have a .cpp extension so that all C++ compilers
2  recognize the extension without flags. Borland does not know .cxx for
3  example. */
4 #ifndef __cplusplus
5 # error "A C compiler has been selected for C++."
6 #endif
7 
8 
9 /* Version number components: V=Version, R=Revision, P=Patch
10  Version date components: YYYY=Year, MM=Month, DD=Day */
11 
12 #if defined(__COMO__)
13 # define COMPILER_ID "Comeau"
14 /* __COMO_VERSION__ = VRR */
15 # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
16 # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
17 
18 #elif defined(__INTEL_COMPILER) || defined(__ICC)
19 # define COMPILER_ID "Intel"
20 # if defined(_MSC_VER)
21 # define SIMULATE_ID "MSVC"
22 # endif
23 /* __INTEL_COMPILER = VRP */
24 # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
25 # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
26 # if defined(__INTEL_COMPILER_UPDATE)
27 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
28 # else
29 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
30 # endif
31 # if defined(__INTEL_COMPILER_BUILD_DATE)
32 /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
33 # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
34 # endif
35 # if defined(_MSC_VER)
36 /* _MSC_VER = VVRR */
37 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
38 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
39 # endif
40 
41 #elif defined(__PATHCC__)
42 # define COMPILER_ID "PathScale"
43 # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
44 # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
45 # if defined(__PATHCC_PATCHLEVEL__)
46 # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
47 # endif
48 
49 #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
50 # define COMPILER_ID "Embarcadero"
51 # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
52 # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
53 # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
54 
55 #elif defined(__BORLANDC__)
56 # define COMPILER_ID "Borland"
57 /* __BORLANDC__ = 0xVRR */
58 # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
59 # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
60 
61 #elif defined(__WATCOMC__) && __WATCOMC__ < 1200
62 # define COMPILER_ID "Watcom"
63 /* __WATCOMC__ = VVRR */
64 # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
65 # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
66 # if (__WATCOMC__ % 10) > 0
67 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
68 # endif
69 
70 #elif defined(__WATCOMC__)
71 # define COMPILER_ID "OpenWatcom"
72 /* __WATCOMC__ = VVRP + 1100 */
73 # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
74 # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
75 # if (__WATCOMC__ % 10) > 0
76 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
77 # endif
78 
79 #elif defined(__SUNPRO_CC)
80 # define COMPILER_ID "SunPro"
81 # if __SUNPRO_CC >= 0x5100
82 /* __SUNPRO_CC = 0xVRRP */
83 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
84 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
85 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
86 # else
87 /* __SUNPRO_CC = 0xVRP */
88 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
89 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
90 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
91 # endif
92 
93 #elif defined(__HP_aCC)
94 # define COMPILER_ID "HP"
95 /* __HP_aCC = VVRRPP */
96 # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
97 # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
98 # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
99 
100 #elif defined(__DECCXX)
101 # define COMPILER_ID "Compaq"
102 /* __DECCXX_VER = VVRRTPPPP */
103 # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
104 # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
105 # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
106 
107 #elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
108 # define COMPILER_ID "zOS"
109 # if defined(__ibmxl__)
110 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
111 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
112 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
113 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
114 # else
115 /* __IBMCPP__ = VRP */
116 # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
117 # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
118 # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
119 # endif
120 
121 
122 #elif defined(__ibmxl__) || (defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800)
123 # define COMPILER_ID "XL"
124 # if defined(__ibmxl__)
125 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
126 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
127 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
128 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
129 # else
130 /* __IBMCPP__ = VRP */
131 # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
132 # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
133 # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
134 # endif
135 
136 
137 #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
138 # define COMPILER_ID "VisualAge"
139 # if defined(__ibmxl__)
140 # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
141 # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
142 # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
143 # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
144 # else
145 /* __IBMCPP__ = VRP */
146 # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
147 # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
148 # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
149 # endif
150 
151 
152 #elif defined(__PGI)
153 # define COMPILER_ID "PGI"
154 # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
155 # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
156 # if defined(__PGIC_PATCHLEVEL__)
157 # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
158 # endif
159 
160 #elif defined(_CRAYC)
161 # define COMPILER_ID "Cray"
162 # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
163 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
164 
165 #elif defined(__TI_COMPILER_VERSION__)
166 # define COMPILER_ID "TI"
167 /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
168 # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
169 # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
170 # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
171 
172 #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
173 # define COMPILER_ID "Fujitsu"
174 
175 #elif defined(__ghs__)
176 # define COMPILER_ID "GHS"
177 /* __GHS_VERSION_NUMBER = VVVVRP */
178 # ifdef __GHS_VERSION_NUMBER
179 # define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
180 # define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
181 # define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
182 # endif
183 
184 #elif defined(__SCO_VERSION__)
185 # define COMPILER_ID "SCO"
186 
187 #elif defined(__ARMCC_VERSION) && !defined(__clang__)
188 # define COMPILER_ID "ARMCC"
189 #if __ARMCC_VERSION >= 1000000
190 /* __ARMCC_VERSION = VRRPPPP */
191 # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
192 # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
193 # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
194 #else
195 /* __ARMCC_VERSION = VRPPPP */
196 # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
197 # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
198 # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
199 #endif
200 
201 
202 #elif defined(__clang__) && defined(__apple_build_version__)
203 # define COMPILER_ID "AppleClang"
204 # if defined(_MSC_VER)
205 # define SIMULATE_ID "MSVC"
206 # endif
207 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
208 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
209 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
210 # if defined(_MSC_VER)
211 /* _MSC_VER = VVRR */
212 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
213 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
214 # endif
215 # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
216 
217 #elif defined(__clang__)
218 # define COMPILER_ID "Clang"
219 # if defined(_MSC_VER)
220 # define SIMULATE_ID "MSVC"
221 # endif
222 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
223 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
224 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
225 # if defined(_MSC_VER)
226 /* _MSC_VER = VVRR */
227 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
228 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
229 # endif
230 
231 #elif defined(__GNUC__) || defined(__GNUG__)
232 # define COMPILER_ID "GNU"
233 # if defined(__GNUC__)
234 # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
235 # else
236 # define COMPILER_VERSION_MAJOR DEC(__GNUG__)
237 # endif
238 # if defined(__GNUC_MINOR__)
239 # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
240 # endif
241 # if defined(__GNUC_PATCHLEVEL__)
242 # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
243 # endif
244 
245 #elif defined(_MSC_VER)
246 # define COMPILER_ID "MSVC"
247 /* _MSC_VER = VVRR */
248 # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
249 # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
250 # if defined(_MSC_FULL_VER)
251 # if _MSC_VER >= 1400
252 /* _MSC_FULL_VER = VVRRPPPPP */
253 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
254 # else
255 /* _MSC_FULL_VER = VVRRPPPP */
256 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
257 # endif
258 # endif
259 # if defined(_MSC_BUILD)
260 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
261 # endif
262 
263 #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
264 # define COMPILER_ID "ADSP"
265 #if defined(__VISUALDSPVERSION__)
266 /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
267 # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
268 # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
269 # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
270 #endif
271 
272 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
273 # define COMPILER_ID "IAR"
274 # if defined(__VER__) && defined(__ICCARM__)
275 # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
276 # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
277 # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
278 # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
279 # elif defined(__VER__) && defined(__ICCAVR__)
280 # define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
281 # define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
282 # define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
283 # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
284 # endif
285 
286 #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
287 # define COMPILER_ID "MIPSpro"
288 # if defined(_SGI_COMPILER_VERSION)
289 /* _SGI_COMPILER_VERSION = VRP */
290 # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
291 # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
292 # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
293 # else
294 /* _COMPILER_VERSION = VRP */
295 # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
296 # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
297 # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
298 # endif
299 
300 
301 /* These compilers are either not known or too old to define an
302  identification macro. Try to identify the platform and guess that
303  it is the native compiler. */
304 #elif defined(__hpux) || defined(__hpua)
305 # define COMPILER_ID "HP"
306 
307 #else /* unknown compiler */
308 # define COMPILER_ID ""
309 #endif
310 
311 /* Construct the string literal in pieces to prevent the source from
312  getting matched. Store it in a pointer rather than an array
313  because some compilers will just produce instructions to fill the
314  array rather than assigning a pointer to a static array. */
315 char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
316 #ifdef SIMULATE_ID
317 char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
318 #endif
319 
320 #ifdef __QNXNTO__
321 char const* qnxnto = "INFO" ":" "qnxnto[]";
322 #endif
323 
324 #if defined(__CRAYXE) || defined(__CRAYXC)
325 char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
326 #endif
327 
328 #define STRINGIFY_HELPER(X) #X
329 #define STRINGIFY(X) STRINGIFY_HELPER(X)
330 
331 /* Identify known platforms by name. */
332 #if defined(__linux) || defined(__linux__) || defined(linux)
333 # define PLATFORM_ID "Linux"
334 
335 #elif defined(__CYGWIN__)
336 # define PLATFORM_ID "Cygwin"
337 
338 #elif defined(__MINGW32__)
339 # define PLATFORM_ID "MinGW"
340 
341 #elif defined(__APPLE__)
342 # define PLATFORM_ID "Darwin"
343 
344 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
345 # define PLATFORM_ID "Windows"
346 
347 #elif defined(__FreeBSD__) || defined(__FreeBSD)
348 # define PLATFORM_ID "FreeBSD"
349 
350 #elif defined(__NetBSD__) || defined(__NetBSD)
351 # define PLATFORM_ID "NetBSD"
352 
353 #elif defined(__OpenBSD__) || defined(__OPENBSD)
354 # define PLATFORM_ID "OpenBSD"
355 
356 #elif defined(__sun) || defined(sun)
357 # define PLATFORM_ID "SunOS"
358 
359 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
360 # define PLATFORM_ID "AIX"
361 
362 #elif defined(__hpux) || defined(__hpux__)
363 # define PLATFORM_ID "HP-UX"
364 
365 #elif defined(__HAIKU__)
366 # define PLATFORM_ID "Haiku"
367 
368 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
369 # define PLATFORM_ID "BeOS"
370 
371 #elif defined(__QNX__) || defined(__QNXNTO__)
372 # define PLATFORM_ID "QNX"
373 
374 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
375 # define PLATFORM_ID "Tru64"
376 
377 #elif defined(__riscos) || defined(__riscos__)
378 # define PLATFORM_ID "RISCos"
379 
380 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
381 # define PLATFORM_ID "SINIX"
382 
383 #elif defined(__UNIX_SV__)
384 # define PLATFORM_ID "UNIX_SV"
385 
386 #elif defined(__bsdos__)
387 # define PLATFORM_ID "BSDOS"
388 
389 #elif defined(_MPRAS) || defined(MPRAS)
390 # define PLATFORM_ID "MP-RAS"
391 
392 #elif defined(__osf) || defined(__osf__)
393 # define PLATFORM_ID "OSF1"
394 
395 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
396 # define PLATFORM_ID "SCO_SV"
397 
398 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
399 # define PLATFORM_ID "ULTRIX"
400 
401 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
402 # define PLATFORM_ID "Xenix"
403 
404 #elif defined(__WATCOMC__)
405 # if defined(__LINUX__)
406 # define PLATFORM_ID "Linux"
407 
408 # elif defined(__DOS__)
409 # define PLATFORM_ID "DOS"
410 
411 # elif defined(__OS2__)
412 # define PLATFORM_ID "OS2"
413 
414 # elif defined(__WINDOWS__)
415 # define PLATFORM_ID "Windows3x"
416 
417 # else /* unknown platform */
418 # define PLATFORM_ID
419 # endif
420 
421 #elif defined(__INTEGRITY)
422 # if defined(INT_178B)
423 # define PLATFORM_ID "Integrity178"
424 
425 # else /* regular Integrity */
426 # define PLATFORM_ID "Integrity"
427 # endif
428 
429 #else /* unknown platform */
430 # define PLATFORM_ID
431 
432 #endif
433 
434 /* For windows compilers MSVC and Intel we can determine
435  the architecture of the compiler being used. This is because
436  the compilers do not have flags that can change the architecture,
437  but rather depend on which compiler is being used
438 */
439 #if defined(_WIN32) && defined(_MSC_VER)
440 # if defined(_M_IA64)
441 # define ARCHITECTURE_ID "IA64"
442 
443 # elif defined(_M_X64) || defined(_M_AMD64)
444 # define ARCHITECTURE_ID "x64"
445 
446 # elif defined(_M_IX86)
447 # define ARCHITECTURE_ID "X86"
448 
449 # elif defined(_M_ARM64)
450 # define ARCHITECTURE_ID "ARM64"
451 
452 # elif defined(_M_ARM)
453 # if _M_ARM == 4
454 # define ARCHITECTURE_ID "ARMV4I"
455 # elif _M_ARM == 5
456 # define ARCHITECTURE_ID "ARMV5I"
457 # else
458 # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
459 # endif
460 
461 # elif defined(_M_MIPS)
462 # define ARCHITECTURE_ID "MIPS"
463 
464 # elif defined(_M_SH)
465 # define ARCHITECTURE_ID "SHx"
466 
467 # else /* unknown architecture */
468 # define ARCHITECTURE_ID ""
469 # endif
470 
471 #elif defined(__WATCOMC__)
472 # if defined(_M_I86)
473 # define ARCHITECTURE_ID "I86"
474 
475 # elif defined(_M_IX86)
476 # define ARCHITECTURE_ID "X86"
477 
478 # else /* unknown architecture */
479 # define ARCHITECTURE_ID ""
480 # endif
481 
482 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
483 # if defined(__ICCARM__)
484 # define ARCHITECTURE_ID "ARM"
485 
486 # elif defined(__ICCAVR__)
487 # define ARCHITECTURE_ID "AVR"
488 
489 # else /* unknown architecture */
490 # define ARCHITECTURE_ID ""
491 # endif
492 
493 #elif defined(__ghs__)
494 # if defined(__PPC64__)
495 # define ARCHITECTURE_ID "PPC64"
496 
497 # elif defined(__ppc__)
498 # define ARCHITECTURE_ID "PPC"
499 
500 # elif defined(__ARM__)
501 # define ARCHITECTURE_ID "ARM"
502 
503 # elif defined(__x86_64__)
504 # define ARCHITECTURE_ID "x64"
505 
506 # elif defined(__i386__)
507 # define ARCHITECTURE_ID "X86"
508 
509 # else /* unknown architecture */
510 # define ARCHITECTURE_ID ""
511 # endif
512 #else
513 # define ARCHITECTURE_ID
514 #endif
515 
516 /* Convert integer to decimal digit literals. */
517 #define DEC(n) \
518  ('0' + (((n) / 10000000)%10)), \
519  ('0' + (((n) / 1000000)%10)), \
520  ('0' + (((n) / 100000)%10)), \
521  ('0' + (((n) / 10000)%10)), \
522  ('0' + (((n) / 1000)%10)), \
523  ('0' + (((n) / 100)%10)), \
524  ('0' + (((n) / 10)%10)), \
525  ('0' + ((n) % 10))
526 
527 /* Convert integer to hex digit literals. */
528 #define HEX(n) \
529  ('0' + ((n)>>28 & 0xF)), \
530  ('0' + ((n)>>24 & 0xF)), \
531  ('0' + ((n)>>20 & 0xF)), \
532  ('0' + ((n)>>16 & 0xF)), \
533  ('0' + ((n)>>12 & 0xF)), \
534  ('0' + ((n)>>8 & 0xF)), \
535  ('0' + ((n)>>4 & 0xF)), \
536  ('0' + ((n) & 0xF))
537 
538 /* Construct a string literal encoding the version number components. */
539 #ifdef COMPILER_VERSION_MAJOR
540 char const info_version[] =
541 {
542  'I', 'N', 'F', 'O', ':',
543  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
544  COMPILER_VERSION_MAJOR,
545 # ifdef COMPILER_VERSION_MINOR
546  '.', COMPILER_VERSION_MINOR,
547 # ifdef COMPILER_VERSION_PATCH
548  '.', COMPILER_VERSION_PATCH,
549 # ifdef COMPILER_VERSION_TWEAK
550  '.', COMPILER_VERSION_TWEAK,
551 # endif
552 # endif
553 # endif
554  ']','\0'
555 };
556 #endif
557 
558 /* Construct a string literal encoding the internal version number. */
559 #ifdef COMPILER_VERSION_INTERNAL
560 char const info_version_internal[] =
561 {
562  'I', 'N', 'F', 'O', ':',
563  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
564  'i','n','t','e','r','n','a','l','[',
565  COMPILER_VERSION_INTERNAL,']','\0'
566 };
567 #endif
568 
569 /* Construct a string literal encoding the version number components. */
570 #ifdef SIMULATE_VERSION_MAJOR
571 char const info_simulate_version[] =
572 {
573  'I', 'N', 'F', 'O', ':',
574  's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
575  SIMULATE_VERSION_MAJOR,
576 # ifdef SIMULATE_VERSION_MINOR
577  '.', SIMULATE_VERSION_MINOR,
578 # ifdef SIMULATE_VERSION_PATCH
579  '.', SIMULATE_VERSION_PATCH,
580 # ifdef SIMULATE_VERSION_TWEAK
581  '.', SIMULATE_VERSION_TWEAK,
582 # endif
583 # endif
584 # endif
585  ']','\0'
586 };
587 #endif
588 
589 /* Construct the string literal in pieces to prevent the source from
590  getting matched. Store it in a pointer rather than an array
591  because some compilers will just produce instructions to fill the
592  array rather than assigning a pointer to a static array. */
593 char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
594 char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
595 
596 
597 
598 
599 #if defined(_MSC_VER) && defined(_MSVC_LANG)
600 #define CXX_STD _MSVC_LANG
601 #else
602 #define CXX_STD __cplusplus
603 #endif
604 
605 const char* info_language_dialect_default = "INFO" ":" "dialect_default["
606 #if CXX_STD > 201703L
607  "20"
608 #elif CXX_STD >= 201703L
609  "17"
610 #elif CXX_STD >= 201402L
611  "14"
612 #elif CXX_STD >= 201103L
613  "11"
614 #else
615  "98"
616 #endif
617  "]";
618 
619 /*--------------------------------------------------------------------------*/
620 
621 int main(int argc, char* argv[])
622 {
623  int require = 0;
624  require += info_compiler[argc];
625  require += info_platform[argc];
626 #ifdef COMPILER_VERSION_MAJOR
627  require += info_version[argc];
628 #endif
629 #ifdef COMPILER_VERSION_INTERNAL
630  require += info_version_internal[argc];
631 #endif
632 #ifdef SIMULATE_ID
633  require += info_simulate[argc];
634 #endif
635 #ifdef SIMULATE_VERSION_MAJOR
636  require += info_simulate_version[argc];
637 #endif
638 #if defined(__CRAYXE) || defined(__CRAYXC)
639  require += info_cray[argc];
640 #endif
641  require += info_language_dialect_default[argc];
642  (void)argv;
643  return require;
644 }
+ + + + diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 06ae8d2..deff929 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -85,7 +85,7 @@ $(function() { diff --git a/docs/html/b15f_8cpp_source.html b/docs/html/b15f_8cpp_source.html index a12e858..4201243 100644 --- a/docs/html/b15f_8cpp_source.html +++ b/docs/html/b15f_8cpp_source.html @@ -70,41 +70,49 @@ $(function() {
b15f.cpp
-
1 #include "b15f.h"
2 
3 B15F* B15F::instance = nullptr;
4 errorhandler_t B15F::errorhandler = nullptr;
5 
6 B15F::B15F()
7 {
8  init();
9 }
10 
11 void B15F::init()
12 {
13 
14  std::string device = exec("bash -c 'ls /dev/ttyUSB*'");
15  while(device.find(' ') != std::string::npos || device.find('\n') != std::string::npos || device.find('\t') != std::string::npos)
16  device.pop_back();
17 
18  if(device.length() == 0)
19  abort("Adapter nicht gefunden");
20 
21  std::cout << PRE << "Verwende Adapter: " << device << std::endl;
22 
23 
24 
25  std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush;
26  usart.setBaudrate(BAUDRATE);
27  usart.openDevice(device);
28  std::cout << "OK" << std::endl;
29 
30 
31 
32  std::cout << PRE << "Teste Verbindung... " << std::flush;
33  uint8_t tries = 3;
34  while(tries--)
35  {
36  // verwerfe Daten, die µC noch hat
37  //discard();
38 
39  if(!testConnection())
40  continue;
41 
42  if(!testIntConv())
43  continue;
44 
45  break;
46  }
47  if(tries == 0)
48  abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
49  std::cout << "OK" << std::endl;
50 
51 
52  // Gib board info aus
53  std::vector<std::string> info = getBoardInfo();
54  std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")" << std::endl;
55 }
56 
58 {
59  uint8_t tries = RECONNECT_TRIES;
60  while(tries--)
61  {
62  delay_ms(RECONNECT_TIMEOUT);
63  discard();
64 
65  if(testConnection())
66  return;
67  }
68 
69  abort("Verbindung kann nicht repariert werden");
70 }
71 
72 void B15F::discard(void)
73 {
74  try
75  {
76  usart.clearOutputBuffer();
77  for(uint8_t i = 0; i < 16; i++)
78  {
79  usart.writeByte(RQ_DISC); // sende discard Befehl (verwerfe input)
80  delay_ms(4);
81  }
82  usart.clearInputBuffer();
83  }
84  catch(std::exception& ex)
85  {
86  abort(ex);
87  }
88 }
89 
91 {
92  // erzeuge zufälliges Byte
93  srand(time(NULL));
94  uint8_t dummy = rand() % 256;
95 
96  usart.writeByte(RQ_TEST);
97  usart.writeByte(dummy);
98 
99  uint8_t aw = usart.readByte();
100  uint8_t mirror = usart.readByte();
101 
102  return aw == MSG_OK && mirror == dummy;
103 }
104 
106 {
107  srand(time(NULL));
108  uint16_t dummy = rand() % (0xFFFF / 3);
109 
110  usart.writeByte(RQ_INT);
111  usart.writeInt(dummy);
112 
113  uint16_t aw = usart.readInt();
114  return aw == dummy * 3;
115 }
116 
117 
118 std::vector<std::string> B15F::getBoardInfo(void)
119 {
120  std::vector<std::string> info;
121 
122  usart.writeByte(RQ_INFO);
123 
124  uint8_t n = usart.readByte();
125  while(n--)
126  {
127  uint8_t len = usart.readByte();
128  std::string str;
129 
130  while(len--) {
131  str += static_cast<char>(usart.readByte());
132  }
133 
134  info.push_back(str);
135  }
136 
137  uint8_t aw = usart.readByte();
138  if(aw != MSG_OK)
139  abort("Board Info fehlerhalft: code " + std::to_string((int) aw));
140 
141  return info;
142 }
143 
145 {
146  usart.writeByte(RQ_ST);
147 
148  uint8_t aw = usart.readByte();
149  return aw == MSG_OK;
150 }
151 
152 bool B15F::digitalWrite0(uint8_t port)
153 {
154  usart.writeByte(RQ_BA0);
155  usart.writeByte(port);
156 
157  uint8_t aw = usart.readByte();
158  delay_us(10);
159  return aw == MSG_OK;
160 }
161 
162 bool B15F::digitalWrite1(uint8_t port)
163 {
164  usart.writeByte(RQ_BA1);
165  usart.writeByte(port);
166 
167  uint8_t aw = usart.readByte();
168  delay_us(10);
169  return aw == MSG_OK;
170 }
171 
173 {
174  usart.clearInputBuffer();
175  usart.writeByte(RQ_BE0);
176  uint8_t byte = usart.readByte();
177  delay_us(10);
178  return byte;
179 }
180 
182 {
183  usart.clearInputBuffer();
184  usart.writeByte(RQ_BE1);
185  uint8_t byte = usart.readByte();
186  delay_us(10);
187  return byte;
188 }
189 
191 {
192  usart.clearInputBuffer();
193  usart.writeByte(RQ_DSW);
194  uint8_t byte = usart.readByte();
195  delay_us(10);
196  return byte;
197 }
198 
199 bool B15F::analogWrite0(uint16_t value)
200 {
201  usart.writeByte(RQ_AA0);
202  usart.writeInt(value);
203 
204  uint8_t aw = usart.readByte();
205  delay_us(10);
206  return aw == MSG_OK;
207 }
208 
209 bool B15F::analogWrite1(uint16_t value)
210 {
211  usart.writeByte(RQ_AA1);
212  usart.writeInt(value);
213 
214  uint8_t aw = usart.readByte();
215  delay_us(10);
216  return aw == MSG_OK;
217 }
218 
219 uint16_t B15F::analogRead(uint8_t channel)
220 {
221  usart.clearInputBuffer();
222  if(channel > 7)
223  abort("Bad ADC channel: " + std::to_string(channel));
224 
225  uint8_t rq[] = {
226  RQ_ADC,
227  channel
228  };
229 
230  int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
231  if(n_sent != sizeof(rq))
232  abort("Sent failed");
233 
234  uint16_t adc = usart.readInt();
235 
236  if(adc > 1023)
237  abort("Bad ADC data detected (1)");
238  return adc;
239 }
240 
241 void B15F::analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
242 {
243  // check pointers
244  buffer_a += offset_a;
245  buffer_b += offset_b;
246 
247 
248  usart.clearInputBuffer();
249  usart.writeByte(RQ_ADC_DAC_STROKE);
250  usart.writeByte(channel_a);
251  usart.writeByte(channel_b);
252  usart.writeInt(start);
253  usart.writeInt(static_cast<uint16_t>(delta));
254  usart.writeInt(count);
255 
256  for(uint16_t i = 0; i < count; i++)
257  {
258  if(buffer_a)
259  {
260  buffer_a[i] = usart.readInt();
261 
262  if(buffer_a[i] > 1023) // check for broken usart connection
263  abort("Bad ADC data detected (2)");
264  }
265  else
266  {
267  usart.readInt();
268  }
269 
270  if(buffer_b)
271  {
272  buffer_b[i] = usart.readInt();
273 
274  if(buffer_b[i] > 1023) // check for broken usart connection
275  abort("Bad ADC data detected (3)");
276  }
277  else
278  {
279  usart.readInt();
280  }
281  }
282 
283  uint8_t aw = usart.readByte();
284  if(aw != MSG_OK)
285  abort("Sequenz unterbrochen");
286 
287  delay_us(10);
288 }
289 
290 void B15F::delay_ms(uint16_t ms)
291 {
292  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
293 }
294 
295 void B15F::delay_us(uint16_t us)
296 {
297  std::this_thread::sleep_for(std::chrono::microseconds(us));
298 }
299 
301 {
302  if(!instance)
303  instance = new B15F();
304 
305  return *instance;
306 }
307 
308 // https://stackoverflow.com/a/478960
309 std::string B15F::exec(std::string cmd) {
310  std::array<char, 128> buffer;
311  std::string result;
312  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
313  if (!pipe) {
314  throw std::runtime_error("popen() failed!");
315  }
316  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
317  result += buffer.data();
318  }
319  return result;
320 }
321 
322 void B15F::abort(std::string msg)
323 {
324  DriverException ex(msg);
325  abort(ex);
326 }
327 void B15F::abort(std::exception& ex)
328 {
329  if(errorhandler)
330  errorhandler(ex);
331  else
332  {
333  std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl;
334  std::cout << ex.what() << std::endl;
335  throw DriverException(ex.what());
336  }
337 }
338 
339 void B15F::setAbortHandler(errorhandler_t func)
340 {
341  errorhandler = func;
342 }
-
static std::string exec(std::string cmd)
Definition: b15f.cpp:309
-
uint8_t readByte(void)
Definition: usart.cpp:210
-
void delay_us(uint16_t us)
Definition: b15f.cpp:295
-
uint8_t digitalRead0(void)
Definition: b15f.cpp:172
-
void analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
Definition: b15f.cpp:241
-
bool testConnection(void)
Definition: b15f.cpp:90
-
uint8_t readDipSwitch(void)
Definition: b15f.cpp:190
-
void delay_ms(uint16_t ms)
Definition: b15f.cpp:290
-
bool analogWrite1(uint16_t)
Definition: b15f.cpp:209
-
static B15F & getInstance(void)
Definition: b15f.cpp:300
-
Definition: b15f.h:24
-
static void abort(std::string msg)
Definition: b15f.cpp:322
-
void clearInputBuffer(void)
Definition: usart.cpp:39
-
void clearOutputBuffer(void)
Definition: usart.cpp:46
-
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:219
-
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:152
-
void setBaudrate(uint32_t baudrate)
Definition: usart.cpp:316
-
bool activateSelfTestMode(void)
Definition: b15f.cpp:144
-
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:118
-
void writeByte(uint8_t b)
Definition: usart.cpp:67
-
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:162
+
1 #include "b15f.h"
2 
3 B15F *B15F::instance = nullptr;
4 errorhandler_t B15F::errorhandler = nullptr;
5 
6 B15F::B15F()
7 {
8  init();
9 }
10 
11 void B15F::init()
12 {
13 
14  std::string device = exec("bash -c 'ls /dev/ttyUSB*'");
15  while (device.find(' ') != std::string::npos || device.find('\n') != std::string::npos ||
16  device.find('\t') != std::string::npos)
17  device.pop_back();
18 
19  if (device.length() == 0)
20  abort("Adapter nicht gefunden");
21 
22  std::cout << PRE << "Verwende Adapter: " << device << std::endl;
23 
24 
25  std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush;
26  usart.setBaudrate(BAUDRATE);
27  usart.openDevice(device);
28  std::cout << "OK" << std::endl;
29 
30 
31  std::cout << PRE << "Teste Verbindung... " << std::flush;
32  uint8_t tries = 3;
33  while (tries--)
34  {
35  // verwerfe Daten, die µC noch hat
36  //discard();
37 
38  if (!testConnection())
39  continue;
40 
41  if (!testIntConv())
42  continue;
43 
44  break;
45  }
46  if (tries == 0)
47  abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
48  std::cout << "OK" << std::endl;
49 
50 
51  // Gib board info aus
52  std::vector<std::string> info = getBoardInfo();
53  std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
54  << std::endl;
55 }
56 
58 {
59  uint8_t tries = RECONNECT_TRIES;
60  while (tries--)
61  {
63  discard();
64 
65  if (testConnection())
66  return;
67  }
68 
69  abort("Verbindung kann nicht repariert werden");
70 }
71 
72 void B15F::discard(void)
73 {
74  try
75  {
76  uint8_t rq[] =
77  {
78  RQ_DISC
79  };
80 
81  usart.clearOutputBuffer();
82  for (uint8_t i = 0; i < 16; i++)
83  {
84  usart.transmit(&rq[0], 0, sizeof(rq)); // sende discard Befehl (verwerfe input)
85  delay_ms(4);
86  }
87  usart.clearInputBuffer();
88  }
89  catch (std::exception &ex)
90  {
91  abort(ex);
92  }
93 }
94 
96 {
97  // erzeuge zufälliges Byte
98  srand(time(NULL));
99  uint8_t dummy = rand() % 256;
100 
101  uint8_t rq[] =
102  {
103  RQ_TEST,
104  dummy
105  };
106  usart.transmit(&rq[0], 0, sizeof(rq));
107 
108  uint8_t aw[2];
109  usart.receive(&aw[0], 0, sizeof(aw));
110 
111  return aw[0] == MSG_OK && aw[1] == dummy;
112 }
113 
115 {
116  srand(time(NULL));
117  uint16_t dummy = rand() % (0xFFFF / 3);
118 
119  uint8_t rq[] =
120  {
121  RQ_INT,
122  static_cast<uint8_t >(dummy & 0xFF),
123  static_cast<uint8_t >(dummy >> 8)
124  };
125  usart.transmit(&rq[0], 0, sizeof(rq));
126 
127  uint16_t aw;
128  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
129 
130  return aw == dummy * 3;
131 }
132 
133 
134 std::vector<std::string> B15F::getBoardInfo(void)
135 {
136  std::vector<std::string> info;
137 
138  uint8_t rq[] =
139  {
140  RQ_INFO
141  };
142  usart.transmit(&rq[0], 0, sizeof(rq));
143 
144  uint8_t n;
145  usart.receive(&n, 0, sizeof(n));
146  while (n--)
147  {
148  uint8_t len;
149  usart.receive(&len, 0, sizeof(len));
150 
151  char str[len + 1];
152  str[len] = '\0';
153  usart.receive(reinterpret_cast<uint8_t *>(&str[0]), 0, len);
154 
155  info.push_back(std::string(str));
156  }
157 
158  uint8_t aw;
159  usart.receive(&aw, 0, sizeof(aw));
160  if (aw != MSG_OK)
161  abort("Board Info fehlerhalft: code " + std::to_string((int) aw));
162 
163  return info;
164 }
165 
167 {
168  uint8_t rq[] =
169  {
170  RQ_ST
171  };
172  usart.transmit(&rq[0], 0, sizeof(rq));
173 
174  uint8_t aw;
175  usart.receive(&aw, 0, sizeof(aw));
176  return aw == MSG_OK;
177 }
178 
179 bool B15F::digitalWrite0(uint8_t port)
180 {
181  uint8_t rq[] =
182  {
183  RQ_BA0,
184  port
185  };
186  usart.transmit(&rq[0], 0, sizeof(rq));
187 
188  uint8_t aw;
189  usart.receive(&aw, 0, sizeof(aw));
190  return aw == MSG_OK;
191 }
192 
193 bool B15F::digitalWrite1(uint8_t port)
194 {
195  uint8_t rq[] =
196  {
197  RQ_BA1,
198  port
199  };
200  usart.transmit(&rq[0], 0, sizeof(rq));
201 
202  uint8_t aw;
203  usart.receive(&aw, 0, sizeof(aw));
204  return aw == MSG_OK;
205 }
206 
208 {
209  usart.clearInputBuffer();
210  uint8_t rq[] =
211  {
212  RQ_BE0
213  };
214  usart.transmit(&rq[0], 0, sizeof(rq));
215 
216  uint8_t aw;
217  usart.receive(&aw, 0, sizeof(aw));
218  return aw;
219 }
220 
222 {
223  usart.clearInputBuffer();
224  uint8_t rq[] =
225  {
226  RQ_BE1
227  };
228  usart.transmit(&rq[0], 0, sizeof(rq));
229 
230  uint8_t aw;
231  usart.receive(&aw, 0, sizeof(aw));
232  return aw;
233 }
234 
236 {
237  usart.clearInputBuffer();
238  uint8_t rq[] =
239  {
240  RQ_DSW
241  };
242  usart.transmit(&rq[0], 0, sizeof(rq));
243 
244  uint8_t aw;
245  usart.receive(&aw, 0, sizeof(aw));
246  return aw;
247 }
248 
249 bool B15F::analogWrite0(uint16_t value)
250 {
251  uint8_t rq[] =
252  {
253  RQ_AA0,
254  static_cast<uint8_t >(value & 0xFF),
255  static_cast<uint8_t >(value >> 8)
256  };
257  usart.transmit(&rq[0], 0, sizeof(rq));
258 
259  uint8_t aw;
260  usart.receive(&aw, 0, sizeof(aw));
261  return aw == MSG_OK;
262 }
263 
264 bool B15F::analogWrite1(uint16_t value)
265 {
266  uint8_t rq[] =
267  {
268  RQ_AA1,
269  static_cast<uint8_t >(value & 0xFF),
270  static_cast<uint8_t >(value >> 8)
271  };
272  usart.transmit(&rq[0], 0, sizeof(rq));
273 
274  uint8_t aw;
275  usart.receive(&aw, 0, sizeof(aw));
276  return aw == MSG_OK;
277 }
278 
279 uint16_t B15F::analogRead(uint8_t channel)
280 {
281  usart.clearInputBuffer();
282  if (channel > 7)
283  abort("Bad ADC channel: " + std::to_string(channel));
284 
285  uint8_t rq[] =
286  {
287  RQ_ADC,
288  channel
289  };
290 
291  usart.transmit(&rq[0], 0, sizeof(rq));
292 
293  uint16_t aw;
294  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
295 
296  if (aw > 1023)
297  abort("Bad ADC data detected (1)");
298  return aw;
299 }
300 
301 void
302 B15F::analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b,
303  uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
304 {
305  // prepare pointers
306  buffer_a += offset_a;
307  buffer_b += offset_b;
308 
309 
310  usart.clearInputBuffer();
311  uint8_t rq[] =
312  {
313  RQ_ADC_DAC_STROKE,
314  channel_a,
315  channel_b,
316  static_cast<uint8_t >(start & 0xFF),
317  static_cast<uint8_t >(start >> 8),
318  static_cast<uint8_t >(delta & 0xFF),
319  static_cast<uint8_t >(delta >> 8),
320  static_cast<uint8_t >(count & 0xFF),
321  static_cast<uint8_t >(count >> 8)
322  };
323 
324  usart.transmit(&rq[0], 0, sizeof(rq));
325 
326  for (uint16_t i = 0; i < count; i++)
327  {
328  if (buffer_a)
329  {
330  usart.receive(reinterpret_cast<uint8_t *>(&buffer_a[i]), 0, 2);
331 
332  if (buffer_a[i] > 1023) // check for broken usart connection
333  abort("Bad ADC data detected (2)");
334  }
335  else
336  {
337  usart.drop(2);
338  }
339 
340  if (buffer_b)
341  {
342  usart.receive(reinterpret_cast<uint8_t *>(&buffer_b[i]), 0, 2);
343 
344  if (buffer_b[i] > 1023) // check for broken usart connection
345  abort("Bad ADC data detected (3)");
346  }
347  else
348  {
349  usart.drop(2);
350  }
351  }
352 
353  uint8_t aw;
354  usart.receive(&aw, 0, sizeof(aw));
355  if(aw != MSG_OK)
356  abort("Sequenz unterbrochen");
357 }
358 
359 uint8_t B15F::pwmSetFrequency(uint32_t freq)
360 {
361  usart.clearInputBuffer();
362 
363  uint8_t rq[] =
364  {
365  RQ_PWM_SET_FREQ,
366  static_cast<uint8_t>((freq >> 0) & 0xFF),
367  static_cast<uint8_t>((freq >> 8) & 0xFF),
368  static_cast<uint8_t>((freq >> 16) & 0xFF),
369  static_cast<uint8_t>((freq >> 24) & 0xFF)
370  };
371 
372  usart.transmit(&rq[0], 0, sizeof(rq));
373 
374  uint8_t aw;
375  usart.receive(&aw, 0, sizeof(aw));
376  return aw;
377 }
378 
379 bool B15F::pwmSetValue(uint8_t value)
380 {
381  usart.clearInputBuffer();
382 
383  uint8_t rq[] =
384  {
385  RQ_PWM_SET_VALUE,
386  value
387  };
388 
389  usart.transmit(&rq[0], 0, sizeof(rq));
390 
391  uint8_t aw;
392  usart.receive(&aw, 0, sizeof(aw));
393  return aw == MSG_OK;
394 }
395 
396 bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
397 {
398  usart.clearInputBuffer();
399 
400  uint8_t rq[] =
401  {
402  RQ_SET_REG,
403  static_cast<uint8_t>(reinterpret_cast<size_t>(adr)),
404  val
405  };
406 
407  usart.transmit(&rq[0], 0, sizeof(rq));
408 
409  uint8_t aw;
410  usart.receive(&aw, 0, sizeof(aw));
411  return aw == val;
412 }
413 
414 uint8_t B15F::getRegister(volatile uint8_t* adr)
415 {
416  usart.clearInputBuffer();
417 
418  uint8_t rq[] =
419  {
420  RQ_GET_REG,
421  static_cast<uint8_t>(reinterpret_cast<size_t>(adr))
422  };
423 
424  usart.transmit(&rq[0], 0, sizeof(rq));
425 
426  uint8_t aw;
427  usart.receive(&aw, 0, sizeof(aw));
428  return aw;
429 }
430 
431 
432 void B15F::delay_ms(uint16_t ms)
433 {
434  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
435 }
436 
437 void B15F::delay_us(uint16_t us)
438 {
439  std::this_thread::sleep_for(std::chrono::microseconds(us));
440 }
441 
443 {
444  if (!instance)
445  instance = new B15F();
446 
447  return *instance;
448 }
449 
450 // https://stackoverflow.com/a/478960
451 std::string B15F::exec(std::string cmd)
452 {
453  std::array<char, 128> buffer;
454  std::string result;
455  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
456  if (!pipe)
457  {
458  throw std::runtime_error("popen() failed!");
459  }
460  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
461  {
462  result += buffer.data();
463  }
464  return result;
465 }
466 
467 void B15F::abort(std::string msg)
468 {
469  DriverException ex(msg);
470  abort(ex);
471 }
472 
473 void B15F::abort(std::exception &ex)
474 {
475  if (errorhandler)
476  errorhandler(ex);
477  else
478  {
479  std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl;
480  std::cout << ex.what() << std::endl;
481  throw DriverException(ex.what());
482  }
483 }
484 
485 void B15F::setAbortHandler(errorhandler_t func)
486 {
487  errorhandler = func;
488 }
+
static std::string exec(std::string cmd)
Definition: b15f.cpp:451
+
void delay_us(uint16_t us)
Definition: b15f.cpp:437
+
uint8_t digitalRead0(void)
Definition: b15f.cpp:207
+
uint8_t pwmSetFrequency(uint32_t freq)
Definition: b15f.cpp:359
+
void analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
Definition: b15f.cpp:302
+
bool testConnection(void)
Definition: b15f.cpp:95
+
uint8_t readDipSwitch(void)
Definition: b15f.cpp:235
+
uint8_t getRegister(volatile uint8_t *adr)
Definition: b15f.cpp:414
+
void delay_ms(uint16_t ms)
Definition: b15f.cpp:432
+
static B15F & getInstance(void)
Definition: b15f.cpp:442
+
Definition: b15f.h:31
+
void transmit(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:75
+
static void abort(std::string msg)
Definition: b15f.cpp:467
+
void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:84
+
void clearInputBuffer(void)
Definition: usart.cpp:54
+
void clearOutputBuffer(void)
Definition: usart.cpp:61
+
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:279
+
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:179
+
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:237
+
void setBaudrate(uint32_t baudrate)
Definition: usart.cpp:131
+
bool activateSelfTestMode(void)
Definition: b15f.cpp:166
+
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:134
+
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:240
+
bool analogWrite1(uint16_t port)
Definition: b15f.cpp:264
+
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:193
+
bool pwmSetValue(uint8_t value)
Definition: b15f.cpp:379
void discard(void)
Definition: b15f.cpp:72
-
bool analogWrite0(uint16_t)
Definition: b15f.cpp:199
-
void openDevice(std::string device)
Definition: usart.cpp:3
-
uint16_t readInt(void)
Definition: usart.cpp:229
-
uint8_t digitalRead1(void)
Definition: b15f.cpp:181
+
bool setRegister(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:396
+
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:238
+
void openDevice(std::string device)
Definition: usart.cpp:9
+
uint8_t digitalRead1(void)
Definition: b15f.cpp:221
void reconnect(void)
Definition: b15f.cpp:57
-
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:339
-
void writeInt(uint16_t d)
Definition: usart.cpp:81
-
bool testIntConv(void)
Definition: b15f.cpp:105
- +
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:243
+
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:485
+
void drop(uint8_t len)
Definition: usart.cpp:114
+
bool analogWrite0(uint16_t port)
Definition: b15f.cpp:249
+
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:242
+
bool testIntConv(void)
Definition: b15f.cpp:114
+ diff --git a/docs/html/b15f_8h_source.html b/docs/html/b15f_8h_source.html index 030198d..9729432 100644 --- a/docs/html/b15f_8h_source.html +++ b/docs/html/b15f_8h_source.html @@ -70,33 +70,44 @@ $(function() {
b15f.h
-
1 #ifndef B15F_H
2 #define B15F_H
3 
4 #include <iostream>
5 #include <bits/stdc++.h>
6 #include <string>
7 #include <fstream>
8 #include <cstdlib>
9 #include <chrono>
10 #include <cstdint>
11 #include <vector>
12 
13 #include <unistd.h>
14 #include <fcntl.h>
15 #include <sys/ioctl.h>
16 #include <termios.h>
17 #include "usart.h"
18 #include "driverexception.h"
19 #include "timeoutexception.h"
20 
21 typedef std::function<void(std::exception&)> errorhandler_t;
22 
23 
24 class B15F
25 {
26 private:
27  // privater Konstruktor
28  B15F(void);
29 public:
30 
31  /*************************************
32  * Grundfunktionen des B15F Treibers *
33  *************************************/
34 
39  void reconnect(void);
40 
45  void discard(void);
46 
51  bool testConnection(void);
52 
57  bool testIntConv(void);
58 
63  std::vector<std::string> getBoardInfo(void);
64 
69  void delay_ms(uint16_t ms);
70 
75  void delay_us(uint16_t us);
76 
81  static B15F& getInstance(void);
82 
87  static std::string exec(std::string cmd);
88 
93  static void abort(std::string msg);
94 
99  static void abort(std::exception& ex);
100 
105  static void setAbortHandler(errorhandler_t func);
106 
107  /*************************************/
108 
109 
110 
111  /*************************
112  * Steuerbefehle für B15 *
113  *************************/
114 
120  bool activateSelfTestMode(void);
121 
127  bool digitalWrite0(uint8_t);
128 
134  bool digitalWrite1(uint8_t);
135 
141  uint8_t digitalRead0(void);
142 
148  uint8_t digitalRead1(void);
149 
155  uint8_t readDipSwitch(void);
156 
162  bool analogWrite0(uint16_t);
163 
169  bool analogWrite1(uint16_t);
170 
176  uint16_t analogRead(uint8_t channel);
177 
193  void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count);
194 
195  /*************************/
196 
197 
198  // CONSTANTS
199  const std::string PRE = "[B15F] ";
200  constexpr static uint8_t MSG_OK = 0xFF;
201  constexpr static uint8_t MSG_FAIL = 0xFE;
202  constexpr static uint16_t RECONNECT_TIMEOUT = 64; // ms
203  constexpr static uint16_t WDT_TIMEOUT = 15; // ms
204  constexpr static uint8_t RECONNECT_TRIES = 3;
205  constexpr static uint32_t BAUDRATE = 57600;
206 
207 private:
208 
213  void init(void);
214 
215  USART usart;
216  static B15F* instance;
217  static errorhandler_t errorhandler;
218 
219  // REQUESTS
220  constexpr static uint8_t RQ_DISC = 0;
221  constexpr static uint8_t RQ_TEST = 1;
222  constexpr static uint8_t RQ_INFO = 2;
223  constexpr static uint8_t RQ_INT = 3;
224  constexpr static uint8_t RQ_ST = 4;
225  constexpr static uint8_t RQ_BA0 = 5;
226  constexpr static uint8_t RQ_BA1 = 6;
227  constexpr static uint8_t RQ_BE0 = 7;
228  constexpr static uint8_t RQ_BE1 = 8;
229  constexpr static uint8_t RQ_DSW = 9;
230  constexpr static uint8_t RQ_AA0 = 10;
231  constexpr static uint8_t RQ_AA1 = 11;
232  constexpr static uint8_t RQ_ADC = 12;
233  constexpr static uint8_t RQ_ADC_DAC_STROKE = 13;
234 };
235 
236 #endif // B15F_H
-
static std::string exec(std::string cmd)
Definition: b15f.cpp:309
-
void delay_us(uint16_t us)
Definition: b15f.cpp:295
-
uint8_t digitalRead0(void)
Definition: b15f.cpp:172
-
void analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
Definition: b15f.cpp:241
-
bool testConnection(void)
Definition: b15f.cpp:90
-
uint8_t readDipSwitch(void)
Definition: b15f.cpp:190
-
void delay_ms(uint16_t ms)
Definition: b15f.cpp:290
-
bool analogWrite1(uint16_t)
Definition: b15f.cpp:209
-
static B15F & getInstance(void)
Definition: b15f.cpp:300
-
Definition: b15f.h:24
-
static void abort(std::string msg)
Definition: b15f.cpp:322
+
1 #ifndef B15F_H
2 #define B15F_H
3 
4 #include <iostream>
5 #include <bits/stdc++.h>
6 #include <string>
7 #include <fstream>
8 #include <cstdlib>
9 #include <chrono>
10 #include <cstdint>
11 #include <vector>
12 
13 #include <unistd.h>
14 #include <fcntl.h>
15 #include <sys/ioctl.h>
16 #include <termios.h>
17 #include "usart.h"
18 #include "driverexception.h"
19 #include "timeoutexception.h"
20 
21 // wichtig für die Register-Zugriffe
22 #define _AVR_IO_H_ 1 // Erzwinge die Inklusion
23 #include "/usr/lib/avr/include/avr/sfr_defs.h"
24 #include "/usr/lib/avr/include/avr/iom1284p.h"
25 
26 typedef std::function<void(std::exception&)> errorhandler_t;
27 
28 
31 class B15F
32 {
33 private:
34  // privater Konstruktor
35  B15F(void);
36 public:
37 
38  /*************************************
39  * Grundfunktionen des B15F Treibers *
40  *************************************/
41 
46  void reconnect(void);
47 
52  void discard(void);
53 
58  bool testConnection(void);
59 
64  bool testIntConv(void);
65 
70  std::vector<std::string> getBoardInfo(void);
71 
76  void delay_ms(uint16_t ms);
77 
82  void delay_us(uint16_t us);
83 
88  static B15F& getInstance(void);
89 
94  static std::string exec(std::string cmd);
95 
100  static void abort(std::string msg);
101 
106  static void abort(std::exception& ex);
107 
112  static void setAbortHandler(errorhandler_t func);
113 
114  /*************************************/
115 
116 
117 
118  /*************************
119  * Steuerbefehle für B15 *
120  *************************/
121 
127  bool activateSelfTestMode(void);
128 
134  bool digitalWrite0(uint8_t);
135 
141  bool digitalWrite1(uint8_t);
142 
148  uint8_t digitalRead0(void);
149 
155  uint8_t digitalRead1(void);
156 
162  uint8_t readDipSwitch(void);
163 
169  bool analogWrite0(uint16_t port);
170 
176  bool analogWrite1(uint16_t port);
177 
183  uint16_t analogRead(uint8_t channel);
184 
200  void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count);
201 
210  uint8_t pwmSetFrequency(uint32_t freq);
211 
217  bool pwmSetValue(uint8_t value);
218 
226  bool setRegister(volatile uint8_t* adr, uint8_t val);
227 
233  uint8_t getRegister(volatile uint8_t* adr);
234 
235  /*************************/
236 
237 
238  // CONSTANTS
239  const std::string PRE = "[B15F] ";
240  constexpr static uint8_t MSG_OK = 0xFF;
241  constexpr static uint8_t MSG_FAIL = 0xFE;
242  constexpr static uint16_t RECONNECT_TIMEOUT = 64;
243  constexpr static uint16_t WDT_TIMEOUT = 15;
244  constexpr static uint8_t RECONNECT_TRIES = 3;
245  constexpr static uint32_t BAUDRATE = 57600;
246 
247 private:
248 
253  void init(void);
254 
255  USART usart;
256  static B15F* instance;
257  static errorhandler_t errorhandler;
258 
259  // REQUESTS
260  constexpr static uint8_t RQ_DISC = 0;
261  constexpr static uint8_t RQ_TEST = 1;
262  constexpr static uint8_t RQ_INFO = 2;
263  constexpr static uint8_t RQ_INT = 3;
264  constexpr static uint8_t RQ_ST = 4;
265  constexpr static uint8_t RQ_BA0 = 5;
266  constexpr static uint8_t RQ_BA1 = 6;
267  constexpr static uint8_t RQ_BE0 = 7;
268  constexpr static uint8_t RQ_BE1 = 8;
269  constexpr static uint8_t RQ_DSW = 9;
270  constexpr static uint8_t RQ_AA0 = 10;
271  constexpr static uint8_t RQ_AA1 = 11;
272  constexpr static uint8_t RQ_ADC = 12;
273  constexpr static uint8_t RQ_ADC_DAC_STROKE = 13;
274  constexpr static uint8_t RQ_PWM_SET_FREQ = 14;
275  constexpr static uint8_t RQ_PWM_SET_VALUE = 15;
276  constexpr static uint8_t RQ_SET_REG = 16;
277  constexpr static uint8_t RQ_GET_REG = 17;
278 };
279 
280 #endif // B15F_H
+
static std::string exec(std::string cmd)
Definition: b15f.cpp:451
+
constexpr static uint8_t MSG_FAIL
Value to reject a received command.
Definition: b15f.h:239
+
void delay_us(uint16_t us)
Definition: b15f.cpp:437
+
uint8_t digitalRead0(void)
Definition: b15f.cpp:207
+
uint8_t pwmSetFrequency(uint32_t freq)
Definition: b15f.cpp:359
+
void analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
Definition: b15f.cpp:302
+
bool testConnection(void)
Definition: b15f.cpp:95
+
uint8_t readDipSwitch(void)
Definition: b15f.cpp:235
+
uint8_t getRegister(volatile uint8_t *adr)
Definition: b15f.cpp:414
+
void delay_ms(uint16_t ms)
Definition: b15f.cpp:432
+
static B15F & getInstance(void)
Definition: b15f.cpp:442
+
Definition: b15f.h:31
+
static void abort(std::string msg)
Definition: b15f.cpp:467
Definition: usart.h:16
-
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:219
-
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:152
-
bool activateSelfTestMode(void)
Definition: b15f.cpp:144
-
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:118
-
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:162
+
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:279
+
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:179
+
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:237
+
bool activateSelfTestMode(void)
Definition: b15f.cpp:166
+
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:134
+
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:240
+
bool analogWrite1(uint16_t port)
Definition: b15f.cpp:264
+
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:193
+
bool pwmSetValue(uint8_t value)
Definition: b15f.cpp:379
void discard(void)
Definition: b15f.cpp:72
-
bool analogWrite0(uint16_t)
Definition: b15f.cpp:199
-
uint8_t digitalRead1(void)
Definition: b15f.cpp:181
+
bool setRegister(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:396
+
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:238
+
uint8_t digitalRead1(void)
Definition: b15f.cpp:221
+
constexpr static uint16_t WDT_TIMEOUT
Time in ms after which the watch dog timer resets the MCU.
Definition: b15f.h:241
void reconnect(void)
Definition: b15f.cpp:57
-
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:339
-
bool testIntConv(void)
Definition: b15f.cpp:105
+
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:243
+
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:485
+
bool analogWrite0(uint16_t port)
Definition: b15f.cpp:249
+
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:242
+
bool testIntConv(void)
Definition: b15f.cpp:114
diff --git a/docs/html/backup_8cpp_source.html b/docs/html/backup_8cpp_source.html new file mode 100644 index 0000000..1ac6851 --- /dev/null +++ b/docs/html/backup_8cpp_source.html @@ -0,0 +1,83 @@ + + + + + + + +B15F: drv/backup.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
backup.cpp
+
+
+
1 
2 void USART::writeByte(uint8_t b)
3 {
4  int sent = write(file_desc, &b, 1);
5  if (sent != 1)
6  {
7  std::cout << "WARNUNG: Fehler beim Senden (" << sent << "): writeByte(), wiederhole..." << std::endl;
8  usleep(100000);
9  sent = write(file_desc, &b, 1);
10  if (sent != 1)
11  throw USARTException("Fehler beim Senden: writeByte()");
12  }
13 
14 }
15 
16 void USART::writeInt(uint16_t d)
17 {
18  int sent = write(file_desc, reinterpret_cast<char *>(&d), 2);
19  if (sent != 2)
20  throw USARTException("Fehler beim Senden: writeInt()");
21 }
22 
23 void USART::writeU32(uint32_t w)
24 {
25  int sent = write(file_desc, reinterpret_cast<char *>(&w), 4);
26  if (sent != 4)
27  throw USARTException("Fehler beim Senden: writeU32()");
28 }
29 
30 uint8_t USART::readByte(void)
31 {
32  char b;
33  auto start = std::chrono::steady_clock::now();
34  auto end = start;
35  uint16_t elapsed = 0;
36  while (elapsed < timeout * 100)
37  {
38  int code = read(file_desc, &b, 1);
39  if (code > 0)
40  return static_cast<uint8_t>(b);
41 
42  end = std::chrono::steady_clock::now();
43  elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
44  }
45 
46  throw TimeoutException("Verbindung unterbrochen.", timeout);
47 }
48 
49 uint16_t USART::readInt(void)
50 {
51  return readByte() | readByte() << 8;
52 }
+ + + + + + diff --git a/docs/html/classB15F-members.html b/docs/html/classB15F-members.html index 6ad79a3..e88d578 100644 --- a/docs/html/classB15F-members.html +++ b/docs/html/classB15F-members.html @@ -74,9 +74,9 @@ $(function() { activateSelfTestMode(void)B15F analogRead(uint8_t channel)B15F analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)B15F - analogWrite0(uint16_t)B15F - analogWrite1(uint16_t)B15F - BAUDRATE (defined in B15F)B15Fstatic + analogWrite0(uint16_t port)B15F + analogWrite1(uint16_t port)B15F + BAUDRATEB15Fstatic delay_ms(uint16_t ms)B15F delay_us(uint16_t us)B15F digitalRead0(void)B15F @@ -87,21 +87,25 @@ $(function() { exec(std::string cmd)B15Fstatic getBoardInfo(void)B15F getInstance(void)B15Fstatic - MSG_FAIL (defined in B15F)B15Fstatic - MSG_OK (defined in B15F)B15Fstatic - PRE (defined in B15F)B15F - readDipSwitch(void)B15F - reconnect(void)B15F - RECONNECT_TIMEOUT (defined in B15F)B15Fstatic - RECONNECT_TRIES (defined in B15F)B15Fstatic - setAbortHandler(errorhandler_t func)B15Fstatic + getRegister(volatile uint8_t *adr)B15F + MSG_FAILB15Fstatic + MSG_OKB15Fstatic + PREB15F + pwmSetFrequency(uint32_t freq)B15F + pwmSetValue(uint8_t value)B15F + readDipSwitch(void)B15F + reconnect(void)B15F + RECONNECT_TIMEOUTB15Fstatic + RECONNECT_TRIESB15Fstatic + setAbortHandler(errorhandler_t func)B15Fstatic + setRegister(volatile uint8_t *adr, uint8_t val)B15F testConnection(void)B15F testIntConv(void)B15F - WDT_TIMEOUT (defined in B15F)B15Fstatic + WDT_TIMEOUTB15Fstatic diff --git a/docs/html/classB15F.html b/docs/html/classB15F.html index d2c9e9b..18bb42a 100644 --- a/docs/html/classB15F.html +++ b/docs/html/classB15F.html @@ -72,6 +72,8 @@ $(function() {
B15F Class Reference
+ +

#include <b15f.h>

@@ -101,14 +103,22 @@ Public Member Functions - - - - + + + + + + + + + + + +

Public Member Functions

 
uint8_t readDipSwitch (void)
 
bool analogWrite0 (uint16_t)
 
bool analogWrite1 (uint16_t)
 
bool analogWrite0 (uint16_t port)
 
bool analogWrite1 (uint16_t port)
 
uint16_t analogRead (uint8_t channel)
 
void analogSequence (uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
 
uint8_t pwmSetFrequency (uint32_t freq)
 
bool pwmSetValue (uint8_t value)
 
bool setRegister (volatile uint8_t *adr, uint8_t val)
 
uint8_t getRegister (volatile uint8_t *adr)
 
@@ -126,33 +136,41 @@ Static Public Member Functions +const std::string  +

Static Public Member Functions

Public Attributes

-const std::string PRE = "[B15F] "
PRE = "[B15F] "
 B15F stdout prefix.
 
+constexpr static uint8_t  + +constexpr static uint8_t  + +constexpr static uint16_t  + +constexpr static uint16_t  + +constexpr static uint8_t  + +constexpr static uint32_t  +

Static Public Attributes

-constexpr static uint8_t MSG_OK = 0xFF
MSG_OK = 0xFF
 Value to acknowledge a received command.
 
-constexpr static uint8_t MSG_FAIL = 0xFE
MSG_FAIL = 0xFE
 Value to reject a received command.
 
-constexpr static uint16_t RECONNECT_TIMEOUT = 64
RECONNECT_TIMEOUT = 64
 Time in ms after which a reconnect attempt aborts.
 
-constexpr static uint16_t WDT_TIMEOUT = 15
WDT_TIMEOUT = 15
 Time in ms after which the watch dog timer resets the MCU.
 
-constexpr static uint8_t RECONNECT_TRIES = 3
RECONNECT_TRIES = 3
 Maximum count of reconnect attempts after which the driver stops.
 
-constexpr static uint32_t BAUDRATE = 57600
BAUDRATE = 57600
 USART baudrate for communication with the MCU.
 

Detailed Description

-
-

Definition at line 24 of file b15f.h.

+

main driver class

+ +

Definition at line 31 of file b15f.h.

Member Function Documentation

◆ abort() [1/2]

@@ -184,7 +202,7 @@ constexpr static uint32_t  -

Definition at line 327 of file b15f.cpp.

+

Definition at line 473 of file b15f.cpp.

@@ -218,7 +236,7 @@ constexpr static uint32_t  -

Definition at line 322 of file b15f.cpp.

+

Definition at line 467 of file b15f.cpp.

@@ -244,7 +262,7 @@ constexpr static uint32_t  -

Definition at line 144 of file b15f.cpp.

+

Definition at line 166 of file b15f.cpp.

@@ -276,7 +294,7 @@ constexpr static uint32_t  -

Definition at line 219 of file b15f.cpp.

+

Definition at line 279 of file b15f.cpp.

@@ -368,12 +386,12 @@ constexpr static uint32_t  -

Definition at line 241 of file b15f.cpp.

+

Definition at line 302 of file b15f.cpp.

- -

◆ analogWrite0()

+ +

◆ analogWrite0()

@@ -382,7 +400,7 @@ constexpr static uint32_t  bool B15F::analogWrite0 ( uint16_t  - value) + port) @@ -400,12 +418,12 @@ constexpr static uint32_t  -

Definition at line 199 of file b15f.cpp.

+

Definition at line 249 of file b15f.cpp.

- -

◆ analogWrite1()

+ +

◆ analogWrite1()

@@ -414,7 +432,7 @@ constexpr static uint32_t  bool B15F::analogWrite1 ( uint16_t  - value) + port) @@ -432,7 +450,7 @@ constexpr static uint32_t  -

Definition at line 209 of file b15f.cpp.

+

Definition at line 264 of file b15f.cpp.

@@ -458,7 +476,7 @@ constexpr static uint32_t  -

Definition at line 290 of file b15f.cpp.

+

Definition at line 432 of file b15f.cpp.

@@ -484,7 +502,7 @@ constexpr static uint32_t  -

Definition at line 295 of file b15f.cpp.

+

Definition at line 437 of file b15f.cpp.

@@ -511,7 +529,7 @@ constexpr static uint32_t  -

Definition at line 172 of file b15f.cpp.

+

Definition at line 207 of file b15f.cpp.

@@ -538,7 +556,7 @@ constexpr static uint32_t  -

Definition at line 181 of file b15f.cpp.

+

Definition at line 221 of file b15f.cpp.

@@ -570,7 +588,7 @@ constexpr static uint32_t  -

Definition at line 152 of file b15f.cpp.

+

Definition at line 179 of file b15f.cpp.

@@ -602,7 +620,7 @@ constexpr static uint32_t  -

Definition at line 162 of file b15f.cpp.

+

Definition at line 193 of file b15f.cpp.

@@ -662,7 +680,7 @@ constexpr static uint32_t  -

Definition at line 309 of file b15f.cpp.

+

Definition at line 451 of file b15f.cpp.

@@ -688,7 +706,7 @@ constexpr static uint32_t  -

Definition at line 118 of file b15f.cpp.

+

Definition at line 134 of file b15f.cpp.

@@ -722,7 +740,104 @@ constexpr static uint32_t  -

Definition at line 300 of file b15f.cpp.

+

Definition at line 442 of file b15f.cpp.

+ + + + +

◆ getRegister()

+ +
+
+ + + + + + + + +
uint8_t B15F::getRegister (volatile uint8_t * adr)
+
+

Liefert den Wert eines MCU Registers.

Parameters
+ + +
adrSpeicheradresse des Registers
+
+
+
Exceptions
+ + +
DriverException
+
+
+ +

Definition at line 414 of file b15f.cpp.

+ +
+
+ +

◆ pwmSetFrequency()

+ +
+
+ + + + + + + + +
uint8_t B15F::pwmSetFrequency (uint32_t freq)
+
+

Setzt die Register so, dass näherungsweise die gewünschte Frequenz erzeugt wird. Ist freq == 0 wird PWM deaktiviert. Standardfrequenz: 31300 (empfohlen, da dann TOP == 255)

Parameters
+ + +
freqPWM Frequenz
+
+
+
Returns
Top Wert des PWM Value für die gesetzte Frequenz
+
Exceptions
+ + +
DriverException
+
+
+ +

Definition at line 359 of file b15f.cpp.

+ +
+
+ +

◆ pwmSetValue()

+ +
+
+ + + + + + + + +
bool B15F::pwmSetValue (uint8_t value)
+
+

Setzt den PWM Wert.

Parameters
+ + +
valuePWM Wert [0..0xFF]
+
+
+
Exceptions
+ + +
DriverException
+
+
+ +

Definition at line 379 of file b15f.cpp.

@@ -749,7 +864,7 @@ constexpr static uint32_t  -

Definition at line 190 of file b15f.cpp.

+

Definition at line 235 of file b15f.cpp.

@@ -809,7 +924,50 @@ constexpr static uint32_t  -

Definition at line 339 of file b15f.cpp.

+

Definition at line 485 of file b15f.cpp.

+ + + + +

◆ setRegister()

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool B15F::setRegister (volatile uint8_t * adr,
uint8_t val 
)
+
+

Setzt direkt den Wert eines MCU Registers. Wichtig: bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!

Parameters
+ + + +
adrSpeicheradresse des Registers
valNeuer Wert für das Register
+
+
+
Exceptions
+ + +
DriverException
+
+
+ +

Definition at line 396 of file b15f.cpp.

@@ -835,7 +993,7 @@ constexpr static uint32_t  -

Definition at line 90 of file b15f.cpp.

+

Definition at line 95 of file b15f.cpp.

@@ -861,7 +1019,7 @@ constexpr static uint32_t  -

Definition at line 105 of file b15f.cpp.

+

Definition at line 114 of file b15f.cpp.

@@ -872,7 +1030,7 @@ constexpr static uint32_t  diff --git a/docs/html/classDot-members.html b/docs/html/classDot-members.html index 414ff4f..b493400 100644 --- a/docs/html/classDot-members.html +++ b/docs/html/classDot-members.html @@ -69,14 +69,14 @@ $(function() {

This is the complete list of members for Dot, including all inherited members.

- - - - + + + +
Dot(uint16_t x, uint16_t y, uint8_t curve) (defined in Dot)Dot
getCurve(void) const (defined in Dot)Dot
getX(void) const (defined in Dot)Dot
getY(void) const (defined in Dot)Dot
Dot(uint16_t x, uint16_t y, uint8_t curve)Dot
getCurve(void) constDot
getX(void) constDot
getY(void) constDot
diff --git a/docs/html/classDot.html b/docs/html/classDot.html index 537f60a..4d8cd1d 100644 --- a/docs/html/classDot.html +++ b/docs/html/classDot.html @@ -69,33 +69,134 @@ $(function() {
Dot Class Reference
+ +

#include <dot.h>

- + - + - + - +

Public Member Functions

Dot (uint16_t x, uint16_t y, uint8_t curve)
 Dot (uint16_t x, uint16_t y, uint8_t curve)
 
-uint16_t getX (void) const
uint16_t getX (void) const
 
-uint16_t getY (void) const
uint16_t getY (void) const
 
-uint8_t getCurve (void) const
uint8_t getCurve (void) const
 

Detailed Description

-
-

Definition at line 7 of file dot.h.

-

The documentation for this class was generated from the following files:
    +

    Immutable dot class with x and y coordinate and curve index. Dots with the same curve index get the same color by plotty.

    + +

    Definition at line 12 of file dot.h.

    +

    Constructor & Destructor Documentation

    + +

    ◆ Dot()

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    Dot::Dot (uint16_t x,
    uint16_t y,
    uint8_t curve 
    )
    +
    +

    Constructor with x and y coordinate and curve index.

    + +

    Definition at line 3 of file dot.cpp.

    + +
    +
    +

    Member Function Documentation

    + +

    ◆ getCurve()

    + +
    +
    + + + + + + + + +
    uint8_t Dot::getCurve (void ) const
    +
    +

    Returns the curve index.

    + +

    Definition at line 19 of file dot.cpp.

    + +
    +
    + +

    ◆ getX()

    + +
    +
    + + + + + + + + +
    uint16_t Dot::getX (void ) const
    +
    +

    Returns the x coordinate.

    + +

    Definition at line 9 of file dot.cpp.

    + +
    +
    + +

    ◆ getY()

    + +
    +
    + + + + + + + + +
    uint16_t Dot::getY (void ) const
    +
    +

    Returns the y coordinate.

    + +

    Definition at line 14 of file dot.cpp.

    + +
    +
    +
    The documentation for this class was generated from the following files:
diff --git a/docs/html/classDriverException-members.html b/docs/html/classDriverException-members.html index d4c2560..385458a 100644 --- a/docs/html/classDriverException-members.html +++ b/docs/html/classDriverException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classDriverException.html b/docs/html/classDriverException.html index 1f469b3..b3dd57e 100644 --- a/docs/html/classDriverException.html +++ b/docs/html/classDriverException.html @@ -70,9 +70,13 @@ $(function() {
DriverException Class Reference
-
-Inheritance diagram for DriverException:
-
+ +

#include <driverexception.h>

+
+ + Inheritance diagram for DriverException:
+
+
+ @@ -96,15 +100,16 @@ std::string msg_<  

Detailed Description

-
-

Definition at line 8 of file driverexception.h.

+

Exception driver problems, for instance incompatible firmware version.

+ +

Definition at line 10 of file driverexception.h.


The documentation for this class was generated from the following file:
diff --git a/docs/html/classPlottyFile-members.html b/docs/html/classPlottyFile-members.html index 2486957..69c5b8a 100644 --- a/docs/html/classPlottyFile-members.html +++ b/docs/html/classPlottyFile-members.html @@ -69,38 +69,38 @@ $(function() {

This is the complete list of members for PlottyFile, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addDot(Dot &dot) (defined in PlottyFile)PlottyFile
addDot(Dot dot) (defined in PlottyFile)PlottyFile
getDescPara(void) const (defined in PlottyFile)PlottyFile
getDescX(void) const (defined in PlottyFile)PlottyFile
getDescY(void) const (defined in PlottyFile)PlottyFile
getFunctionType(void) const (defined in PlottyFile)PlottyFile
getParaFirstCurve(void) const (defined in PlottyFile)PlottyFile
getParaStepWidth(void) const (defined in PlottyFile)PlottyFile
getQuadrant(void) const (defined in PlottyFile)PlottyFile
getRefX(void) const (defined in PlottyFile)PlottyFile
getRefY(void) const (defined in PlottyFile)PlottyFile
getUnitPara(void) const (defined in PlottyFile)PlottyFile
getUnitX(void) const (defined in PlottyFile)PlottyFile
getUnitY(void) const (defined in PlottyFile)PlottyFile
setDescPara(std::string) (defined in PlottyFile)PlottyFile
setDescX(std::string) (defined in PlottyFile)PlottyFile
setDescY(std::string) (defined in PlottyFile)PlottyFile
setFunctionType(FunctionType) (defined in PlottyFile)PlottyFile
setParaFirstCurve(uint16_t) (defined in PlottyFile)PlottyFile
setParaStepWidth(uint16_t) (defined in PlottyFile)PlottyFile
setQuadrant(uint8_t) (defined in PlottyFile)PlottyFile
setRefX(uint16_t) (defined in PlottyFile)PlottyFile
setRefY(uint16_t) (defined in PlottyFile)PlottyFile
setUnitPara(std::string) (defined in PlottyFile)PlottyFile
setUnitX(std::string) (defined in PlottyFile)PlottyFile
setUnitY(std::string) (defined in PlottyFile)PlottyFile
startPlotty(std::string filename) (defined in PlottyFile)PlottyFile
writeToFile(std::string filename) (defined in PlottyFile)PlottyFile
addDot(Dot &dot)PlottyFile
addDot(Dot dot)PlottyFile
getDescPara(void) constPlottyFile
getDescX(void) constPlottyFile
getDescY(void) constPlottyFile
getFunctionType(void) constPlottyFile
getParaFirstCurve(void) constPlottyFile
getParaStepWidth(void) constPlottyFile
getQuadrant(void) constPlottyFile
getRefX(void) constPlottyFile
getRefY(void) constPlottyFile
getUnitPara(void) constPlottyFile
getUnitX(void) constPlottyFile
getUnitY(void) constPlottyFile
setDescPara(std::string desc_para)PlottyFile
setDescX(std::string desc_x)PlottyFile
setDescY(std::string desc_y)PlottyFile
setFunctionType(FunctionType function_type)PlottyFile
setParaFirstCurve(uint16_t para_first)PlottyFile
setParaStepWidth(uint16_t para_stepwidth)PlottyFile
setQuadrant(uint8_t quadrant)PlottyFile
setRefX(uint16_t ref_x)PlottyFile
setRefY(uint16_t ref_y)PlottyFile
setUnitPara(std::string unit_para)PlottyFile
setUnitX(std::string unit_x)PlottyFile
setUnitY(std::string unit_y)PlottyFile
startPlotty(std::string filename)PlottyFile
writeToFile(std::string filename)PlottyFile
diff --git a/docs/html/classPlottyFile.html b/docs/html/classPlottyFile.html index e3e9672..3eb73ca 100644 --- a/docs/html/classPlottyFile.html +++ b/docs/html/classPlottyFile.html @@ -69,105 +69,749 @@ $(function() {
PlottyFile Class Reference
+ +

#include <plottyfile.h>

- + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - +

Public Member Functions

-void addDot (Dot &dot)
void addDot (Dot &dot)
 
-void addDot (Dot dot)
void addDot (Dot dot)
 
-void setFunctionType (FunctionType)
 
-void setQuadrant (uint8_t)
 
-void setRefX (uint16_t)
 
-void setRefY (uint16_t)
 
-void setParaFirstCurve (uint16_t)
 
-void setParaStepWidth (uint16_t)
 
-void setUnitX (std::string)
 
-void setDescX (std::string)
 
-void setUnitY (std::string)
 
-void setDescY (std::string)
 
-void setUnitPara (std::string)
 
-void setDescPara (std::string)
 
-FunctionType getFunctionType (void) const
void setFunctionType (FunctionType function_type)
 
void setQuadrant (uint8_t quadrant)
 
void setRefX (uint16_t ref_x)
 
void setRefY (uint16_t ref_y)
 
void setParaFirstCurve (uint16_t para_first)
 
void setParaStepWidth (uint16_t para_stepwidth)
 
void setUnitX (std::string unit_x)
 
void setDescX (std::string desc_x)
 
void setUnitY (std::string unit_y)
 
void setDescY (std::string desc_y)
 
void setUnitPara (std::string unit_para)
 
void setDescPara (std::string desc_para)
 
FunctionType getFunctionType (void) const
 
-uint8_t getQuadrant (void) const
uint8_t getQuadrant (void) const
 
-uint16_t getRefX (void) const
uint16_t getRefX (void) const
 
-uint16_t getRefY (void) const
uint16_t getRefY (void) const
 
-uint16_t getParaFirstCurve (void) const
uint16_t getParaFirstCurve (void) const
 
-uint16_t getParaStepWidth (void) const
uint16_t getParaStepWidth (void) const
 
-std::string getUnitX (void) const
std::string getUnitX (void) const
 
-std::string getDescX (void) const
std::string getDescX (void) const
 
-std::string getUnitY (void) const
std::string getUnitY (void) const
 
-std::string getDescY (void) const
std::string getDescY (void) const
 
-std::string getUnitPara (void) const
std::string getUnitPara (void) const
 
-std::string getDescPara (void) const
std::string getDescPara (void) const
 
-void writeToFile (std::string filename)
void writeToFile (std::string filename)
 
-void startPlotty (std::string filename)
void startPlotty (std::string filename)
 

Detailed Description

-
-

Definition at line 17 of file plottyfile.h.

-

The documentation for this class was generated from the following files:
    +

    Wrapper class for convenient plot file creation, needed to display graphs using plotty.

    + +

    Definition at line 20 of file plottyfile.h.

    +

    Member Function Documentation

    + +

    ◆ addDot() [1/2]

    + +
    +
    + + + + + + + + +
    void PlottyFile::addDot (Dotdot)
    +
    +

    Adds a dot to the plotty file.

    Parameters
    + + +
    dotthe dot
    +
    +
    + +

    Definition at line 3 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ addDot() [2/2]

    + +
    +
    + + + + + + + + +
    void PlottyFile::addDot (Dot dot)
    +
    +

    Adds a dot by reference to the plotty file.

    Parameters
    + + +
    dotthe dot
    +
    +
    + +

    Definition at line 8 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getDescPara()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getDescPara (void ) const
    +
    +
    Returns
    description of parameter
    + +

    Definition at line 130 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getDescX()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getDescX (void ) const
    +
    +
    Returns
    description of x axis
    + +

    Definition at line 110 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getDescY()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getDescY (void ) const
    +
    +
    Returns
    description of y axis
    + +

    Definition at line 120 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getFunctionType()

    + +
    +
    + + + + + + + + +
    FunctionType PlottyFile::getFunctionType (void ) const
    +
    +
    Returns
    the FunctionType
    + +

    Definition at line 75 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getParaFirstCurve()

    + +
    +
    + + + + + + + + +
    uint16_t PlottyFile::getParaFirstCurve (void ) const
    +
    +
    Returns
    initial parameter value
    + +

    Definition at line 95 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getParaStepWidth()

    + +
    +
    + + + + + + + + +
    uint16_t PlottyFile::getParaStepWidth (void ) const
    +
    +
    Returns
    parameter stepwith
    + +

    Definition at line 100 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getQuadrant()

    + +
    +
    + + + + + + + + +
    uint8_t PlottyFile::getQuadrant (void ) const
    +
    +
    Returns
    the quadrant
    + +

    Definition at line 80 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getRefX()

    + +
    +
    + + + + + + + + +
    uint16_t PlottyFile::getRefX (void ) const
    +
    +
    Returns
    x reference (max) value
    + +

    Definition at line 85 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getRefY()

    + +
    +
    + + + + + + + + +
    uint16_t PlottyFile::getRefY (void ) const
    +
    +
    Returns
    y reference (max) value
    + +

    Definition at line 90 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getUnitPara()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getUnitPara (void ) const
    +
    +
    Returns
    unit of parameter
    + +

    Definition at line 125 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getUnitX()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getUnitX (void ) const
    +
    +
    Returns
    unit of x axis
    + +

    Definition at line 105 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ getUnitY()

    + +
    +
    + + + + + + + + +
    std::string PlottyFile::getUnitY (void ) const
    +
    +
    Returns
    unit of y axis
    + +

    Definition at line 115 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setDescPara()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setDescPara (std::string desc_para)
    +
    +

    Sets the description of the parameter.

    Parameters
    + + +
    para_firstdescription
    +
    +
    + +

    Definition at line 70 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setDescX()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setDescX (std::string desc_x)
    +
    +

    Sets the description of the x axis.

    Parameters
    + + +
    para_firstdescription
    +
    +
    + +

    Definition at line 50 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setDescY()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setDescY (std::string desc_y)
    +
    +

    Sets the description of the y axis.

    Parameters
    + + +
    para_firstdescription
    +
    +
    + +

    Definition at line 60 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setFunctionType()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setFunctionType (FunctionType function_type)
    +
    +

    Sets the FunctionType of this plotty file.

    Parameters
    + + +
    function_typeenum value
    +
    +
    + +

    Definition at line 13 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setParaFirstCurve()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setParaFirstCurve (uint16_t para_first)
    +
    +

    Sets initial value of the parameter. Gets used together with the stepwith to label the curves.

    Parameters
    + + +
    para_firstinitial parameter value
    +
    +
    + +

    Definition at line 35 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setParaStepWidth()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setParaStepWidth (uint16_t para_stepwidth)
    +
    +

    Sets the stepwith the parameter got increased with each curve.

    Parameters
    + + +
    para_firstparameter stepwith
    +
    +
    + +

    Definition at line 40 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setQuadrant()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setQuadrant (uint8_t quadrant)
    +
    +

    Sets the quadrant of this plot.

    Parameters
    + + +
    quadrantquadrant number (1..4)
    +
    +
    + +

    Definition at line 18 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setRefX()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setRefX (uint16_t ref_x)
    +
    +

    Sets reference (max) value of the x axis

    Parameters
    + + +
    ref_xreference value
    +
    +
    + +

    Definition at line 25 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setRefY()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setRefY (uint16_t ref_y)
    +
    +

    Sets reference (max) value of the y axis

    Parameters
    + + +
    ref_yreference value
    +
    +
    + +

    Definition at line 30 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setUnitPara()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setUnitPara (std::string unit_para)
    +
    +

    Sets the unit of the parameter.

    Parameters
    + + +
    para_firstunit
    +
    +
    + +

    Definition at line 65 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setUnitX()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setUnitX (std::string unit_x)
    +
    +

    Sets the unit of the x axis.

    Parameters
    + + +
    para_firstunit
    +
    +
    + +

    Definition at line 45 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ setUnitY()

    + +
    +
    + + + + + + + + +
    void PlottyFile::setUnitY (std::string unit_y)
    +
    +

    Sets the unit of the y axis.

    Parameters
    + + +
    para_firstunit
    +
    +
    + +

    Definition at line 55 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ startPlotty()

    + +
    +
    + + + + + + + + +
    void PlottyFile::startPlotty (std::string filename)
    +
    +

    Starts plotty with a plot file.

    Parameters
    + + +
    filenameplot path
    +
    +
    + +

    Definition at line 196 of file plottyfile.cpp.

    + +
    +
    + +

    ◆ writeToFile()

    + +
    +
    + + + + + + + + +
    void PlottyFile::writeToFile (std::string filename)
    +
    +

    Saves the PlottyFile in a binary format, ready to open with plotty.

    Parameters
    + + +
    filenamedesired plot path
    +
    +
    + +

    Definition at line 147 of file plottyfile.cpp.

    + +
    +
    +
    The documentation for this class was generated from the following files:
diff --git a/docs/html/classTimeoutException-members.html b/docs/html/classTimeoutException-members.html index 511f555..15cc27f 100644 --- a/docs/html/classTimeoutException-members.html +++ b/docs/html/classTimeoutException-members.html @@ -69,16 +69,15 @@ $(function() {

This is the complete list of members for TimeoutException, including all inherited members.

- - - - - - + + + + +
m_timeout (defined in TimeoutException)TimeoutExceptionprotected
msg (defined in TimeoutException)TimeoutExceptionprotected
TimeoutException(const char *message, int timeout) (defined in TimeoutException)TimeoutExceptioninlineexplicit
TimeoutException(const std::string &message, int timeout) (defined in TimeoutException)TimeoutExceptioninlineexplicit
what() const (defined in TimeoutException)TimeoutExceptioninlinevirtual
~TimeoutException() (defined in TimeoutException)TimeoutExceptioninlinevirtual
msgTimeoutExceptionprotected
TimeoutException(const char *message)TimeoutExceptioninlineexplicit
TimeoutException(const std::string &message)TimeoutExceptioninlineexplicit
what() constTimeoutExceptioninlinevirtual
~TimeoutException()=defaultTimeoutExceptionvirtual
diff --git a/docs/html/classTimeoutException.html b/docs/html/classTimeoutException.html index 8419517..015849c 100644 --- a/docs/html/classTimeoutException.html +++ b/docs/html/classTimeoutException.html @@ -70,44 +70,176 @@ $(function() {
TimeoutException Class Reference
-
-Inheritance diagram for TimeoutException:
-
+ +

#include <timeoutexception.h>

+
+ + Inheritance diagram for TimeoutException:
+
+
+ - - - - - + + + + + + +

Public Member Functions

TimeoutException (const char *message, int timeout)
 
TimeoutException (const std::string &message, int timeout)
 
-virtual const char * what () const throw ()
 TimeoutException (const char *message)
 
 TimeoutException (const std::string &message)
 
virtual ~TimeoutException ()=default
 
virtual const char * what () const throw ()
 
+std::string  + - -

Protected Attributes

-std::string msg
msg
 failure description
 
-int m_timeout
 

Detailed Description

-
-

Definition at line 8 of file timeoutexception.h.

-

The documentation for this class was generated from the following file:
    +

    Exception for USART related timeouts.

    + +

    Definition at line 9 of file timeoutexception.h.

    +

    Constructor & Destructor Documentation

    + +

    ◆ TimeoutException() [1/2]

    + +
    +
    + + + + + +
    + + + + + + + + +
    TimeoutException::TimeoutException (const char * message)
    +
    +inlineexplicit
    +
    +

    Constructor

    Parameters
    + + +
    messageas c-string
    +
    +
    + +

    Definition at line 16 of file timeoutexception.h.

    + +
    +
    + +

    ◆ TimeoutException() [2/2]

    + +
    +
    + + + + + +
    + + + + + + + + +
    TimeoutException::TimeoutException (const std::string & message)
    +
    +inlineexplicit
    +
    +

    Constructor

    Parameters
    + + +
    messageas c++-string
    +
    +
    + +

    Definition at line 24 of file timeoutexception.h.

    + +
    +
    + +

    ◆ ~TimeoutException()

    + +
    +
    + + + + + +
    + + + + + + + +
    virtual TimeoutException::~TimeoutException ()
    +
    +virtualdefault
    +
    +

    Standard-destructor

    + +
    +
    +

    Member Function Documentation

    + +

    ◆ what()

    + +
    +
    + + + + + +
    + + + + + + + + + + + + + +
    virtual const char* TimeoutException::what () const
    throw (
    )
    +
    +inlinevirtual
    +
    +

    Get failure description

    Returns
    error message as c-string
    + +

    Definition at line 37 of file timeoutexception.h.

    + +
    +
    +
    The documentation for this class was generated from the following file:
diff --git a/docs/html/classUSART-members.html b/docs/html/classUSART-members.html index b80ed02..56759ff 100644 --- a/docs/html/classUSART-members.html +++ b/docs/html/classUSART-members.html @@ -69,31 +69,24 @@ $(function() {

This is the complete list of members for USART, including all inherited members.

- - - - - - - - - + + + + + + + - - - - - + - - - - + + +
BLOCK_END (defined in USART)USARTstatic
clearInputBuffer(void)USART
clearOutputBuffer(void)USART
closeDevice(void)USART
CRC7_POLY (defined in USART)USARTstatic
flushOutputBuffer(void)USART
getBaudrate(void)USART
getTimeout(void)USART
MAX_BLOCK_SIZE (defined in USART)USARTstatic
clearInputBuffer(void)USART
clearOutputBuffer(void)USART
closeDevice(void)USART
drop(uint8_t len)USART
flushOutputBuffer(void)USART
getBaudrate(void)USART
getTimeout(void)USART
openDevice(std::string device)USART
printStatistics(void)USART
read_timeout(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout) (defined in USART)USART
readBlock(uint8_t *buffer, uint16_t offset) (defined in USART)USART
readByte(void)USART
readInt(void)USART
receive(uint8_t *buffer, uint16_t offset, uint8_t len)USART
setBaudrate(uint32_t baudrate)USART
setTimeout(uint8_t timeout)USART
write_timeout(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout) (defined in USART)USART
writeBlock(uint8_t *buffer, uint16_t offset, uint8_t len) (defined in USART)USART
writeByte(uint8_t b)USART
writeInt(uint16_t d)USART
transmit(uint8_t *buffer, uint16_t offset, uint8_t len)USART
USART()=defaultUSARTexplicit
~USART(void)USARTvirtual
diff --git a/docs/html/classUSART.html b/docs/html/classUSART.html index 965f784..556dd16 100644 --- a/docs/html/classUSART.html +++ b/docs/html/classUSART.html @@ -64,15 +64,20 @@ $(function() {
+ +

#include <usart.h>

+ + + + @@ -83,28 +88,12 @@ Public Member Functions - - - - - - - - - - - - - - - - - - + + + + + + @@ -113,23 +102,68 @@ bool  -

Public Member Functions

 USART ()=default
 
virtual ~USART (void)
 
void openDevice (std::string device)
 
void closeDevice (void)
 
void flushOutputBuffer (void)
 
void printStatistics (void)
 
void writeByte (uint8_t b)
 
void writeInt (uint16_t d)
 
uint8_t readByte (void)
 
uint16_t readInt (void)
 
-int read_timeout (uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout)
 
-int write_timeout (uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout)
 
-void writeBlock (uint8_t *buffer, uint16_t offset, uint8_t len)
 
-bool readBlock (uint8_t *buffer, uint16_t offset)
 
void transmit (uint8_t *buffer, uint16_t offset, uint8_t len)
 
void receive (uint8_t *buffer, uint16_t offset, uint8_t len)
 
void drop (uint8_t len)
 
uint32_t getBaudrate (void)
 
uint8_t getTimeout (void)
readBlock (uint8_
 
void setTimeout (uint8_t timeout)
 
- - - - - - -

-Static Public Attributes

-constexpr static uint8_t CRC7_POLY = 0x91
 
-constexpr static uint8_t MAX_BLOCK_SIZE = 64
 
-constexpr static uint8_t BLOCK_END = 0x80
 

Detailed Description

-
+

C++ Wrapper class for termios usart library.

+

Definition at line 16 of file usart.h.

-

Member Function Documentation

+

Constructor & Destructor Documentation

+ +

◆ USART()

+ +
+
+ + + + + +
+ + + + + + + +
USART::USART ()
+
+explicitdefault
+
+

Standard-Konstruktor

+ +
+
+ +

◆ ~USART()

+ +
+
+ + + + + +
+ + + + + + + + +
USART::~USART (void )
+
+virtual
+
+

Destructor, ruft automatisch closeDevice() auf

+ +

Definition at line 4 of file usart.cpp.

+ +
+
+

Member Function Documentation

◆ clearInputBuffer()

@@ -152,7 +186,7 @@ constexpr static uint8_t B -

Definition at line 39 of file usart.cpp.

+

Definition at line 54 of file usart.cpp.

@@ -178,7 +212,7 @@ constexpr static uint8_t B -

Definition at line 46 of file usart.cpp.

+

Definition at line 61 of file usart.cpp.

@@ -204,7 +238,39 @@ constexpr static uint8_t B -

Definition at line 32 of file usart.cpp.

+

Definition at line 43 of file usart.cpp.

+ + + + +

◆ drop()

+ +
+
+ + + + + + + + +
void USART::drop (uint8_t len)
+
+

Receives n bytes but discards them

Parameters
+ + +
lencount of bytes to receive
+
+
+
Exceptions
+ + +
USARTException
+
+
+ +

Definition at line 114 of file usart.cpp.

@@ -230,7 +296,7 @@ constexpr static uint8_t B -

Definition at line 53 of file usart.cpp.

+

Definition at line 68 of file usart.cpp.

@@ -251,7 +317,7 @@ constexpr static uint8_t B

Liefert die eingestellte Baudrate Änderungen werden erst nach einem open() wirksam

-

Definition at line 306 of file usart.cpp.

+

Definition at line 121 of file usart.cpp.

@@ -272,7 +338,7 @@ constexpr static uint8_t B

Liefert den eingestellten Timeout (in Dezisekunden) Änderungen werden erst nach einem open() wirksam

-

Definition at line 311 of file usart.cpp.

+

Definition at line 126 of file usart.cpp.

@@ -304,80 +370,57 @@ constexpr static uint8_t B -

Definition at line 3 of file usart.cpp.

+

Definition at line 9 of file usart.cpp.

- -

◆ printStatistics()

+ +

◆ receive()

- + - - - + + -
void USART::printStatistics void USART::receive (void )uint8_t * buffer,
-
-

Gibt Anzahl an erfolgreichen und fehlgeschlagenen Block-Übertragungen an

- -

Definition at line 60 of file usart.cpp.

- -
-
- -

◆ readByte()

- -
-
- - - - - + + + + + + + + + + + + + +
uint8_t USART::readByte (void ) uint16_t offset,
uint8_t len 
)
-

Empfängt ein Byte über die USART Schnittstelle

Exceptions
+

Receives n bytes from USART and writes them into the buffer

Parameters
+ + + + +
buffertarget buffer
offsetin buffer (mostly 0)
lencount of bytes to receive
+
+
+
Exceptions
USARTException
-

Definition at line 210 of file usart.cpp.

- -
-
- -

◆ readInt()

- -
-
- - - - - - - - -
uint16_t USART::readInt (void )
-
-

Empfängt ein Integer über die USART Schnittstelle

Exceptions
- - -
USARTException
-
-
- -

Definition at line 229 of file usart.cpp.

+

Definition at line 84 of file usart.cpp.

@@ -396,9 +439,9 @@ constexpr static uint8_t B
-

Setzt die Baudrate Änderungen werden erst nach einem open() wirksam

+

Setzt die Baudrate Änderungen werden erst nach openDevice() wirksam

-

Definition at line 316 of file usart.cpp.

+

Definition at line 131 of file usart.cpp.

@@ -417,62 +460,48 @@ constexpr static uint8_t B
-

Setzt den Timeout (in Dezisekunden) Änderungen werden erst nach einem open() wirksam

+

Setzt den Timeout (in Dezisekunden) Änderungen werden erst nach openDevice() wirksam

-

Definition at line 321 of file usart.cpp.

+

Definition at line 136 of file usart.cpp.

- -

◆ writeByte()

+ +

◆ transmit()

- + - - - + + -
void USART::writeByte void USART::transmit (uint8_t b)uint8_t * buffer,
-
-

Sendet ein Byte über die USART Schnittstelle

Parameters
- - -
bdas zu sendende Byte
-
-
-
Exceptions
- - -
USARTException
-
-
- -

Definition at line 67 of file usart.cpp.

- -
-
- -

◆ writeInt()

- -
-
- - - + + - + + + + + + + + + + +
void USART::writeInt ( uint16_t d)offset,
uint8_t len 
)
-

Sendet ein Integer über die USART Schnittstelle

Parameters
+

Sends n bytes from the buffer over USART

Parameters
- + + +
bdas zu sendende Byte
buffertarget buffer
offsetin buffer (mostly 0)
lencount of bytes to send
@@ -483,7 +512,7 @@ constexpr static uint8_t B
-

Definition at line 81 of file usart.cpp.

+

Definition at line 75 of file usart.cpp.

@@ -494,7 +523,7 @@ constexpr static uint8_t B diff --git a/docs/html/classUSARTException-members.html b/docs/html/classUSARTException-members.html index 2ec12b3..b634feb 100644 --- a/docs/html/classUSARTException-members.html +++ b/docs/html/classUSARTException-members.html @@ -69,15 +69,15 @@ $(function() {

This is the complete list of members for USARTException, including all inherited members.

- - - - - + + + + +
msg (defined in USARTException)USARTExceptionprotected
USARTException(const char *message) (defined in USARTException)USARTExceptioninlineexplicit
USARTException(const std::string &message) (defined in USARTException)USARTExceptioninlineexplicit
what() const (defined in USARTException)USARTExceptioninlinevirtual
~USARTException() (defined in USARTException)USARTExceptioninlinevirtual
msgUSARTExceptionprotected
USARTException(const char *message)USARTExceptioninlineexplicit
USARTException(const std::string &message)USARTExceptioninlineexplicit
what() constUSARTExceptioninlinevirtual
~USARTException()=defaultUSARTExceptionvirtual
diff --git a/docs/html/classUSARTException.html b/docs/html/classUSARTException.html index 956a359..83a3239 100644 --- a/docs/html/classUSARTException.html +++ b/docs/html/classUSARTException.html @@ -70,41 +70,176 @@ $(function() {
USARTException Class Reference
-
-Inheritance diagram for USARTException:
-
+ +

#include <usartexception.h>

+
+ + Inheritance diagram for USARTException:
+
+
+ - + - + - + + +

Public Member Functions

USARTException (const char *message)
 USARTException (const char *message)
 
USARTException (const std::string &message)
 USARTException (const std::string &message)
 
-virtual const char * what () const throw ()
virtual ~USARTException ()=default
 
virtual const char * what () const throw ()
 
+std::string  +

Protected Attributes

-std::string msg
msg
 failure description
 

Detailed Description

-
+

Exception for USART problems, for instance buffer overflow.

+

Definition at line 9 of file usartexception.h.

-

The documentation for this class was generated from the following file:
    +

Constructor & Destructor Documentation

+ +

◆ USARTException() [1/2]

+ +
+
+ + + + + +
+ + + + + + + + +
USARTException::USARTException (const char * message)
+
+inlineexplicit
+
+

Constructor

Parameters
+ + +
messageas c-string
+
+
+ +

Definition at line 16 of file usartexception.h.

+ +
+
+ +

◆ USARTException() [2/2]

+ +
+
+ + + + + +
+ + + + + + + + +
USARTException::USARTException (const std::string & message)
+
+inlineexplicit
+
+

Constructor

Parameters
+ + +
messageas c++-string
+
+
+ +

Definition at line 24 of file usartexception.h.

+ +
+
+ +

◆ ~USARTException()

+ +
+
+ + + + + +
+ + + + + + + +
virtual USARTException::~USARTException ()
+
+virtualdefault
+
+

Standard-destructor

+ +
+
+

Member Function Documentation

+ +

◆ what()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + +
virtual const char* USARTException::what () const
throw (
)
+
+inlinevirtual
+
+

Get failure description

Returns
error message as c-string
+ +

Definition at line 37 of file usartexception.h.

+ +
+
+
The documentation for this class was generated from the following file:
diff --git a/docs/html/classView-members.html b/docs/html/classView-members.html index 2ce3664..d7b06ee 100644 --- a/docs/html/classView-members.html +++ b/docs/html/classView-members.html @@ -89,7 +89,7 @@ $(function() {
diff --git a/docs/html/classView.html b/docs/html/classView.html index cdc2f42..38d7d02 100644 --- a/docs/html/classView.html +++ b/docs/html/classView.html @@ -72,9 +72,13 @@ $(function() {
View Class Referenceabstract
-
-Inheritance diagram for View:
-
+ +

#include <view.h>

+
+ + Inheritance diagram for View:
+
+
+
-
-Inheritance diagram for ViewInfo:
-
+ +

#include <view_info.h>

+
+ + Inheritance diagram for ViewInfo:
+
+
+
-
-Inheritance diagram for ViewMonitor:
-
+ +

#include <view_monitor.h>

+
+ + Inheritance diagram for ViewMonitor:
+
+
+
-
-Inheritance diagram for ViewPromt:
-
+ +

#include <view_promt.h>

+
+ + Inheritance diagram for ViewPromt:
+
+
+
-
-Inheritance diagram for ViewSelection:
-
+ +

#include <view_selection.h>

+
+ + Inheritance diagram for ViewSelection:
+
+
+
-
1 #define B15F_CLI_DEBUG
2 
3 #include <stdio.h>
4 #include <ncurses.h> // sudo apt-get install libncurses5-dev
5 #include <vector>
6 #include <string>
7 #include <iostream>
8 #include <signal.h>
9 #include <sys/ioctl.h>
10 #include <unistd.h>
11 #include <signal.h>
12 #include <future>
13 #include <thread>
14 #include <chrono>
15 #include "drv/b15f.h"
16 #include "ui/ui.h"
17 #include "ui/view_selection.h"
18 #include "ui/view_info.h"
19 #include "ui/view_monitor.h"
20 #include "ui/view_promt.h"
21 
22 volatile int win_changed_cooldown = 0;
23 volatile bool t_refresh_active = false;
24 
25 void signal_handler(int signal)
26 {
27  if(signal == SIGWINCH)
28  {
29  win_changed_cooldown = 10; // 100ms
30 
31  if (!t_refresh_active)
32  {
33  if(t_refresh.joinable())
34  t_refresh.join();
35  t_refresh_active = true;
36  t_refresh = std::thread([](){
37 
38  while(win_changed_cooldown--)
39  std::this_thread::sleep_for(std::chrono::milliseconds(10));
40 
41  t_refresh_active = false;
42 
43  if(win_stack.size())
44  win_stack.back()->repaint();
45 
46  });
47  }
48 
49  }
50  else if(signal == SIGINT)
51  {
52  cleanup();
53  std::cout << "SIGINT - Abbruch." << std::endl;
54  exit(EXIT_FAILURE);
55  }
56 }
57 
58 void abort_handler(std::exception& ex)
59 {
60  ViewInfo* view = new ViewInfo();
61  view->setTitle("Fehler");
62  std::string msg(ex.what());
63  msg += "\n\nBeende in 5 Sekunden.";
64  view->setText(msg.c_str());
65  view->setLabelClose("");
66  view->repaint();
67 
68  std::this_thread::sleep_for(std::chrono::milliseconds(5000));
69 
70  cleanup();
71  std::cerr << std::endl << "*** EXCEPTION ***" << std::endl << ex.what() << std::endl;
72  exit(EXIT_FAILURE);
73 }
74 
75 void init()
76 {
77  // init b15 driver
79 #ifndef B15F_CLI_DEBUG
80  std::cout << std::endl << "Starte in 3s ..." << std::endl;
81  sleep(3);
82 #endif
83  B15F::setAbortHandler(&abort_handler);
84 
85  // init all ncurses stuff
86  initscr();
87  start_color();
88  curs_set(0); // 0: invisible, 1: normal, 2: very visible
89  clear();
90  noecho();
91  cbreak(); // Line buffering disabled. pass on everything
92  mousemask(ALL_MOUSE_EVENTS, NULL);
93 
94  // connect signals to handler
95  signal(SIGWINCH, signal_handler);
96  signal(SIGINT, signal_handler);
97 
98  // set view context
99  View::setWinContext(newwin(25, 85, 0, 0));
100 }
101 
102 
103 int main()
104 {
105  init();
106 
107  int exit_code = EXIT_SUCCESS;
108 
109  show_main(0);
110 
111  cleanup();
112 
113  return exit_code;
114 }
- -
static B15F & getInstance(void)
Definition: b15f.cpp:300
-
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:339
+
1 //#define B15F_CLI_DEBUG
2 
3 #include <stdio.h>
4 #include <ncurses.h> // sudo apt-get install libncurses5-dev
5 #include <vector>
6 #include <string>
7 #include <iostream>
8 #include <signal.h>
9 #include <sys/ioctl.h>
10 #include <unistd.h>
11 #include <signal.h>
12 #include <future>
13 #include <thread>
14 #include <chrono>
15 #include "drv/b15f.h"
16 #include "ui/ui.h"
17 #include "ui/view_selection.h"
18 #include "ui/view_info.h"
19 #include "ui/view_monitor.h"
20 #include "ui/view_promt.h"
21 
22 volatile int win_changed_cooldown = 0;
23 volatile bool t_refresh_active = false;
24 
25 void signal_handler(int signal)
26 {
27  if(signal == SIGWINCH)
28  {
29  win_changed_cooldown = 10; // 100ms
30 
31  if (!t_refresh_active)
32  {
33  if(t_refresh.joinable())
34  t_refresh.join();
35  t_refresh_active = true;
36  t_refresh = std::thread([]()
37  {
38 
39  while(win_changed_cooldown--)
40  std::this_thread::sleep_for(std::chrono::milliseconds(10));
41 
42  t_refresh_active = false;
43 
44  if(win_stack.size())
45  win_stack.back()->repaint();
46 
47  });
48  }
49 
50  }
51  else if(signal == SIGINT)
52  {
53  cleanup();
54  std::cout << "SIGINT - Abbruch." << std::endl;
55  exit(EXIT_FAILURE);
56  }
57 }
58 
59 void abort_handler(std::exception& ex)
60 {
61  ViewInfo* view = new ViewInfo();
62  view->setTitle("Fehler");
63  std::string msg(ex.what());
64  msg += "\n\nBeende in 5 Sekunden.";
65  view->setText(msg.c_str());
66  view->setLabelClose("");
67  view->repaint();
68 
69  std::this_thread::sleep_for(std::chrono::milliseconds(5000));
70 
71  cleanup();
72  std::cerr << std::endl << "*** EXCEPTION ***" << std::endl << ex.what() << std::endl;
73  exit(EXIT_FAILURE);
74 }
75 
76 void init()
77 {
78  // init b15 driver
80 #ifndef B15F_CLI_DEBUG
81  std::cout << std::endl << "Starte in 3s ..." << std::endl;
82  sleep(3);
83 #endif
84  B15F::setAbortHandler(&abort_handler);
85 
86  // init all ncurses stuff
87  initscr();
88  start_color();
89  curs_set(0); // 0: invisible, 1: normal, 2: very visible
90  clear();
91  noecho();
92  cbreak(); // Line buffering disabled. pass on everything
93  mousemask(ALL_MOUSE_EVENTS, NULL);
94 
95  // connect signals to handler
96  signal(SIGWINCH, signal_handler);
97  signal(SIGINT, signal_handler);
98 
99  // set view context
100  View::setWinContext(newwin(25, 85, 0, 0));
101 }
102 
103 
104 int main()
105 {
106  init();
107 
108  int exit_code = EXIT_SUCCESS;
109 
110  show_main(0);
111 
112  cleanup();
113 
114  return exit_code;
115 }
+ +
static B15F & getInstance(void)
Definition: b15f.cpp:442
+
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:485
diff --git a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html index f35095c..df74479 100644 --- a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html +++ b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html @@ -73,7 +73,7 @@ $(function() {
diff --git a/docs/html/dir_19f2f1b99f19c12fa55b8d312cf373ed.html b/docs/html/dir_19f2f1b99f19c12fa55b8d312cf373ed.html new file mode 100644 index 0000000..09e2ed5 --- /dev/null +++ b/docs/html/dir_19f2f1b99f19c12fa55b8d312cf373ed.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/3.14.3/CompilerIdC Directory Reference + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
CompilerIdC Directory Reference
+
+
+
+ + + + diff --git a/docs/html/dir_3d3c8ff3ebf9841b39117ac899f41936.html b/docs/html/dir_3d3c8ff3ebf9841b39117ac899f41936.html new file mode 100644 index 0000000..f2f6a5f --- /dev/null +++ b/docs/html/dir_3d3c8ff3ebf9841b39117ac899f41936.html @@ -0,0 +1,85 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/3.14.3 Directory Reference + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
3.14.3 Directory Reference
+
+
+ + +

+Directories

+
+ + + + diff --git a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html index 10f6872..d4aae6d 100644 --- a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html +++ b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html @@ -73,7 +73,7 @@ $(function() {
diff --git a/docs/html/dir_90e361ec3542f3dd076ea3ad19547437.html b/docs/html/dir_90e361ec3542f3dd076ea3ad19547437.html new file mode 100644 index 0000000..9bfc892 --- /dev/null +++ b/docs/html/dir_90e361ec3542f3dd076ea3ad19547437.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/3.14.3/CompilerIdCXX Directory Reference + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
CompilerIdCXX Directory Reference
+
+
+
+ + + + diff --git a/docs/html/dir_95e29a8b8ee7c54052c171a88bb95675.html b/docs/html/dir_95e29a8b8ee7c54052c171a88bb95675.html new file mode 100644 index 0000000..a5b199f --- /dev/null +++ b/docs/html/dir_95e29a8b8ee7c54052c171a88bb95675.html @@ -0,0 +1,85 @@ + + + + + + + +B15F: cmake-build-debug Directory Reference + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
cmake-build-debug Directory Reference
+
+
+ + +

+Directories

+
+ + + + diff --git a/docs/html/dir_f89abcb304c928c7d889aa5625570de5.html b/docs/html/dir_f89abcb304c928c7d889aa5625570de5.html new file mode 100644 index 0000000..a690f2b --- /dev/null +++ b/docs/html/dir_f89abcb304c928c7d889aa5625570de5.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles Directory Reference + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
CMakeFiles Directory Reference
+
+
+
+ + + + diff --git a/docs/html/dot_8cpp_source.html b/docs/html/dot_8cpp_source.html index b5442fc..acf3fde 100644 --- a/docs/html/dot_8cpp_source.html +++ b/docs/html/dot_8cpp_source.html @@ -70,10 +70,14 @@ $(function() {
dot.cpp
-
1 #include "dot.h"
2 
3 Dot::Dot(uint16_t x, uint16_t y, uint8_t curve) : x(x), y(y), curve(curve)
4 {
5  if(curve >= 64)
6  throw std::range_error("Kurvenindex muss im Bereich [0, 63] liegen");
7 }
8 
9 uint16_t Dot::getX() const
10 {
11  return x;
12 }
13 
14 uint16_t Dot::getY() const
15 {
16  return y;
17 }
18 
19 uint8_t Dot::getCurve(void) const
20 {
21  return curve;
22 }
+
1 #include "dot.h"
2 
3 Dot::Dot(uint16_t x, uint16_t y, uint8_t curve) : x(x), y(y), curve(curve)
4 {
5  if(curve >= 64)
6  throw std::range_error("Kurvenindex muss im Bereich [0, 63] liegen");
7 }
8 
9 uint16_t Dot::getX() const
10 {
11  return x;
12 }
13 
14 uint16_t Dot::getY() const
15 {
16  return y;
17 }
18 
19 uint8_t Dot::getCurve(void) const
20 {
21  return curve;
22 }
+
uint16_t getX(void) const
Definition: dot.cpp:9
+
uint16_t getY(void) const
Definition: dot.cpp:14
+
uint8_t getCurve(void) const
Definition: dot.cpp:19
+
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/dot_8h_source.html b/docs/html/dot_8h_source.html index 695f88e..51b1e8c 100644 --- a/docs/html/dot_8h_source.html +++ b/docs/html/dot_8h_source.html @@ -70,11 +70,15 @@ $(function() {
dot.h
-
1 #ifndef DOT_H
2 #define DOT_H
3 
4 #include <cstdint>
5 #include <stdexcept>
6 
7 class Dot
8 {
9 public:
10  Dot(uint16_t x, uint16_t y, uint8_t curve);
11  uint16_t getX(void) const;
12  uint16_t getY(void) const;
13  uint8_t getCurve(void) const;
14 
15 private:
16  uint16_t x, y;
17  uint8_t curve;
18 };
19 
20 
21 #endif // DOT_H
-
Definition: dot.h:7
+
1 #ifndef DOT_H
2 #define DOT_H
3 
4 #include <cstdint>
5 #include <stdexcept>
6 
12 class Dot
13 {
14 public:
18  Dot(uint16_t x, uint16_t y, uint8_t curve);
19 
23  uint16_t getX(void) const;
24 
28  uint16_t getY(void) const;
29 
33  uint8_t getCurve(void) const;
34 
35 private:
36  uint16_t x, y;
37  uint8_t curve;
38 };
39 
40 
41 #endif // DOT_H
+
uint16_t getX(void) const
Definition: dot.cpp:9
+
Definition: dot.h:12
+
uint16_t getY(void) const
Definition: dot.cpp:14
+
uint8_t getCurve(void) const
Definition: dot.cpp:19
+
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/driverexception_8h_source.html b/docs/html/driverexception_8h_source.html index a9c7385..ee33149 100644 --- a/docs/html/driverexception_8h_source.html +++ b/docs/html/driverexception_8h_source.html @@ -70,11 +70,11 @@ $(function() {
driverexception.h
-
1 #ifndef DRIVEREXCEPTION_H
2 #define DRIVEREXCEPTION_H
3 
4 #include <exception>
5 
6 // SOURCE: https://stackoverflow.com/a/8152888
7 
8 class DriverException: public std::exception
9 {
10 public:
11  explicit DriverException(const char* message) : msg_(message)
12  {
13  }
14 
15  explicit DriverException(const std::string& message) : msg_(message)
16  {
17  }
18 
19  virtual ~DriverException() throw ()
20  {
21  }
22 
23  virtual const char* what() const throw ()
24  {
25  return msg_.c_str();
26  }
27 
28 protected:
29  std::string msg_;
30 };
31 
32 #endif // DRIVEREXCEPTION_H
33 
- +
1 #ifndef DRIVEREXCEPTION_H
2 #define DRIVEREXCEPTION_H
3 
4 #include <exception>
5 
6 // SOURCE: https://stackoverflow.com/a/8152888
7 
10 class DriverException: public std::exception
11 {
12 public:
13  explicit DriverException(const char* message) : msg_(message)
14  {
15  }
16 
17  explicit DriverException(const std::string& message) : msg_(message)
18  {
19  }
20 
21  virtual ~DriverException() throw ()
22  {
23  }
24 
25  virtual const char* what() const throw ()
26  {
27  return msg_.c_str();
28  }
29 
30 protected:
31  std::string msg_;
32 };
33 
34 #endif // DRIVEREXCEPTION_H
35 
+ diff --git a/docs/html/feature__tests_8c_source.html b/docs/html/feature__tests_8c_source.html new file mode 100644 index 0000000..680cfb0 --- /dev/null +++ b/docs/html/feature__tests_8c_source.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/feature_tests.c Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
feature_tests.c
+
+
+
1 
2 const char features[] = {"\n"
3  "C_FEATURE:"
4 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 304
5  "1"
6 #else
7  "0"
8 #endif
9  "c_function_prototypes\n"
10  "C_FEATURE:"
11 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 304 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
12  "1"
13 #else
14  "0"
15 #endif
16  "c_restrict\n"
17  "C_FEATURE:"
18 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L
19  "1"
20 #else
21  "0"
22 #endif
23  "c_static_assert\n"
24  "C_FEATURE:"
25 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 304 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
26  "1"
27 #else
28  "0"
29 #endif
30  "c_variadic_macros\n"
31 
32  };
33 
34 int main(int argc, char** argv)
35 {
36  (void)argv;
37  return features[argc];
38 }
+ + + + diff --git a/docs/html/feature__tests_8cxx_source.html b/docs/html/feature__tests_8cxx_source.html new file mode 100644 index 0000000..aba4067 --- /dev/null +++ b/docs/html/feature__tests_8cxx_source.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: cmake-build-debug/CMakeFiles/feature_tests.cxx Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
feature_tests.cxx
+
+
+
1 
2  const char features[] = {"\n"
3 "CXX_FEATURE:"
4 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L
5 "1"
6 #else
7 "0"
8 #endif
9 "cxx_aggregate_default_initializers\n"
10 "CXX_FEATURE:"
11 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
12 "1"
13 #else
14 "0"
15 #endif
16 "cxx_alias_templates\n"
17 "CXX_FEATURE:"
18 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
19 "1"
20 #else
21 "0"
22 #endif
23 "cxx_alignas\n"
24 "CXX_FEATURE:"
25 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
26 "1"
27 #else
28 "0"
29 #endif
30 "cxx_alignof\n"
31 "CXX_FEATURE:"
32 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
33 "1"
34 #else
35 "0"
36 #endif
37 "cxx_attributes\n"
38 "CXX_FEATURE:"
39 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
40 "1"
41 #else
42 "0"
43 #endif
44 "cxx_attribute_deprecated\n"
45 "CXX_FEATURE:"
46 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
47 "1"
48 #else
49 "0"
50 #endif
51 "cxx_auto_type\n"
52 "CXX_FEATURE:"
53 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
54 "1"
55 #else
56 "0"
57 #endif
58 "cxx_binary_literals\n"
59 "CXX_FEATURE:"
60 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
61 "1"
62 #else
63 "0"
64 #endif
65 "cxx_constexpr\n"
66 "CXX_FEATURE:"
67 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
68 "1"
69 #else
70 "0"
71 #endif
72 "cxx_contextual_conversions\n"
73 "CXX_FEATURE:"
74 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
75 "1"
76 #else
77 "0"
78 #endif
79 "cxx_decltype\n"
80 "CXX_FEATURE:"
81 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
82 "1"
83 #else
84 "0"
85 #endif
86 "cxx_decltype_auto\n"
87 "CXX_FEATURE:"
88 #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L
89 "1"
90 #else
91 "0"
92 #endif
93 "cxx_decltype_incomplete_return_types\n"
94 "CXX_FEATURE:"
95 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
96 "1"
97 #else
98 "0"
99 #endif
100 "cxx_default_function_template_args\n"
101 "CXX_FEATURE:"
102 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
103 "1"
104 #else
105 "0"
106 #endif
107 "cxx_defaulted_functions\n"
108 "CXX_FEATURE:"
109 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
110 "1"
111 #else
112 "0"
113 #endif
114 "cxx_defaulted_move_initializers\n"
115 "CXX_FEATURE:"
116 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
117 "1"
118 #else
119 "0"
120 #endif
121 "cxx_delegating_constructors\n"
122 "CXX_FEATURE:"
123 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
124 "1"
125 #else
126 "0"
127 #endif
128 "cxx_deleted_functions\n"
129 "CXX_FEATURE:"
130 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
131 "1"
132 #else
133 "0"
134 #endif
135 "cxx_digit_separators\n"
136 "CXX_FEATURE:"
137 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
138 "1"
139 #else
140 "0"
141 #endif
142 "cxx_enum_forward_declarations\n"
143 "CXX_FEATURE:"
144 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
145 "1"
146 #else
147 "0"
148 #endif
149 "cxx_explicit_conversions\n"
150 "CXX_FEATURE:"
151 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
152 "1"
153 #else
154 "0"
155 #endif
156 "cxx_extended_friend_declarations\n"
157 "CXX_FEATURE:"
158 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
159 "1"
160 #else
161 "0"
162 #endif
163 "cxx_extern_templates\n"
164 "CXX_FEATURE:"
165 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
166 "1"
167 #else
168 "0"
169 #endif
170 "cxx_final\n"
171 "CXX_FEATURE:"
172 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
173 "1"
174 #else
175 "0"
176 #endif
177 "cxx_func_identifier\n"
178 "CXX_FEATURE:"
179 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
180 "1"
181 #else
182 "0"
183 #endif
184 "cxx_generalized_initializers\n"
185 "CXX_FEATURE:"
186 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
187 "1"
188 #else
189 "0"
190 #endif
191 "cxx_generic_lambdas\n"
192 "CXX_FEATURE:"
193 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
194 "1"
195 #else
196 "0"
197 #endif
198 "cxx_inheriting_constructors\n"
199 "CXX_FEATURE:"
200 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
201 "1"
202 #else
203 "0"
204 #endif
205 "cxx_inline_namespaces\n"
206 "CXX_FEATURE:"
207 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
208 "1"
209 #else
210 "0"
211 #endif
212 "cxx_lambdas\n"
213 "CXX_FEATURE:"
214 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
215 "1"
216 #else
217 "0"
218 #endif
219 "cxx_lambda_init_captures\n"
220 "CXX_FEATURE:"
221 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
222 "1"
223 #else
224 "0"
225 #endif
226 "cxx_local_type_template_args\n"
227 "CXX_FEATURE:"
228 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
229 "1"
230 #else
231 "0"
232 #endif
233 "cxx_long_long_type\n"
234 "CXX_FEATURE:"
235 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
236 "1"
237 #else
238 "0"
239 #endif
240 "cxx_noexcept\n"
241 "CXX_FEATURE:"
242 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
243 "1"
244 #else
245 "0"
246 #endif
247 "cxx_nonstatic_member_init\n"
248 "CXX_FEATURE:"
249 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
250 "1"
251 #else
252 "0"
253 #endif
254 "cxx_nullptr\n"
255 "CXX_FEATURE:"
256 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
257 "1"
258 #else
259 "0"
260 #endif
261 "cxx_override\n"
262 "CXX_FEATURE:"
263 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
264 "1"
265 #else
266 "0"
267 #endif
268 "cxx_range_for\n"
269 "CXX_FEATURE:"
270 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
271 "1"
272 #else
273 "0"
274 #endif
275 "cxx_raw_string_literals\n"
276 "CXX_FEATURE:"
277 #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L
278 "1"
279 #else
280 "0"
281 #endif
282 "cxx_reference_qualified_functions\n"
283 "CXX_FEATURE:"
284 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L
285 "1"
286 #else
287 "0"
288 #endif
289 "cxx_relaxed_constexpr\n"
290 "CXX_FEATURE:"
291 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
292 "1"
293 #else
294 "0"
295 #endif
296 "cxx_return_type_deduction\n"
297 "CXX_FEATURE:"
298 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
299 "1"
300 #else
301 "0"
302 #endif
303 "cxx_right_angle_brackets\n"
304 "CXX_FEATURE:"
305 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
306 "1"
307 #else
308 "0"
309 #endif
310 "cxx_rvalue_references\n"
311 "CXX_FEATURE:"
312 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
313 "1"
314 #else
315 "0"
316 #endif
317 "cxx_sizeof_member\n"
318 "CXX_FEATURE:"
319 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
320 "1"
321 #else
322 "0"
323 #endif
324 "cxx_static_assert\n"
325 "CXX_FEATURE:"
326 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
327 "1"
328 #else
329 "0"
330 #endif
331 "cxx_strong_enums\n"
332 "CXX_FEATURE:"
333 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && __cplusplus
334 "1"
335 #else
336 "0"
337 #endif
338 "cxx_template_template_parameters\n"
339 "CXX_FEATURE:"
340 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
341 "1"
342 #else
343 "0"
344 #endif
345 "cxx_thread_local\n"
346 "CXX_FEATURE:"
347 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
348 "1"
349 #else
350 "0"
351 #endif
352 "cxx_trailing_return_types\n"
353 "CXX_FEATURE:"
354 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
355 "1"
356 #else
357 "0"
358 #endif
359 "cxx_unicode_literals\n"
360 "CXX_FEATURE:"
361 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
362 "1"
363 #else
364 "0"
365 #endif
366 "cxx_uniform_initialization\n"
367 "CXX_FEATURE:"
368 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
369 "1"
370 #else
371 "0"
372 #endif
373 "cxx_unrestricted_unions\n"
374 "CXX_FEATURE:"
375 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L
376 "1"
377 #else
378 "0"
379 #endif
380 "cxx_user_literals\n"
381 "CXX_FEATURE:"
382 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L
383 "1"
384 #else
385 "0"
386 #endif
387 "cxx_variable_templates\n"
388 "CXX_FEATURE:"
389 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
390 "1"
391 #else
392 "0"
393 #endif
394 "cxx_variadic_macros\n"
395 "CXX_FEATURE:"
396 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))
397 "1"
398 #else
399 "0"
400 #endif
401 "cxx_variadic_templates\n"
402 
403 };
404 
405 int main(int argc, char** argv) { (void)argv; return features[argc]; }
+ + + + diff --git a/docs/html/files.html b/docs/html/files.html index e4b7368..3ad0f6b 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -67,39 +67,49 @@ $(function() {
Here is a list of all documented files with brief descriptions:
-
[detail level 12]
- - - - - - - - - - - - - - - - - - - - - - - - - - +
[detail level 12345]
  drv
 b15f.cpp
 b15f.h
 dot.cpp
 dot.h
 driverexception.h
 plottyfile.cpp
 plottyfile.h
 timeoutexception.h
 usart.cpp
 usart.h
 usartexception.h
  ui
 ui.cpp
 ui.h
 view.cpp
 view.h
 view_info.cpp
 view_info.h
 view_monitor.cpp
 view_monitor.h
 view_promt.cpp
 view_promt.h
 view_selection.cpp
 view_selection.h
 cli.cpp
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  cmake-build-debug
  CMakeFiles
  3.14.3
  CompilerIdC
 CMakeCCompilerId.c
  CompilerIdCXX
 CMakeCXXCompilerId.cpp
 feature_tests.c
 feature_tests.cxx
  drv
 b15f.cpp
 b15f.h
 backup.cpp
 dot.cpp
 dot.h
 driverexception.h
 plottyfile.cpp
 plottyfile.h
 timeoutexception.h
 usart.cpp
 usart.h
 usartexception.h
  ui
 ui.cpp
 ui.h
 view.cpp
 view.h
 view_info.cpp
 view_info.h
 view_monitor.cpp
 view_monitor.h
 view_promt.cpp
 view_promt.h
 view_selection.cpp
 view_selection.h
 cli.cpp
diff --git a/docs/html/functions.html b/docs/html/functions.html index 1c5c177..30bdf0a 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -71,6 +71,9 @@ $(function() {
  • activateSelfTestMode() : B15F
  • +
  • addDot() +: PlottyFile +
  • analogRead() : B15F
  • @@ -78,10 +81,17 @@ $(function() { : B15F
  • analogWrite0() -: B15F +: B15F
  • analogWrite1() -: B15F +: B15F +
  • + + + +

    - b -

    @@ -121,6 +131,12 @@ $(function() {
  • discard() : B15F
  • +
  • Dot() +: Dot +
  • +
  • drop() +: USART +
  • @@ -145,12 +161,74 @@ $(function() {
  • getBoardInfo() : B15F
  • +
  • getCurve() +: Dot +
  • +
  • getDescPara() +: PlottyFile +
  • +
  • getDescX() +: PlottyFile +
  • +
  • getDescY() +: PlottyFile +
  • +
  • getFunctionType() +: PlottyFile +
  • getInstance() : B15F
  • +
  • getParaFirstCurve() +: PlottyFile +
  • +
  • getParaStepWidth() +: PlottyFile +
  • +
  • getQuadrant() +: PlottyFile +
  • +
  • getRefX() +: PlottyFile +
  • +
  • getRefY() +: PlottyFile +
  • +
  • getRegister() +: B15F +
  • getTimeout() : USART
  • +
  • getUnitPara() +: PlottyFile +
  • +
  • getUnitX() +: PlottyFile +
  • +
  • getUnitY() +: PlottyFile +
  • +
  • getX() +: Dot +
  • +
  • getY() +: Dot +
  • + + + +

    - m -

    @@ -162,25 +240,34 @@ $(function() {

    - p -

      -
    • printStatistics() -: USART +
    • PRE +: B15F +
    • +
    • pwmSetFrequency() +: B15F +
    • +
    • pwmSetValue() +: B15F

    - r -

      -
    • readByte() -: USART -
    • readDipSwitch() : B15F
    • -
    • readInt() -: USART +
    • receive() +: USART
    • reconnect() : B15F
    • +
    • RECONNECT_TIMEOUT +: B15F +
    • +
    • RECONNECT_TRIES +: B15F +
    @@ -191,9 +278,51 @@ $(function() {
  • setBaudrate() : USART
  • +
  • setDescPara() +: PlottyFile +
  • +
  • setDescX() +: PlottyFile +
  • +
  • setDescY() +: PlottyFile +
  • +
  • setFunctionType() +: PlottyFile +
  • +
  • setParaFirstCurve() +: PlottyFile +
  • +
  • setParaStepWidth() +: PlottyFile +
  • +
  • setQuadrant() +: PlottyFile +
  • +
  • setRefX() +: PlottyFile +
  • +
  • setRefY() +: PlottyFile +
  • +
  • setRegister() +: B15F +
  • setTimeout() : USART
  • +
  • setUnitPara() +: PlottyFile +
  • +
  • setUnitX() +: PlottyFile +
  • +
  • setUnitY() +: PlottyFile +
  • +
  • startPlotty() +: PlottyFile +
  • @@ -204,21 +333,54 @@ $(function() {
  • testIntConv() : B15F
  • +
  • TimeoutException() +: TimeoutException +
  • +
  • transmit() +: USART +
  • + + + +

    - u -

    - w -

    + + +

    - ~ -

    diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 0a45dfa..f5b2bf5 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -71,6 +71,9 @@ $(function() {
  • activateSelfTestMode() : B15F
  • +
  • addDot() +: PlottyFile +
  • analogRead() : B15F
  • @@ -78,10 +81,10 @@ $(function() { : B15F
  • analogWrite0() -: B15F +: B15F
  • analogWrite1() -: B15F +: B15F
  • @@ -121,6 +124,12 @@ $(function() {
  • discard() : B15F
  • +
  • Dot() +: Dot +
  • +
  • drop() +: USART +
  • @@ -145,12 +154,60 @@ $(function() {
  • getBoardInfo() : B15F
  • +
  • getCurve() +: Dot +
  • +
  • getDescPara() +: PlottyFile +
  • +
  • getDescX() +: PlottyFile +
  • +
  • getDescY() +: PlottyFile +
  • +
  • getFunctionType() +: PlottyFile +
  • getInstance() : B15F
  • +
  • getParaFirstCurve() +: PlottyFile +
  • +
  • getParaStepWidth() +: PlottyFile +
  • +
  • getQuadrant() +: PlottyFile +
  • +
  • getRefX() +: PlottyFile +
  • +
  • getRefY() +: PlottyFile +
  • +
  • getRegister() +: B15F +
  • getTimeout() : USART
  • +
  • getUnitPara() +: PlottyFile +
  • +
  • getUnitX() +: PlottyFile +
  • +
  • getUnitY() +: PlottyFile +
  • +
  • getX() +: Dot +
  • +
  • getY() +: Dot +
  • @@ -162,21 +219,21 @@ $(function() {

    - p -

      -
    • printStatistics() -: USART +
    • pwmSetFrequency() +: B15F +
    • +
    • pwmSetValue() +: B15F

    - r -

    @@ -204,21 +303,51 @@ $(function() {
  • testIntConv() : B15F
  • +
  • TimeoutException() +: TimeoutException +
  • +
  • transmit() +: USART +
  • + + + +

    - u -

    - w -

    + + +

    - ~ -

    diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html new file mode 100644 index 0000000..ae7d02a --- /dev/null +++ b/docs/html/functions_vars.html @@ -0,0 +1,100 @@ + + + + + + + +B15F: Class Members - Variables + + + + + + + + + +
    +
    + + + + + + +
    +
    B15F +
    +
    Board 15 Famulus Edition
    +
    +
    + + + + + + + +
    + +
    +
    + + +
    + +
    + +
    +
    + + + + diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 5c42834..7eaae9a 100644 --- a/docs/html/hierarchy.html +++ b/docs/html/hierarchy.html @@ -86,7 +86,7 @@ $(function() { diff --git a/docs/html/index.html b/docs/html/index.html index 39eaa17..b291453 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -5,7 +5,7 @@ -B15F: Einführung +B15F: B15F Benutzerhandbuch @@ -63,16 +63,90 @@ $(function() {
    -
    Einführung
    +
    B15F Benutzerhandbuch
    -

    Die wichtigste Klasse für die Steuerung des Board 15 ist B15F.
    -Dort befindet sich auch eine Übersicht der verfügbaren Befehle.

    +

    Hinweis: Terminal-Befehle sind fett gedruckt

    +

    +Installation

    +

    +1. Abhängigkeiten installieren

    +

    (a) sudo apt-get update
    + (b) sudo apt-get install git avr-libc avrdude libncurses5-dev g++
    +

    +

    +2. Das Repository klonen

    +

    (a) cd /home/famulus/
    + (b) git clone "https://github.com/devfix/b15f.git"
    +

    +

    +3. Die Firmware installieren

    +

    (a) cd "/home/famulus/b15f/firmware"
    + (b) Passen Sie in der Datei Makefile die Option "MCU = ..." an die MCU des vorliegenden Boards an
    + (atmega1284 und atmega1284p sind nicht identisch!)
    + (c) make
    + Wenn udev richtig konfiguriert wurde:
    + (d I) make upload
    + Sonst:
    + (d II) sudo make upload
    +

    +

    +4. Die Steuersoftware (Bibliothek & CLI) installieren

    +

    (a) cd "/home/famulus/b15f/control/src"
    + (b) make
    + (Die Warnungen durch doxygen können ignoriert werden.)

    +

    (c) sudo make install
    +

    +

    +Aktualisierung

    +

    (a) cd /home/famulus/b15f/
    + (b) git pull –prune
    + (c) cd "/home/famulus/b15f/firmware"
    + (d) make clean
    + (e) cd "/home/famulus/b15f/control/src"
    + (f) make clean
    + (g) Installation ab Schritt 3 wiederholen

    +

    +Das CommandLineInterface (CLI) benutzen

    +

    (a) Öffnen Sie ein Terminal und maximieren Sie das Fenster
    + (b) Start des CLI erfolgt durch b15fcli
    + (c) Die Navigation erfolgt durch <Tab>, die Pfeiltasten und <Enter> oder die Maus
    + (d) Mit <Strg + c> kann das Programm sofort verlassen werden

    +

    +Eigene Programme mit B15F schreiben

    +

    +Grundsätzliches

    +

    Die wichtigste Klasse für die Steuerung des Board 15 ist B15F.
    +Dort befindet sich auch eine Übersicht der verfügbaren Befehle.
    +

    +

    +Beispiele

    +

    In dem Verzeichnis b15f/control/examples sind einige Beispiele für die Verwendung einzelner B15F Funktionen.
    +Zu jedem Beispiel gehört eine main.cpp mit dem Quellcode und eine Makefile-Datei.
    +Das Beispiel kann mit make kompiliert und mit **./main.elf** gestartet werden.

    +

    +Den B15F Treiber verwenden

    +

    Benötigt wird der B15F-Header:
    +#include <b15f/b15f.h>
    +und der Header für die plottyfile-Generierung, falls mit Kennlinien gearbeitet werden soll:
    +#include <b15f/plottyfile.h>

    +

    Für die Interaktion wird eine Referenz auf die aktuelle Treiberinstanz gespeichert:
    +B15F& drv = B15F::getInstance();
    +Falls noch keine existiert, wird automatisch eine erzeugt und Verbindung zum Board hergestellt.
    + Ab jetzt können auf dem Object drv verschiedene Methoden angewand werden, siehe B15F.
    +

    +

    +Kennlinien mit plottyfile generieren

    +

    Die Beschreibung zu Plottyfile befindet sich hier.
    +Nach dem Include von plottyfile kann ein neues Objekt erzeugt und konfiguriert werden:
    +

    {C++}
    PlottyFile pf;
    pf.setUnitX("V");
    pf.setUnitY("V");
    pf.setUnitPara("V");
    pf.setDescX("U_{OUT}");
    pf.setDescY("U_{IN}");
    pf.setDescPara("");
    pf.setRefX(5);
    pf.setRefY(5);
    pf.setParaFirstCurve(0);
    pf.setParaStepWidth(0);

    Messpunkte können anschließend hinzugefügt werden.
    +Dabei gehören Punkte mit dem gleichen Index für curve (uint8_t) zur selben Kurve und erhalten durch Plotty automatisch die gleiche Farbe.
    +

    {C++}
    pf.addDot(Dot(x, y, curve));

    x und y sind uint16_t, also keine Gleitkommazahlen.

    diff --git a/docs/html/menudata.js b/docs/html/menudata.js index 3c52b9d..e79079b 100644 --- a/docs/html/menudata.js +++ b/docs/html/menudata.js @@ -29,17 +29,21 @@ var menudata={children:[ {text:"Class Members",url:"functions.html",children:[ {text:"All",url:"functions.html",children:[ {text:"a",url:"functions.html#index_a"}, +{text:"b",url:"functions.html#index_b"}, {text:"c",url:"functions.html#index_c"}, {text:"d",url:"functions.html#index_d"}, {text:"e",url:"functions.html#index_e"}, {text:"f",url:"functions.html#index_f"}, {text:"g",url:"functions.html#index_g"}, +{text:"m",url:"functions.html#index_m"}, {text:"o",url:"functions.html#index_o"}, {text:"p",url:"functions.html#index_p"}, {text:"r",url:"functions.html#index_r"}, {text:"s",url:"functions.html#index_s"}, {text:"t",url:"functions.html#index_t"}, -{text:"w",url:"functions.html#index_w"}]}, +{text:"u",url:"functions.html#index_u"}, +{text:"w",url:"functions.html#index_w"}, +{text:"~",url:"functions.html#index__7E"}]}, {text:"Functions",url:"functions_func.html",children:[ {text:"a",url:"functions_func.html#index_a"}, {text:"c",url:"functions_func.html#index_c"}, @@ -52,6 +56,9 @@ var menudata={children:[ {text:"r",url:"functions_func.html#index_r"}, {text:"s",url:"functions_func.html#index_s"}, {text:"t",url:"functions_func.html#index_t"}, -{text:"w",url:"functions_func.html#index_w"}]}]}]}, +{text:"u",url:"functions_func.html#index_u"}, +{text:"w",url:"functions_func.html#index_w"}, +{text:"~",url:"functions_func.html#index__7E"}]}, +{text:"Variables",url:"functions_vars.html"}]}]}, {text:"Files",url:"files.html",children:[ {text:"File List",url:"files.html"}]}]} diff --git a/docs/html/plottyfile_8cpp_source.html b/docs/html/plottyfile_8cpp_source.html index 75db2c6..e22de2c 100644 --- a/docs/html/plottyfile_8cpp_source.html +++ b/docs/html/plottyfile_8cpp_source.html @@ -70,11 +70,38 @@ $(function() {
    plottyfile.cpp
    -
    1 #include "plottyfile.h"
    2 
    3 void PlottyFile::addDot(Dot& dot)
    4 {
    5  dots.push_back(dot);
    6 }
    7 
    8 void PlottyFile::addDot(Dot dot)
    9 {
    10  dots.push_back(dot);
    11 }
    12 
    13 void PlottyFile::setFunctionType(FunctionType function_type)
    14 {
    15  this->function_type = function_type;
    16 }
    17 
    18 void PlottyFile::setQuadrant(uint8_t quadrant)
    19 {
    20  if(quadrant < 1 || quadrant > 4)
    21  throw std::range_error("Ungueltiger Quadrant");
    22  this->quadrant = quadrant;
    23 }
    24 
    25 void PlottyFile::setRefX(uint16_t ref_x)
    26 {
    27  this->ref_x = ref_x;
    28 }
    29 
    30 void PlottyFile::setRefY(uint16_t ref_y)
    31 {
    32  this->ref_y = ref_y;
    33 }
    34 
    35 void PlottyFile::setParaFirstCurve(uint16_t para_first)
    36 {
    37  this->para_first = para_first;
    38 }
    39 
    40 void PlottyFile::setParaStepWidth(uint16_t para_stepwidth)
    41 {
    42  this->para_stepwidth = para_stepwidth;
    43 }
    44 
    45 void PlottyFile::setUnitX(std::string unit_x)
    46 {
    47  this->unit_x = unit_x;
    48 }
    49 
    50 void PlottyFile::setDescX(std::string desc_x)
    51 {
    52  this->desc_x = desc_x;
    53 }
    54 
    55 void PlottyFile::setUnitY(std::string unit_y)
    56 {
    57  this->unit_y = unit_y;
    58 }
    59 
    60 void PlottyFile::setDescY(std::string desc_y)
    61 {
    62  this->desc_y = desc_y;
    63 }
    64 
    65 void PlottyFile::setUnitPara(std::string unit_para)
    66 {
    67  this->unit_para = unit_para;
    68 }
    69 
    70 void PlottyFile::setDescPara(std::string desc_para)
    71 {
    72  this->desc_para = desc_para;
    73 }
    74 
    75 FunctionType PlottyFile::getFunctionType() const
    76 {
    77  return function_type;
    78 }
    79 
    80 uint8_t PlottyFile::getQuadrant() const
    81 {
    82  return quadrant;
    83 }
    84 
    85 uint16_t PlottyFile::getRefX() const
    86 {
    87  return ref_x;
    88 }
    89 
    90 uint16_t PlottyFile::getRefY() const
    91 {
    92  return ref_y;
    93 }
    94 
    95 uint16_t PlottyFile::getParaFirstCurve() const
    96 {
    97  return para_first;
    98 }
    99 
    100 uint16_t PlottyFile::getParaStepWidth() const
    101 {
    102  return para_stepwidth;
    103 }
    104 
    105 std::string PlottyFile::getUnitX() const
    106 {
    107  return unit_x;
    108 }
    109 
    110 std::string PlottyFile::getDescX() const
    111 {
    112  return desc_x;
    113 }
    114 
    115 std::string PlottyFile::getUnitY() const
    116 {
    117  return unit_y;
    118 }
    119 
    120 std::string PlottyFile::getDescY() const
    121 {
    122  return desc_y;
    123 }
    124 
    125 std::string PlottyFile::getUnitPara() const
    126 {
    127  return unit_para;
    128 }
    129 
    130 std::string PlottyFile::getDescPara() const
    131 {
    132  return desc_para;
    133 }
    134 
    135 void PlottyFile::prepStr(std::string& str, uint8_t len)
    136 {
    137  if(str.length() > len)
    138  throw std::runtime_error("Zu grosser String.");
    139 
    140  if(str.length() != len)
    141  str += '\n';
    142 
    143  while(str.length() < len)
    144  str += '\0';
    145 }
    146 
    147 void PlottyFile::writeToFile(std::string filename)
    148 {
    149  prepStr(unit_x, STR_LEN_SHORT);
    150  prepStr(desc_x, STR_LEN_LARGE);
    151  prepStr(unit_y, STR_LEN_SHORT);
    152  prepStr(desc_y, STR_LEN_LARGE);
    153  prepStr(unit_para, STR_LEN_SHORT);
    154  prepStr(desc_para, STR_LEN_LARGE);
    155 
    156  std::ofstream file(filename);
    157 
    158  // write file header
    159  file.write(reinterpret_cast<char*>(&command), 1);
    160  file.write(head.c_str(), head.length());
    161  file.write(filetype.c_str(), filetype.length());
    162  file.write(reinterpret_cast<char*>(&version), 2);
    163  file.write(reinterpret_cast<char*>(&subversion), 2);
    164  file.put(static_cast<uint8_t>(function_type));
    165  file.write(reinterpret_cast<char*>(&quadrant), 1);
    166  file.write(reinterpret_cast<char*>(&ref_x), 2);
    167  file.write(reinterpret_cast<char*>(&ref_y), 2);
    168  file.write(reinterpret_cast<char*>(&para_first), 2);
    169  file.write(reinterpret_cast<char*>(&para_stepwidth), 2);
    170  file.write(unit_x.c_str(), unit_x.length());
    171  file.write(desc_x.c_str(), desc_x.length());
    172  file.write(unit_y.c_str(), unit_y.length());
    173  file.write(desc_y.c_str(), desc_y.length());
    174  file.write(unit_para.c_str(), unit_para.length());
    175  file.write(desc_para.c_str(), desc_para.length());
    176  file.write(reinterpret_cast<const char*>(&eof), 1);
    177 
    178  // make sure header size is 256 Byte
    179  while(file.tellp() < 256)
    180  file.put(0);
    181 
    182  for(Dot& dot : dots)
    183  {
    184  file.put((dot.getX() >> 8) | (static_cast<uint8_t>(dot.getCurve()) << 2));
    185  file.put(dot.getX() & 0xFF);
    186  file.put(dot.getY() >> 8);
    187  file.put(dot.getY() & 0xFF);
    188  }
    189 
    190  file.close();
    191 }
    192 
    193 void PlottyFile::startPlotty(std::string filename)
    194 {
    195  int code = system(("plotty --in " + filename).c_str());
    196  if(code)
    197  throw std::runtime_error("Fehler beim Aufruf von plotty");
    198 }
    -
    Definition: dot.h:7
    +
    1 #include "plottyfile.h"
    2 
    4 {
    5  dots.push_back(dot);
    6 }
    7 
    9 {
    10  dots.push_back(dot);
    11 }
    12 
    13 void PlottyFile::setFunctionType(FunctionType function_type)
    14 {
    15  this->function_type = function_type;
    16 }
    17 
    18 void PlottyFile::setQuadrant(uint8_t quadrant)
    19 {
    20  if(quadrant < 1 || quadrant > 4)
    21  throw std::range_error("Ungueltiger Quadrant");
    22  this->quadrant = quadrant;
    23 }
    24 
    25 void PlottyFile::setRefX(uint16_t ref_x)
    26 {
    27  this->ref_x = ref_x;
    28 }
    29 
    30 void PlottyFile::setRefY(uint16_t ref_y)
    31 {
    32  this->ref_y = ref_y;
    33 }
    34 
    35 void PlottyFile::setParaFirstCurve(uint16_t para_first)
    36 {
    37  this->para_first = para_first;
    38 }
    39 
    40 void PlottyFile::setParaStepWidth(uint16_t para_stepwidth)
    41 {
    42  this->para_stepwidth = para_stepwidth;
    43 }
    44 
    45 void PlottyFile::setUnitX(std::string unit_x)
    46 {
    47  this->unit_x = unit_x;
    48 }
    49 
    50 void PlottyFile::setDescX(std::string desc_x)
    51 {
    52  this->desc_x = desc_x;
    53 }
    54 
    55 void PlottyFile::setUnitY(std::string unit_y)
    56 {
    57  this->unit_y = unit_y;
    58 }
    59 
    60 void PlottyFile::setDescY(std::string desc_y)
    61 {
    62  this->desc_y = desc_y;
    63 }
    64 
    65 void PlottyFile::setUnitPara(std::string unit_para)
    66 {
    67  this->unit_para = unit_para;
    68 }
    69 
    70 void PlottyFile::setDescPara(std::string desc_para)
    71 {
    72  this->desc_para = desc_para;
    73 }
    74 
    75 FunctionType PlottyFile::getFunctionType() const
    76 {
    77  return function_type;
    78 }
    79 
    80 uint8_t PlottyFile::getQuadrant() const
    81 {
    82  return quadrant;
    83 }
    84 
    85 uint16_t PlottyFile::getRefX() const
    86 {
    87  return ref_x;
    88 }
    89 
    90 uint16_t PlottyFile::getRefY() const
    91 {
    92  return ref_y;
    93 }
    94 
    96 {
    97  return para_first;
    98 }
    99 
    101 {
    102  return para_stepwidth;
    103 }
    104 
    105 std::string PlottyFile::getUnitX() const
    106 {
    107  return unit_x;
    108 }
    109 
    110 std::string PlottyFile::getDescX() const
    111 {
    112  return desc_x;
    113 }
    114 
    115 std::string PlottyFile::getUnitY() const
    116 {
    117  return unit_y;
    118 }
    119 
    120 std::string PlottyFile::getDescY() const
    121 {
    122  return desc_y;
    123 }
    124 
    125 std::string PlottyFile::getUnitPara() const
    126 {
    127  return unit_para;
    128 }
    129 
    130 std::string PlottyFile::getDescPara() const
    131 {
    132  return desc_para;
    133 }
    134 
    135 void PlottyFile::prepStr(std::string& str, uint8_t len)
    136 {
    137  if(str.length() > len)
    138  throw std::runtime_error("Zu grosser String.");
    139 
    140  if(str.length() != len)
    141  str += '\n';
    142 
    143  while(str.length() < len)
    144  str += '\0';
    145 }
    146 
    147 void PlottyFile::writeToFile(std::string filename)
    148 {
    149  if(dots.empty())
    150  throw std::length_error("Es wurden keine Punkte gespeichert.");
    151 
    152  prepStr(unit_x, STR_LEN_SHORT);
    153  prepStr(desc_x, STR_LEN_LARGE);
    154  prepStr(unit_y, STR_LEN_SHORT);
    155  prepStr(desc_y, STR_LEN_LARGE);
    156  prepStr(unit_para, STR_LEN_SHORT);
    157  prepStr(desc_para, STR_LEN_LARGE);
    158 
    159  std::ofstream file(filename);
    160 
    161  // write file header
    162  file.write(reinterpret_cast<char*>(&command), 1);
    163  file.write(head.c_str(), head.length());
    164  file.write(filetype.c_str(), filetype.length());
    165  file.write(reinterpret_cast<char*>(&version), 2);
    166  file.write(reinterpret_cast<char*>(&subversion), 2);
    167  file.put(static_cast<uint8_t>(function_type));
    168  file.write(reinterpret_cast<char*>(&quadrant), 1);
    169  file.write(reinterpret_cast<char*>(&ref_x), 2);
    170  file.write(reinterpret_cast<char*>(&ref_y), 2);
    171  file.write(reinterpret_cast<char*>(&para_first), 2);
    172  file.write(reinterpret_cast<char*>(&para_stepwidth), 2);
    173  file.write(unit_x.c_str(), unit_x.length());
    174  file.write(desc_x.c_str(), desc_x.length());
    175  file.write(unit_y.c_str(), unit_y.length());
    176  file.write(desc_y.c_str(), desc_y.length());
    177  file.write(unit_para.c_str(), unit_para.length());
    178  file.write(desc_para.c_str(), desc_para.length());
    179  file.write(reinterpret_cast<const char*>(&eof), 1);
    180 
    181  // make sure header size is 256 Byte
    182  while(file.tellp() < 256)
    183  file.put(0);
    184 
    185  for(Dot& dot : dots)
    186  {
    187  file.put((dot.getX() >> 8) | (static_cast<uint8_t>(dot.getCurve()) << 2));
    188  file.put(dot.getX() & 0xFF);
    189  file.put(dot.getY() >> 8);
    190  file.put(dot.getY() & 0xFF);
    191  }
    192 
    193  file.close();
    194 }
    195 
    196 void PlottyFile::startPlotty(std::string filename)
    197 {
    198  int code = system(("plotty --in " + filename).c_str());
    199  if(code)
    200  throw std::runtime_error("Fehler beim Aufruf von plotty");
    201 }
    +
    void setParaStepWidth(uint16_t para_stepwidth)
    Definition: plottyfile.cpp:40
    +
    uint8_t getQuadrant(void) const
    Definition: plottyfile.cpp:80
    +
    void startPlotty(std::string filename)
    Definition: plottyfile.cpp:196
    +
    void writeToFile(std::string filename)
    Definition: plottyfile.cpp:147
    +
    void setUnitX(std::string unit_x)
    Definition: plottyfile.cpp:45
    +
    void setUnitPara(std::string unit_para)
    Definition: plottyfile.cpp:65
    +
    void setDescY(std::string desc_y)
    Definition: plottyfile.cpp:60
    +
    void setQuadrant(uint8_t quadrant)
    Definition: plottyfile.cpp:18
    +
    std::string getDescY(void) const
    Definition: plottyfile.cpp:120
    +
    void setRefY(uint16_t ref_y)
    Definition: plottyfile.cpp:30
    +
    std::string getDescX(void) const
    Definition: plottyfile.cpp:110
    +
    void setFunctionType(FunctionType function_type)
    Definition: plottyfile.cpp:13
    +
    void setDescX(std::string desc_x)
    Definition: plottyfile.cpp:50
    +
    Definition: dot.h:12
    +
    void setRefX(uint16_t ref_x)
    Definition: plottyfile.cpp:25
    +
    void setUnitY(std::string unit_y)
    Definition: plottyfile.cpp:55
    +
    void addDot(Dot &dot)
    Definition: plottyfile.cpp:3
    +
    void setDescPara(std::string desc_para)
    Definition: plottyfile.cpp:70
    +
    uint16_t getParaStepWidth(void) const
    Definition: plottyfile.cpp:100
    +
    std::string getDescPara(void) const
    Definition: plottyfile.cpp:130
    +
    void setParaFirstCurve(uint16_t para_first)
    Definition: plottyfile.cpp:35
    +
    std::string getUnitY(void) const
    Definition: plottyfile.cpp:115
    +
    uint16_t getParaFirstCurve(void) const
    Definition: plottyfile.cpp:95
    +
    uint16_t getRefX(void) const
    Definition: plottyfile.cpp:85
    +
    std::string getUnitPara(void) const
    Definition: plottyfile.cpp:125
    +
    FunctionType getFunctionType(void) const
    Definition: plottyfile.cpp:75
    +
    uint16_t getRefY(void) const
    Definition: plottyfile.cpp:90
    +
    std::string getUnitX(void) const
    Definition: plottyfile.cpp:105
    diff --git a/docs/html/plottyfile_8h_source.html b/docs/html/plottyfile_8h_source.html index a263325..1f19f61 100644 --- a/docs/html/plottyfile_8h_source.html +++ b/docs/html/plottyfile_8h_source.html @@ -70,12 +70,39 @@ $(function() {
    plottyfile.h
    -
    1 #ifndef PLOTTYFILE_H
    2 #define PLOTTYFILE_H
    3 
    4 #include <iostream>
    5 #include <fstream>
    6 #include <exception>
    7 #include <vector>
    8 #include "dot.h"
    9 
    10 enum FunctionType
    11 {
    12  CurveFamily = 'S',
    13  Curve = 'C',
    14  Level = 'P'
    15 };
    16 
    18 {
    19 public:
    20  void addDot(Dot& dot);
    21  void addDot(Dot dot);
    22 
    23  void setFunctionType(FunctionType);
    24  void setQuadrant(uint8_t);
    25  void setRefX(uint16_t);
    26  void setRefY(uint16_t);
    27  void setParaFirstCurve(uint16_t);
    28  void setParaStepWidth(uint16_t);
    29  void setUnitX(std::string);
    30  void setDescX(std::string);
    31  void setUnitY(std::string);
    32  void setDescY(std::string);
    33  void setUnitPara(std::string);
    34  void setDescPara(std::string);
    35 
    36  FunctionType getFunctionType(void) const;
    37  uint8_t getQuadrant(void) const;
    38  uint16_t getRefX(void) const;
    39  uint16_t getRefY(void) const;
    40  uint16_t getParaFirstCurve(void) const;
    41  uint16_t getParaStepWidth(void) const;
    42  std::string getUnitX(void) const;
    43  std::string getDescX(void) const;
    44  std::string getUnitY(void) const;
    45  std::string getDescY(void) const;
    46  std::string getUnitPara(void) const;
    47  std::string getDescPara(void) const;
    48 
    49  void writeToFile(std::string filename);
    50  void startPlotty(std::string filename);
    51 private:
    52  void prepStr(std::string& str, uint8_t len);
    53 
    54  std::vector<Dot> dots;
    55 
    56  int8_t command = 0x1D;
    57  const std::string head = "HTWK-HWLab";
    58  const std::string filetype = "MD";
    59  int16_t version = 1;
    60  int16_t subversion = 0;
    61  FunctionType function_type = FunctionType::Curve;
    62  uint8_t quadrant = 1;
    63  uint16_t ref_x = 1023;
    64  uint16_t ref_y = 1023;
    65  uint16_t para_first = 1;
    66  uint16_t para_stepwidth = 1;
    67  std::string unit_x;
    68  std::string desc_x;
    69  std::string unit_y;
    70  std::string desc_y;
    71  std::string unit_para;
    72  std::string desc_para;
    73  const uint8_t eof = 0xD;
    74 
    75  constexpr static uint8_t STR_LEN_SHORT = 10;
    76  constexpr static uint8_t STR_LEN_LARGE = 20;
    77 };
    78 
    79 #endif // PLOTTYFILE_H
    - -
    Definition: dot.h:7
    +
    1 #ifndef PLOTTYFILE_H
    2 #define PLOTTYFILE_H
    3 
    4 #include <iostream>
    5 #include <fstream>
    6 #include <exception>
    7 #include <vector>
    8 #include <stdexcept>
    9 #include "dot.h"
    10 
    11 enum FunctionType
    12 {
    13  CurveFamily = 'S',
    14  Curve = 'C',
    15  Level = 'P'
    16 };
    17 
    21 {
    22 public:
    27  void addDot(Dot& dot);
    28 
    33  void addDot(Dot dot);
    34 
    39  void setFunctionType(FunctionType function_type);
    40 
    45  void setQuadrant(uint8_t quadrant);
    46 
    51  void setRefX(uint16_t ref_x);
    52 
    57  void setRefY(uint16_t ref_y);
    58 
    64  void setParaFirstCurve(uint16_t para_first);
    65 
    70  void setParaStepWidth(uint16_t para_stepwidth);
    71 
    76  void setUnitX(std::string unit_x);
    77 
    82  void setDescX(std::string desc_x);
    83 
    88  void setUnitY(std::string unit_y);
    89 
    94  void setDescY(std::string desc_y);
    95 
    100  void setUnitPara(std::string unit_para);
    105  void setDescPara(std::string desc_para);
    106 
    107 
    108 
    112  FunctionType getFunctionType(void) const;
    113 
    117  uint8_t getQuadrant(void) const;
    118 
    122  uint16_t getRefX(void) const;
    123 
    127  uint16_t getRefY(void) const;
    128 
    132  uint16_t getParaFirstCurve(void) const;
    133 
    137  uint16_t getParaStepWidth(void) const;
    138 
    142  std::string getUnitX(void) const;
    143 
    147  std::string getDescX(void) const;
    148 
    152  std::string getUnitY(void) const;
    153 
    157  std::string getDescY(void) const;
    158 
    162  std::string getUnitPara(void) const;
    163 
    167  std::string getDescPara(void) const;
    168 
    169 
    174  void writeToFile(std::string filename);
    175 
    180  void startPlotty(std::string filename);
    181 private:
    182  void prepStr(std::string& str, uint8_t len);
    183 
    184  std::vector<Dot> dots;
    185 
    186  int8_t command = 0x1D;
    187  const std::string head = "HTWK-HWLab";
    188  const std::string filetype = "MD";
    189  int16_t version = 1;
    190  int16_t subversion = 0;
    191  FunctionType function_type = FunctionType::Curve;
    192  uint8_t quadrant = 1;
    193  uint16_t ref_x = 1023;
    194  uint16_t ref_y = 1023;
    195  uint16_t para_first = 1;
    196  uint16_t para_stepwidth = 1;
    197  std::string unit_x;
    198  std::string desc_x;
    199  std::string unit_y;
    200  std::string desc_y;
    201  std::string unit_para;
    202  std::string desc_para;
    203  const uint8_t eof = 0xD;
    204 
    205  constexpr static uint8_t STR_LEN_SHORT = 10;
    206  constexpr static uint8_t STR_LEN_LARGE = 20;
    207 };
    208 
    209 #endif // PLOTTYFILE_H
    +
    void setParaStepWidth(uint16_t para_stepwidth)
    Definition: plottyfile.cpp:40
    +
    uint8_t getQuadrant(void) const
    Definition: plottyfile.cpp:80
    +
    void startPlotty(std::string filename)
    Definition: plottyfile.cpp:196
    +
    void writeToFile(std::string filename)
    Definition: plottyfile.cpp:147
    +
    void setUnitX(std::string unit_x)
    Definition: plottyfile.cpp:45
    +
    void setUnitPara(std::string unit_para)
    Definition: plottyfile.cpp:65
    +
    void setDescY(std::string desc_y)
    Definition: plottyfile.cpp:60
    +
    void setQuadrant(uint8_t quadrant)
    Definition: plottyfile.cpp:18
    +
    std::string getDescY(void) const
    Definition: plottyfile.cpp:120
    + +
    void setRefY(uint16_t ref_y)
    Definition: plottyfile.cpp:30
    +
    std::string getDescX(void) const
    Definition: plottyfile.cpp:110
    +
    void setFunctionType(FunctionType function_type)
    Definition: plottyfile.cpp:13
    +
    void setDescX(std::string desc_x)
    Definition: plottyfile.cpp:50
    +
    Definition: dot.h:12
    +
    void setRefX(uint16_t ref_x)
    Definition: plottyfile.cpp:25
    +
    void setUnitY(std::string unit_y)
    Definition: plottyfile.cpp:55
    +
    void addDot(Dot &dot)
    Definition: plottyfile.cpp:3
    +
    void setDescPara(std::string desc_para)
    Definition: plottyfile.cpp:70
    +
    uint16_t getParaStepWidth(void) const
    Definition: plottyfile.cpp:100
    +
    std::string getDescPara(void) const
    Definition: plottyfile.cpp:130
    +
    void setParaFirstCurve(uint16_t para_first)
    Definition: plottyfile.cpp:35
    +
    std::string getUnitY(void) const
    Definition: plottyfile.cpp:115
    +
    uint16_t getParaFirstCurve(void) const
    Definition: plottyfile.cpp:95
    +
    uint16_t getRefX(void) const
    Definition: plottyfile.cpp:85
    +
    std::string getUnitPara(void) const
    Definition: plottyfile.cpp:125
    +
    FunctionType getFunctionType(void) const
    Definition: plottyfile.cpp:75
    +
    uint16_t getRefY(void) const
    Definition: plottyfile.cpp:90
    +
    std::string getUnitX(void) const
    Definition: plottyfile.cpp:105
    diff --git a/docs/html/search/all_0.js b/docs/html/search/all_0.js index ebee3d5..c4bd927 100644 --- a/docs/html/search/all_0.js +++ b/docs/html/search/all_0.js @@ -2,8 +2,9 @@ var searchData= [ ['abort',['abort',['../classB15F.html#a3f09a418f9e3be5d1d750e4515c96f1e',1,'B15F::abort(std::string msg)'],['../classB15F.html#ac962a6a49bddd0e261a8c7d3aded23f8',1,'B15F::abort(std::exception &ex)']]], ['activateselftestmode',['activateSelfTestMode',['../classB15F.html#ad9bf80ee2485fb5aac9926c6ef0731f1',1,'B15F']]], + ['adddot',['addDot',['../classPlottyFile.html#ae091e6eaaca16302f17572ac7dec6f7c',1,'PlottyFile::addDot(Dot &dot)'],['../classPlottyFile.html#a80e4b45219b4e9571992edfc28a28568',1,'PlottyFile::addDot(Dot dot)']]], ['analogread',['analogRead',['../classB15F.html#ae0bd1f69751e2dc3c462db9213fc4627',1,'B15F']]], ['analogsequence',['analogSequence',['../classB15F.html#ab82a324426c3063318c6cafb3089ae02',1,'B15F']]], - ['analogwrite0',['analogWrite0',['../classB15F.html#a5c5583d591afdd3f9501856c6b0ba3e3',1,'B15F']]], - ['analogwrite1',['analogWrite1',['../classB15F.html#a63d67795879cdc0b035c9c970e7d6fc3',1,'B15F']]] + ['analogwrite0',['analogWrite0',['../classB15F.html#afc55fd590c7fa5c942d100cb60c4b0d3',1,'B15F']]], + ['analogwrite1',['analogWrite1',['../classB15F.html#a7f1becceac744f5cd2ad529748fd836f',1,'B15F']]] ]; diff --git a/docs/html/search/all_1.js b/docs/html/search/all_1.js index 7622f87..5156238 100644 --- a/docs/html/search/all_1.js +++ b/docs/html/search/all_1.js @@ -1,4 +1,6 @@ var searchData= [ - ['b15f',['B15F',['../classB15F.html',1,'']]] + ['b15f',['B15F',['../classB15F.html',1,'']]], + ['baudrate',['BAUDRATE',['../classB15F.html#a7d548d6861cfc69753161bf9cda14f87',1,'B15F']]], + ['b15f_20benutzerhandbuch',['B15F Benutzerhandbuch',['../index.html',1,'']]] ]; diff --git a/docs/html/search/all_10.html b/docs/html/search/all_10.html new file mode 100644 index 0000000..c234738 --- /dev/null +++ b/docs/html/search/all_10.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/all_10.js b/docs/html/search/all_10.js new file mode 100644 index 0000000..f5a3874 --- /dev/null +++ b/docs/html/search/all_10.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['_7etimeoutexception',['~TimeoutException',['../classTimeoutException.html#a2f686b262d2ccffa0090fda9b44ab540',1,'TimeoutException']]], + ['_7eusart',['~USART',['../classUSART.html#a0c8eb1a939ca00921e22f6cbcc7bb749',1,'USART']]], + ['_7eusartexception',['~USARTException',['../classUSARTException.html#a0e008b3cb4974859e6bc8c8f8eb480be',1,'USARTException']]] +]; diff --git a/docs/html/search/all_3.js b/docs/html/search/all_3.js index 196425e..937a08b 100644 --- a/docs/html/search/all_3.js +++ b/docs/html/search/all_3.js @@ -7,6 +7,7 @@ var searchData= ['digitalwrite0',['digitalWrite0',['../classB15F.html#a13797edea1c50278988373acbd110064',1,'B15F']]], ['digitalwrite1',['digitalWrite1',['../classB15F.html#aa225e7fc813849634063e071ef25db1b',1,'B15F']]], ['discard',['discard',['../classB15F.html#ae4740cd473f40a1a4121dfa66b25e1d5',1,'B15F']]], - ['dot',['Dot',['../classDot.html',1,'']]], - ['driverexception',['DriverException',['../classDriverException.html',1,'']]] + ['dot',['Dot',['../classDot.html',1,'Dot'],['../classDot.html#ad975f119c0627a928790b3cd5ca6da05',1,'Dot::Dot()']]], + ['driverexception',['DriverException',['../classDriverException.html',1,'']]], + ['drop',['drop',['../classUSART.html#a038d00c0b3d8c0c13c3e7eae5dad7813',1,'USART']]] ]; diff --git a/docs/html/search/all_4.js b/docs/html/search/all_4.js index 4acd298..fb3f662 100644 --- a/docs/html/search/all_4.js +++ b/docs/html/search/all_4.js @@ -1,5 +1,4 @@ var searchData= [ - ['exec',['exec',['../classB15F.html#a1a7ac52984ed7ecac008a3e4060eee3a',1,'B15F']]], - ['einführung',['Einführung',['../index.html',1,'']]] + ['exec',['exec',['../classB15F.html#a1a7ac52984ed7ecac008a3e4060eee3a',1,'B15F']]] ]; diff --git a/docs/html/search/all_6.js b/docs/html/search/all_6.js index fc75b8c..1982342 100644 --- a/docs/html/search/all_6.js +++ b/docs/html/search/all_6.js @@ -2,6 +2,22 @@ var searchData= [ ['getbaudrate',['getBaudrate',['../classUSART.html#a4918672d8069df205378a528b1892db3',1,'USART']]], ['getboardinfo',['getBoardInfo',['../classB15F.html#a4f01677e73d6d172a2c1cae9427a591b',1,'B15F']]], + ['getcurve',['getCurve',['../classDot.html#ad0ae7dc1a9be3d8d985affc089b34396',1,'Dot']]], + ['getdescpara',['getDescPara',['../classPlottyFile.html#a536967daae3b382a5d6575f55450e198',1,'PlottyFile']]], + ['getdescx',['getDescX',['../classPlottyFile.html#a9cf7baa569be308c2cf6e07cadded09d',1,'PlottyFile']]], + ['getdescy',['getDescY',['../classPlottyFile.html#ab4a847fd71a804182f211233e194df45',1,'PlottyFile']]], + ['getfunctiontype',['getFunctionType',['../classPlottyFile.html#a88bb7d8350ed5fbc7a40e8d903c94bdb',1,'PlottyFile']]], ['getinstance',['getInstance',['../classB15F.html#a8b4533d232c55ef2aa967e39e2d23380',1,'B15F']]], - ['gettimeout',['getTimeout',['../classUSART.html#a19cf777956a038878fc2d2b58c3d2b41',1,'USART']]] + ['getparafirstcurve',['getParaFirstCurve',['../classPlottyFile.html#a40828c93d66fe80166c4f603d5bdfa48',1,'PlottyFile']]], + ['getparastepwidth',['getParaStepWidth',['../classPlottyFile.html#a9da23f2bb8e6eb1837fc992ffd4057db',1,'PlottyFile']]], + ['getquadrant',['getQuadrant',['../classPlottyFile.html#a54e94e80061a27614f2d4d63697d3376',1,'PlottyFile']]], + ['getrefx',['getRefX',['../classPlottyFile.html#a7dd84b9f0826f3220fc6b5a4f1ce9890',1,'PlottyFile']]], + ['getrefy',['getRefY',['../classPlottyFile.html#ae6650c61a3b1a610ce716253418bd7f2',1,'PlottyFile']]], + ['getregister',['getRegister',['../classB15F.html#a9bd47da39928af6f51075bdc3fe73ddc',1,'B15F']]], + ['gettimeout',['getTimeout',['../classUSART.html#a19cf777956a038878fc2d2b58c3d2b41',1,'USART']]], + ['getunitpara',['getUnitPara',['../classPlottyFile.html#abcda4139adf8c5ab8a93b13b84ac097c',1,'PlottyFile']]], + ['getunitx',['getUnitX',['../classPlottyFile.html#af952ac5e2c40896acaf6a86063874fe3',1,'PlottyFile']]], + ['getunity',['getUnitY',['../classPlottyFile.html#a746b96036872dbece204e9739f3413b6',1,'PlottyFile']]], + ['getx',['getX',['../classDot.html#a029f0cc99c474122b77a708a317e7f77',1,'Dot']]], + ['gety',['getY',['../classDot.html#a8fcb987e6308d8184d1a2c8692227e58',1,'Dot']]] ]; diff --git a/docs/html/search/all_7.js b/docs/html/search/all_7.js index bd75d34..66df4a3 100644 --- a/docs/html/search/all_7.js +++ b/docs/html/search/all_7.js @@ -1,4 +1,6 @@ var searchData= [ - ['opendevice',['openDevice',['../classUSART.html#a5f7e2abda2ec4a68a5fdb8ee2f8a940a',1,'USART']]] + ['msg',['msg',['../classTimeoutException.html#aa625fc0fae48a67737a98eafb91c9624',1,'TimeoutException::msg()'],['../classUSARTException.html#a14c80df95f216d221aa97cffbcd8dd79',1,'USARTException::msg()']]], + ['msg_5ffail',['MSG_FAIL',['../classB15F.html#a77d1ecf24b406c9204665d3b09c36f1e',1,'B15F']]], + ['msg_5fok',['MSG_OK',['../classB15F.html#ab01299858f74a6cec598688562e0ad02',1,'B15F']]] ]; diff --git a/docs/html/search/all_8.js b/docs/html/search/all_8.js index 8232ab7..bd75d34 100644 --- a/docs/html/search/all_8.js +++ b/docs/html/search/all_8.js @@ -1,5 +1,4 @@ var searchData= [ - ['plottyfile',['PlottyFile',['../classPlottyFile.html',1,'']]], - ['printstatistics',['printStatistics',['../classUSART.html#a33559bb8f0eda33a489d47b9c9227b59',1,'USART']]] + ['opendevice',['openDevice',['../classUSART.html#a5f7e2abda2ec4a68a5fdb8ee2f8a940a',1,'USART']]] ]; diff --git a/docs/html/search/all_9.js b/docs/html/search/all_9.js index 5d35f1d..1695de2 100644 --- a/docs/html/search/all_9.js +++ b/docs/html/search/all_9.js @@ -1,7 +1,7 @@ var searchData= [ - ['readbyte',['readByte',['../classUSART.html#a8f54b98b26bfe084359a5604bda82562',1,'USART']]], - ['readdipswitch',['readDipSwitch',['../classB15F.html#a6f858f21ea81d491b5031b3644a2239a',1,'B15F']]], - ['readint',['readInt',['../classUSART.html#a1534c229db71a375e556cf1e7d0b8119',1,'USART']]], - ['reconnect',['reconnect',['../classB15F.html#a52557b375443c180a044e7d4e80a1ae7',1,'B15F']]] + ['plottyfile',['PlottyFile',['../classPlottyFile.html',1,'']]], + ['pre',['PRE',['../classB15F.html#a3b0fc1f85954b2d9c145af4a3af5b1ec',1,'B15F']]], + ['pwmsetfrequency',['pwmSetFrequency',['../classB15F.html#ac6f6532bb9550a0632c28b98c157d0a1',1,'B15F']]], + ['pwmsetvalue',['pwmSetValue',['../classB15F.html#af9aad3c0db5d5a8b37219d713e1977ee',1,'B15F']]] ]; diff --git a/docs/html/search/all_a.js b/docs/html/search/all_a.js index 4f4d28c..7ca61ac 100644 --- a/docs/html/search/all_a.js +++ b/docs/html/search/all_a.js @@ -1,6 +1,8 @@ var searchData= [ - ['setaborthandler',['setAbortHandler',['../classB15F.html#a55b0cd1ea582bda53d6979442640f8e9',1,'B15F']]], - ['setbaudrate',['setBaudrate',['../classUSART.html#aac63918a8b97ae63ee607cfa39e6d88d',1,'USART']]], - ['settimeout',['setTimeout',['../classUSART.html#ad7fe866cebe920784d2b17602824c7ff',1,'USART']]] + ['readdipswitch',['readDipSwitch',['../classB15F.html#a6f858f21ea81d491b5031b3644a2239a',1,'B15F']]], + ['receive',['receive',['../classUSART.html#a0fdc238203852f00bd750127602b2a6a',1,'USART']]], + ['reconnect',['reconnect',['../classB15F.html#a52557b375443c180a044e7d4e80a1ae7',1,'B15F']]], + ['reconnect_5ftimeout',['RECONNECT_TIMEOUT',['../classB15F.html#a040951746fbfd632e12bd1ad14578816',1,'B15F']]], + ['reconnect_5ftries',['RECONNECT_TRIES',['../classB15F.html#a6c4895bdbcd71ff6743becf97985c2dc',1,'B15F']]] ]; diff --git a/docs/html/search/all_b.js b/docs/html/search/all_b.js index 57a58a5..db20ab4 100644 --- a/docs/html/search/all_b.js +++ b/docs/html/search/all_b.js @@ -1,6 +1,20 @@ var searchData= [ - ['testconnection',['testConnection',['../classB15F.html#af01983594f2af98ab2b1e514aa036a5d',1,'B15F']]], - ['testintconv',['testIntConv',['../classB15F.html#a7b8a0e2a9156f7dcb05d097f23666a78',1,'B15F']]], - ['timeoutexception',['TimeoutException',['../classTimeoutException.html',1,'']]] + ['setaborthandler',['setAbortHandler',['../classB15F.html#a55b0cd1ea582bda53d6979442640f8e9',1,'B15F']]], + ['setbaudrate',['setBaudrate',['../classUSART.html#aac63918a8b97ae63ee607cfa39e6d88d',1,'USART']]], + ['setdescpara',['setDescPara',['../classPlottyFile.html#a431904143c3c1164a2e8b8cfec3c77ab',1,'PlottyFile']]], + ['setdescx',['setDescX',['../classPlottyFile.html#aa0449c290265d55d6223b19cf0a88b0a',1,'PlottyFile']]], + ['setdescy',['setDescY',['../classPlottyFile.html#a38a3a4dfc76bc70523727584bf01d590',1,'PlottyFile']]], + ['setfunctiontype',['setFunctionType',['../classPlottyFile.html#a4e5ab1ebb012a5cc1a3d6458a4cd512f',1,'PlottyFile']]], + ['setparafirstcurve',['setParaFirstCurve',['../classPlottyFile.html#aa676414793becb975506f48d6e949dd0',1,'PlottyFile']]], + ['setparastepwidth',['setParaStepWidth',['../classPlottyFile.html#a6caebd31e04e2e7081cc007047350355',1,'PlottyFile']]], + ['setquadrant',['setQuadrant',['../classPlottyFile.html#a1953ee0d9a87b7353c16139584e9c2ae',1,'PlottyFile']]], + ['setrefx',['setRefX',['../classPlottyFile.html#a80c2c2e97a454566f9c1f2c51e1d7f3e',1,'PlottyFile']]], + ['setrefy',['setRefY',['../classPlottyFile.html#a3a371228ddcc007e97eebe7cc04dffc2',1,'PlottyFile']]], + ['setregister',['setRegister',['../classB15F.html#ab446ecffab28d4515dfade79a8efc93d',1,'B15F']]], + ['settimeout',['setTimeout',['../classUSART.html#ad7fe866cebe920784d2b17602824c7ff',1,'USART']]], + ['setunitpara',['setUnitPara',['../classPlottyFile.html#abbac84109a1e0958a4ca5c270fac0986',1,'PlottyFile']]], + ['setunitx',['setUnitX',['../classPlottyFile.html#ab8d35a841ca9c325fca671cf34e03527',1,'PlottyFile']]], + ['setunity',['setUnitY',['../classPlottyFile.html#abb18c814f435926f741f7ceb310f3059',1,'PlottyFile']]], + ['startplotty',['startPlotty',['../classPlottyFile.html#a08a115ef10458cadfe76077d623313df',1,'PlottyFile']]] ]; diff --git a/docs/html/search/all_c.js b/docs/html/search/all_c.js index c030e1b..37e3d29 100644 --- a/docs/html/search/all_c.js +++ b/docs/html/search/all_c.js @@ -1,5 +1,7 @@ var searchData= [ - ['usart',['USART',['../classUSART.html',1,'']]], - ['usartexception',['USARTException',['../classUSARTException.html',1,'']]] + ['testconnection',['testConnection',['../classB15F.html#af01983594f2af98ab2b1e514aa036a5d',1,'B15F']]], + ['testintconv',['testIntConv',['../classB15F.html#a7b8a0e2a9156f7dcb05d097f23666a78',1,'B15F']]], + ['timeoutexception',['TimeoutException',['../classTimeoutException.html',1,'TimeoutException'],['../classTimeoutException.html#aa45912234da11ffc9dd3594a1bbc0218',1,'TimeoutException::TimeoutException(const char *message)'],['../classTimeoutException.html#ad6e5c200fbfd276f48a6c1163e2d2988',1,'TimeoutException::TimeoutException(const std::string &message)']]], + ['transmit',['transmit',['../classUSART.html#a41b19dd58f307015b73e154048cd74ca',1,'USART']]] ]; diff --git a/docs/html/search/all_d.js b/docs/html/search/all_d.js index 27f785f..7e9d9bc 100644 --- a/docs/html/search/all_d.js +++ b/docs/html/search/all_d.js @@ -1,8 +1,5 @@ var searchData= [ - ['view',['View',['../classView.html',1,'']]], - ['viewinfo',['ViewInfo',['../classViewInfo.html',1,'']]], - ['viewmonitor',['ViewMonitor',['../classViewMonitor.html',1,'']]], - ['viewpromt',['ViewPromt',['../classViewPromt.html',1,'']]], - ['viewselection',['ViewSelection',['../classViewSelection.html',1,'']]] + ['usart',['USART',['../classUSART.html',1,'USART'],['../classUSART.html#a5daed20dc595c43d87c4c28bb08a7449',1,'USART::USART()']]], + ['usartexception',['USARTException',['../classUSARTException.html',1,'USARTException'],['../classUSARTException.html#a3c359db129825703b91392d5128cf93d',1,'USARTException::USARTException(const char *message)'],['../classUSARTException.html#a643c0a8b7f0d81e2f1693a75b378e6c2',1,'USARTException::USARTException(const std::string &message)']]] ]; diff --git a/docs/html/search/all_e.js b/docs/html/search/all_e.js index 88b07d9..27f785f 100644 --- a/docs/html/search/all_e.js +++ b/docs/html/search/all_e.js @@ -1,5 +1,8 @@ var searchData= [ - ['writebyte',['writeByte',['../classUSART.html#a60eadbe9956bab8144ee96d89eacd9f5',1,'USART']]], - ['writeint',['writeInt',['../classUSART.html#a78b30d9aa863f38745e982860392599a',1,'USART']]] + ['view',['View',['../classView.html',1,'']]], + ['viewinfo',['ViewInfo',['../classViewInfo.html',1,'']]], + ['viewmonitor',['ViewMonitor',['../classViewMonitor.html',1,'']]], + ['viewpromt',['ViewPromt',['../classViewPromt.html',1,'']]], + ['viewselection',['ViewSelection',['../classViewSelection.html',1,'']]] ]; diff --git a/docs/html/search/all_f.html b/docs/html/search/all_f.html new file mode 100644 index 0000000..ca42a52 --- /dev/null +++ b/docs/html/search/all_f.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/all_f.js b/docs/html/search/all_f.js new file mode 100644 index 0000000..38b315c --- /dev/null +++ b/docs/html/search/all_f.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['wdt_5ftimeout',['WDT_TIMEOUT',['../classB15F.html#a158d13bc84aed6430cdede1396384e06',1,'B15F']]], + ['what',['what',['../classTimeoutException.html#a97eaf01fc39ddb94b060020b42fefd6e',1,'TimeoutException::what()'],['../classUSARTException.html#a2af5e3c00cd0585c7427c2e0420a8f15',1,'USARTException::what()']]], + ['writetofile',['writeToFile',['../classPlottyFile.html#a82c348e7fade2edcbc907e7c2bc2e305',1,'PlottyFile']]] +]; diff --git a/docs/html/search/functions_0.js b/docs/html/search/functions_0.js index ebee3d5..c4bd927 100644 --- a/docs/html/search/functions_0.js +++ b/docs/html/search/functions_0.js @@ -2,8 +2,9 @@ var searchData= [ ['abort',['abort',['../classB15F.html#a3f09a418f9e3be5d1d750e4515c96f1e',1,'B15F::abort(std::string msg)'],['../classB15F.html#ac962a6a49bddd0e261a8c7d3aded23f8',1,'B15F::abort(std::exception &ex)']]], ['activateselftestmode',['activateSelfTestMode',['../classB15F.html#ad9bf80ee2485fb5aac9926c6ef0731f1',1,'B15F']]], + ['adddot',['addDot',['../classPlottyFile.html#ae091e6eaaca16302f17572ac7dec6f7c',1,'PlottyFile::addDot(Dot &dot)'],['../classPlottyFile.html#a80e4b45219b4e9571992edfc28a28568',1,'PlottyFile::addDot(Dot dot)']]], ['analogread',['analogRead',['../classB15F.html#ae0bd1f69751e2dc3c462db9213fc4627',1,'B15F']]], ['analogsequence',['analogSequence',['../classB15F.html#ab82a324426c3063318c6cafb3089ae02',1,'B15F']]], - ['analogwrite0',['analogWrite0',['../classB15F.html#a5c5583d591afdd3f9501856c6b0ba3e3',1,'B15F']]], - ['analogwrite1',['analogWrite1',['../classB15F.html#a63d67795879cdc0b035c9c970e7d6fc3',1,'B15F']]] + ['analogwrite0',['analogWrite0',['../classB15F.html#afc55fd590c7fa5c942d100cb60c4b0d3',1,'B15F']]], + ['analogwrite1',['analogWrite1',['../classB15F.html#a7f1becceac744f5cd2ad529748fd836f',1,'B15F']]] ]; diff --git a/docs/html/search/functions_2.js b/docs/html/search/functions_2.js index 970150a..06f50ef 100644 --- a/docs/html/search/functions_2.js +++ b/docs/html/search/functions_2.js @@ -6,5 +6,7 @@ var searchData= ['digitalread1',['digitalRead1',['../classB15F.html#afc76b612dd4faeee0ac02a66b65af5f2',1,'B15F']]], ['digitalwrite0',['digitalWrite0',['../classB15F.html#a13797edea1c50278988373acbd110064',1,'B15F']]], ['digitalwrite1',['digitalWrite1',['../classB15F.html#aa225e7fc813849634063e071ef25db1b',1,'B15F']]], - ['discard',['discard',['../classB15F.html#ae4740cd473f40a1a4121dfa66b25e1d5',1,'B15F']]] + ['discard',['discard',['../classB15F.html#ae4740cd473f40a1a4121dfa66b25e1d5',1,'B15F']]], + ['dot',['Dot',['../classDot.html#ad975f119c0627a928790b3cd5ca6da05',1,'Dot']]], + ['drop',['drop',['../classUSART.html#a038d00c0b3d8c0c13c3e7eae5dad7813',1,'USART']]] ]; diff --git a/docs/html/search/functions_5.js b/docs/html/search/functions_5.js index fc75b8c..1982342 100644 --- a/docs/html/search/functions_5.js +++ b/docs/html/search/functions_5.js @@ -2,6 +2,22 @@ var searchData= [ ['getbaudrate',['getBaudrate',['../classUSART.html#a4918672d8069df205378a528b1892db3',1,'USART']]], ['getboardinfo',['getBoardInfo',['../classB15F.html#a4f01677e73d6d172a2c1cae9427a591b',1,'B15F']]], + ['getcurve',['getCurve',['../classDot.html#ad0ae7dc1a9be3d8d985affc089b34396',1,'Dot']]], + ['getdescpara',['getDescPara',['../classPlottyFile.html#a536967daae3b382a5d6575f55450e198',1,'PlottyFile']]], + ['getdescx',['getDescX',['../classPlottyFile.html#a9cf7baa569be308c2cf6e07cadded09d',1,'PlottyFile']]], + ['getdescy',['getDescY',['../classPlottyFile.html#ab4a847fd71a804182f211233e194df45',1,'PlottyFile']]], + ['getfunctiontype',['getFunctionType',['../classPlottyFile.html#a88bb7d8350ed5fbc7a40e8d903c94bdb',1,'PlottyFile']]], ['getinstance',['getInstance',['../classB15F.html#a8b4533d232c55ef2aa967e39e2d23380',1,'B15F']]], - ['gettimeout',['getTimeout',['../classUSART.html#a19cf777956a038878fc2d2b58c3d2b41',1,'USART']]] + ['getparafirstcurve',['getParaFirstCurve',['../classPlottyFile.html#a40828c93d66fe80166c4f603d5bdfa48',1,'PlottyFile']]], + ['getparastepwidth',['getParaStepWidth',['../classPlottyFile.html#a9da23f2bb8e6eb1837fc992ffd4057db',1,'PlottyFile']]], + ['getquadrant',['getQuadrant',['../classPlottyFile.html#a54e94e80061a27614f2d4d63697d3376',1,'PlottyFile']]], + ['getrefx',['getRefX',['../classPlottyFile.html#a7dd84b9f0826f3220fc6b5a4f1ce9890',1,'PlottyFile']]], + ['getrefy',['getRefY',['../classPlottyFile.html#ae6650c61a3b1a610ce716253418bd7f2',1,'PlottyFile']]], + ['getregister',['getRegister',['../classB15F.html#a9bd47da39928af6f51075bdc3fe73ddc',1,'B15F']]], + ['gettimeout',['getTimeout',['../classUSART.html#a19cf777956a038878fc2d2b58c3d2b41',1,'USART']]], + ['getunitpara',['getUnitPara',['../classPlottyFile.html#abcda4139adf8c5ab8a93b13b84ac097c',1,'PlottyFile']]], + ['getunitx',['getUnitX',['../classPlottyFile.html#af952ac5e2c40896acaf6a86063874fe3',1,'PlottyFile']]], + ['getunity',['getUnitY',['../classPlottyFile.html#a746b96036872dbece204e9739f3413b6',1,'PlottyFile']]], + ['getx',['getX',['../classDot.html#a029f0cc99c474122b77a708a317e7f77',1,'Dot']]], + ['gety',['getY',['../classDot.html#a8fcb987e6308d8184d1a2c8692227e58',1,'Dot']]] ]; diff --git a/docs/html/search/functions_7.js b/docs/html/search/functions_7.js index cfb7a36..b0de2bf 100644 --- a/docs/html/search/functions_7.js +++ b/docs/html/search/functions_7.js @@ -1,4 +1,5 @@ var searchData= [ - ['printstatistics',['printStatistics',['../classUSART.html#a33559bb8f0eda33a489d47b9c9227b59',1,'USART']]] + ['pwmsetfrequency',['pwmSetFrequency',['../classB15F.html#ac6f6532bb9550a0632c28b98c157d0a1',1,'B15F']]], + ['pwmsetvalue',['pwmSetValue',['../classB15F.html#af9aad3c0db5d5a8b37219d713e1977ee',1,'B15F']]] ]; diff --git a/docs/html/search/functions_8.js b/docs/html/search/functions_8.js index 5d35f1d..b57cb64 100644 --- a/docs/html/search/functions_8.js +++ b/docs/html/search/functions_8.js @@ -1,7 +1,6 @@ var searchData= [ - ['readbyte',['readByte',['../classUSART.html#a8f54b98b26bfe084359a5604bda82562',1,'USART']]], ['readdipswitch',['readDipSwitch',['../classB15F.html#a6f858f21ea81d491b5031b3644a2239a',1,'B15F']]], - ['readint',['readInt',['../classUSART.html#a1534c229db71a375e556cf1e7d0b8119',1,'USART']]], + ['receive',['receive',['../classUSART.html#a0fdc238203852f00bd750127602b2a6a',1,'USART']]], ['reconnect',['reconnect',['../classB15F.html#a52557b375443c180a044e7d4e80a1ae7',1,'B15F']]] ]; diff --git a/docs/html/search/functions_9.js b/docs/html/search/functions_9.js index 4f4d28c..db20ab4 100644 --- a/docs/html/search/functions_9.js +++ b/docs/html/search/functions_9.js @@ -2,5 +2,19 @@ var searchData= [ ['setaborthandler',['setAbortHandler',['../classB15F.html#a55b0cd1ea582bda53d6979442640f8e9',1,'B15F']]], ['setbaudrate',['setBaudrate',['../classUSART.html#aac63918a8b97ae63ee607cfa39e6d88d',1,'USART']]], - ['settimeout',['setTimeout',['../classUSART.html#ad7fe866cebe920784d2b17602824c7ff',1,'USART']]] + ['setdescpara',['setDescPara',['../classPlottyFile.html#a431904143c3c1164a2e8b8cfec3c77ab',1,'PlottyFile']]], + ['setdescx',['setDescX',['../classPlottyFile.html#aa0449c290265d55d6223b19cf0a88b0a',1,'PlottyFile']]], + ['setdescy',['setDescY',['../classPlottyFile.html#a38a3a4dfc76bc70523727584bf01d590',1,'PlottyFile']]], + ['setfunctiontype',['setFunctionType',['../classPlottyFile.html#a4e5ab1ebb012a5cc1a3d6458a4cd512f',1,'PlottyFile']]], + ['setparafirstcurve',['setParaFirstCurve',['../classPlottyFile.html#aa676414793becb975506f48d6e949dd0',1,'PlottyFile']]], + ['setparastepwidth',['setParaStepWidth',['../classPlottyFile.html#a6caebd31e04e2e7081cc007047350355',1,'PlottyFile']]], + ['setquadrant',['setQuadrant',['../classPlottyFile.html#a1953ee0d9a87b7353c16139584e9c2ae',1,'PlottyFile']]], + ['setrefx',['setRefX',['../classPlottyFile.html#a80c2c2e97a454566f9c1f2c51e1d7f3e',1,'PlottyFile']]], + ['setrefy',['setRefY',['../classPlottyFile.html#a3a371228ddcc007e97eebe7cc04dffc2',1,'PlottyFile']]], + ['setregister',['setRegister',['../classB15F.html#ab446ecffab28d4515dfade79a8efc93d',1,'B15F']]], + ['settimeout',['setTimeout',['../classUSART.html#ad7fe866cebe920784d2b17602824c7ff',1,'USART']]], + ['setunitpara',['setUnitPara',['../classPlottyFile.html#abbac84109a1e0958a4ca5c270fac0986',1,'PlottyFile']]], + ['setunitx',['setUnitX',['../classPlottyFile.html#ab8d35a841ca9c325fca671cf34e03527',1,'PlottyFile']]], + ['setunity',['setUnitY',['../classPlottyFile.html#abb18c814f435926f741f7ceb310f3059',1,'PlottyFile']]], + ['startplotty',['startPlotty',['../classPlottyFile.html#a08a115ef10458cadfe76077d623313df',1,'PlottyFile']]] ]; diff --git a/docs/html/search/functions_a.js b/docs/html/search/functions_a.js index 4b801c0..c417073 100644 --- a/docs/html/search/functions_a.js +++ b/docs/html/search/functions_a.js @@ -1,5 +1,7 @@ var searchData= [ ['testconnection',['testConnection',['../classB15F.html#af01983594f2af98ab2b1e514aa036a5d',1,'B15F']]], - ['testintconv',['testIntConv',['../classB15F.html#a7b8a0e2a9156f7dcb05d097f23666a78',1,'B15F']]] + ['testintconv',['testIntConv',['../classB15F.html#a7b8a0e2a9156f7dcb05d097f23666a78',1,'B15F']]], + ['timeoutexception',['TimeoutException',['../classTimeoutException.html#aa45912234da11ffc9dd3594a1bbc0218',1,'TimeoutException::TimeoutException(const char *message)'],['../classTimeoutException.html#ad6e5c200fbfd276f48a6c1163e2d2988',1,'TimeoutException::TimeoutException(const std::string &message)']]], + ['transmit',['transmit',['../classUSART.html#a41b19dd58f307015b73e154048cd74ca',1,'USART']]] ]; diff --git a/docs/html/search/functions_b.js b/docs/html/search/functions_b.js index 88b07d9..7419b81 100644 --- a/docs/html/search/functions_b.js +++ b/docs/html/search/functions_b.js @@ -1,5 +1,5 @@ var searchData= [ - ['writebyte',['writeByte',['../classUSART.html#a60eadbe9956bab8144ee96d89eacd9f5',1,'USART']]], - ['writeint',['writeInt',['../classUSART.html#a78b30d9aa863f38745e982860392599a',1,'USART']]] + ['usart',['USART',['../classUSART.html#a5daed20dc595c43d87c4c28bb08a7449',1,'USART']]], + ['usartexception',['USARTException',['../classUSARTException.html#a3c359db129825703b91392d5128cf93d',1,'USARTException::USARTException(const char *message)'],['../classUSARTException.html#a643c0a8b7f0d81e2f1693a75b378e6c2',1,'USARTException::USARTException(const std::string &message)']]] ]; diff --git a/docs/html/search/functions_c.html b/docs/html/search/functions_c.html new file mode 100644 index 0000000..a1a1437 --- /dev/null +++ b/docs/html/search/functions_c.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/functions_c.js b/docs/html/search/functions_c.js new file mode 100644 index 0000000..b730bff --- /dev/null +++ b/docs/html/search/functions_c.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['what',['what',['../classTimeoutException.html#a97eaf01fc39ddb94b060020b42fefd6e',1,'TimeoutException::what()'],['../classUSARTException.html#a2af5e3c00cd0585c7427c2e0420a8f15',1,'USARTException::what()']]], + ['writetofile',['writeToFile',['../classPlottyFile.html#a82c348e7fade2edcbc907e7c2bc2e305',1,'PlottyFile']]] +]; diff --git a/docs/html/search/functions_d.html b/docs/html/search/functions_d.html new file mode 100644 index 0000000..4375535 --- /dev/null +++ b/docs/html/search/functions_d.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/functions_d.js b/docs/html/search/functions_d.js new file mode 100644 index 0000000..f5a3874 --- /dev/null +++ b/docs/html/search/functions_d.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['_7etimeoutexception',['~TimeoutException',['../classTimeoutException.html#a2f686b262d2ccffa0090fda9b44ab540',1,'TimeoutException']]], + ['_7eusart',['~USART',['../classUSART.html#a0c8eb1a939ca00921e22f6cbcc7bb749',1,'USART']]], + ['_7eusartexception',['~USARTException',['../classUSARTException.html#a0e008b3cb4974859e6bc8c8f8eb480be',1,'USARTException']]] +]; diff --git a/docs/html/search/pages_0.js b/docs/html/search/pages_0.js index abe03ca..31be983 100644 --- a/docs/html/search/pages_0.js +++ b/docs/html/search/pages_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['einführung',['Einführung',['../index.html',1,'']]] + ['b15f_20benutzerhandbuch',['B15F Benutzerhandbuch',['../index.html',1,'']]] ]; diff --git a/docs/html/search/searchdata.js b/docs/html/search/searchdata.js index 522aa5c..9ff7555 100644 --- a/docs/html/search/searchdata.js +++ b/docs/html/search/searchdata.js @@ -1,9 +1,10 @@ var indexSectionsWithContent = { - 0: "abcdefgoprstuvw", + 0: "abcdefgmoprstuvw~", 1: "bdptuv", - 2: "acdefgoprstw", - 3: "e" + 2: "acdefgoprstuw~", + 3: "bmprw", + 4: "b" }; var indexSectionNames = @@ -11,7 +12,8 @@ var indexSectionNames = 0: "all", 1: "classes", 2: "functions", - 3: "pages" + 3: "variables", + 4: "pages" }; var indexSectionLabels = @@ -19,6 +21,7 @@ var indexSectionLabels = 0: "All", 1: "Classes", 2: "Functions", - 3: "Pages" + 3: "Variables", + 4: "Pages" }; diff --git a/docs/html/search/variables_0.html b/docs/html/search/variables_0.html new file mode 100644 index 0000000..a2a3ae6 --- /dev/null +++ b/docs/html/search/variables_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/variables_0.js b/docs/html/search/variables_0.js new file mode 100644 index 0000000..d1fd2cf --- /dev/null +++ b/docs/html/search/variables_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['baudrate',['BAUDRATE',['../classB15F.html#a7d548d6861cfc69753161bf9cda14f87',1,'B15F']]] +]; diff --git a/docs/html/search/variables_1.html b/docs/html/search/variables_1.html new file mode 100644 index 0000000..b243c42 --- /dev/null +++ b/docs/html/search/variables_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/variables_1.js b/docs/html/search/variables_1.js new file mode 100644 index 0000000..66df4a3 --- /dev/null +++ b/docs/html/search/variables_1.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['msg',['msg',['../classTimeoutException.html#aa625fc0fae48a67737a98eafb91c9624',1,'TimeoutException::msg()'],['../classUSARTException.html#a14c80df95f216d221aa97cffbcd8dd79',1,'USARTException::msg()']]], + ['msg_5ffail',['MSG_FAIL',['../classB15F.html#a77d1ecf24b406c9204665d3b09c36f1e',1,'B15F']]], + ['msg_5fok',['MSG_OK',['../classB15F.html#ab01299858f74a6cec598688562e0ad02',1,'B15F']]] +]; diff --git a/docs/html/search/variables_2.html b/docs/html/search/variables_2.html new file mode 100644 index 0000000..647df20 --- /dev/null +++ b/docs/html/search/variables_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/variables_2.js b/docs/html/search/variables_2.js new file mode 100644 index 0000000..570beea --- /dev/null +++ b/docs/html/search/variables_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['pre',['PRE',['../classB15F.html#a3b0fc1f85954b2d9c145af4a3af5b1ec',1,'B15F']]] +]; diff --git a/docs/html/search/variables_3.html b/docs/html/search/variables_3.html new file mode 100644 index 0000000..9dc9b89 --- /dev/null +++ b/docs/html/search/variables_3.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/variables_3.js b/docs/html/search/variables_3.js new file mode 100644 index 0000000..fbf0a47 --- /dev/null +++ b/docs/html/search/variables_3.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['reconnect_5ftimeout',['RECONNECT_TIMEOUT',['../classB15F.html#a040951746fbfd632e12bd1ad14578816',1,'B15F']]], + ['reconnect_5ftries',['RECONNECT_TRIES',['../classB15F.html#a6c4895bdbcd71ff6743becf97985c2dc',1,'B15F']]] +]; diff --git a/docs/html/search/variables_4.html b/docs/html/search/variables_4.html new file mode 100644 index 0000000..78cc2c7 --- /dev/null +++ b/docs/html/search/variables_4.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/html/search/variables_4.js b/docs/html/search/variables_4.js new file mode 100644 index 0000000..9a9c561 --- /dev/null +++ b/docs/html/search/variables_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['wdt_5ftimeout',['WDT_TIMEOUT',['../classB15F.html#a158d13bc84aed6430cdede1396384e06',1,'B15F']]] +]; diff --git a/docs/html/timeoutexception_8h_source.html b/docs/html/timeoutexception_8h_source.html index cfb9642..d121f28 100644 --- a/docs/html/timeoutexception_8h_source.html +++ b/docs/html/timeoutexception_8h_source.html @@ -70,11 +70,16 @@ $(function() {
    timeoutexception.h
    -
    1 #ifndef TIMEOUTEXCEPTION_H
    2 #define TIMEOUTEXCEPTION_H
    3 
    4 #include <exception>
    5 
    6 // SOURCE: https://stackoverflow.com/a/8152888
    7 
    8 class TimeoutException: public std::exception
    9 {
    10 public:
    11  explicit TimeoutException(const char* message, int timeout) : TimeoutException(std::string(message), timeout)
    12  {
    13  }
    14 
    15  explicit TimeoutException(const std::string& message, int timeout) : msg(message), m_timeout(timeout)
    16  {
    17  if(!msg.length())
    18  msg = "Timeout reached (" + std::to_string(m_timeout) + ")";
    19  }
    20 
    21  virtual ~TimeoutException() throw ()
    22  {
    23  }
    24 
    25  virtual const char* what() const throw ()
    26  {
    27  return msg.c_str();
    28  }
    29 
    30 protected:
    31  std::string msg;
    32  int m_timeout;
    33 };
    34 
    35 #endif // TIMEOUTEXCEPTION_H
    - +
    1 #ifndef TIMEOUTEXCEPTION_H
    2 #define TIMEOUTEXCEPTION_H
    3 
    4 #include <exception>
    5 #include <string>
    6 
    9 class TimeoutException: public std::exception
    10 {
    11 public:
    16  explicit TimeoutException(const char* message) : msg(message)
    17  {
    18  }
    19 
    24  explicit TimeoutException(const std::string& message) : msg(message)
    25  {
    26  }
    27 
    31  virtual ~TimeoutException() = default;
    32 
    37  virtual const char* what() const throw ()
    38  {
    39  return msg.c_str();
    40  }
    41 
    42 protected:
    43  std::string msg;
    44 };
    45 
    46 #endif // TIMEOUTEXCEPTION_H
    +
    virtual ~TimeoutException()=default
    +
    std::string msg
    failure description
    +
    virtual const char * what() const
    +
    TimeoutException(const char *message)
    + +
    TimeoutException(const std::string &message)
    diff --git a/docs/html/ui_8cpp_source.html b/docs/html/ui_8cpp_source.html index 07d853b..3724f29 100644 --- a/docs/html/ui_8cpp_source.html +++ b/docs/html/ui_8cpp_source.html @@ -70,24 +70,25 @@ $(function() {
    ui.cpp
    -
    1 #include "ui.h"
    2 #include "../drv/b15f.h"
    3 
    4 std::vector<View*> win_stack;
    5 std::thread t_refresh;
    6 
    7 void show_main(int)
    8 {
    9  ViewSelection* view = new ViewSelection();
    10  view->setTitle("B15F - Command Line Interface");
    11  view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor);
    12  view->addChoice("[ Digitale Ausgabe BE0 ]", &show_digital_output0);
    13  view->addChoice("[ Digitale Ausgabe BE1 ]", &show_digital_output1);
    14  view->addChoice("[ Analoge Ausgabe AA0 ]", &show_analog_output0);
    15  view->addChoice("[ Analoge Ausgabe AA1 ]", &show_analog_output1);
    16  view->addChoice("[ Selbsttest des B15 ]", &show_selftest_info);
    17  view->addChoice("[ Informationen ]", &show_info);
    18  view->addChoice("", nullptr);
    19  view->addChoice("[ Beenden ]", &finish);
    20  view->repaint();
    21 
    22  win_stack.push_back(view);
    23  input(0);
    24 }
    25 
    26 void input(int)
    27 {
    28  call_t nextCall;
    29  int key;
    30  do
    31  {
    32  key = wgetch(View::getWinContext());
    33  win_stack.back()->repaint();
    34  nextCall = win_stack.back()->keypress(key);
    35 
    36  if(key == -1)
    37  view_back(key);
    38 
    39  if(nextCall)
    40  nextCall(key);
    41  }
    42  while(win_stack.size());
    43 }
    44 
    45 void view_back(int)
    46 {
    47  if(win_stack.size())
    48  {
    49  delete win_stack.back();
    50  win_stack.pop_back();
    51  }
    52  if(win_stack.size())
    53  win_stack.back()->repaint();
    54 }
    55 
    56 void finish(int)
    57 {
    58  cleanup();
    59  exit(EXIT_SUCCESS);
    60 }
    61 
    62 void cleanup()
    63 {
    64  if(t_refresh.joinable())
    65  t_refresh.join();
    66  clrtoeol();
    67  refresh();
    68  endwin();
    69 }
    70 
    71 void show_info(int)
    72 {
    73  ViewInfo* view = new ViewInfo();
    74  view->setTitle("Info");
    75  view->setText("Informationen zu Board 15 Famulus Edition\nEs war einmal...");
    76  view->setLabelClose("[ Zurueck ]");
    77  view->repaint();
    78 
    79  win_stack.push_back(view);
    80  input(0);
    81 }
    82 
    83 void show_monitor(int)
    84 {
    85  ViewMonitor* view = new ViewMonitor();
    86  view->setTitle("Monitor");
    87  view->setText("\nErfasse Messwerte...");
    88  view->setLabelClose("[ Zurueck ]");
    89  view->repaint();
    90 
    91  win_stack.push_back(view);
    92  input(0);
    93 }
    94 
    95 void show_invalid_port_input(int)
    96 {
    97  ViewInfo* view = new ViewInfo();
    98  view->setTitle("Falsche Eingabe");
    99  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, FF] an.");
    100  view->setLabelClose("[ Schliessen ]");
    101  view->repaint();
    102 
    103  win_stack.push_back(view);
    104  input(0);
    105 }
    106 
    107 void show_invalid_dac_input(int)
    108 {
    109  ViewInfo* view = new ViewInfo();
    110  view->setTitle("Falsche Eingabe");
    111  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, 1023] an.");
    112  view->setLabelClose("[ Schliessen ]");
    113  view->repaint();
    114 
    115  win_stack.push_back(view);
    116  input(0);
    117 }
    118 
    119 void write_digital_output0(int)
    120 {
    121  try
    122  {
    123  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    124  if(d > 255 || 0 > d)
    125  throw std::invalid_argument("bad value");
    126  uint8_t port = static_cast<uint8_t>(d);
    127 
    128  B15F& drv = B15F::getInstance();
    129  drv.digitalWrite0(port);
    130  view_back(0);
    131  }
    132  catch(std::invalid_argument& ex)
    133  {
    134  show_invalid_port_input(0);
    135  }
    136 }
    137 
    138 void write_digital_output1(int)
    139 {
    140  try
    141  {
    142  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    143  if(d > 255 || 0 > d)
    144  throw std::invalid_argument("bad value");
    145  uint8_t port = static_cast<uint8_t>(d);
    146 
    147  B15F& drv = B15F::getInstance();
    148  drv.digitalWrite1(port);
    149  view_back(0);
    150  }
    151  catch(std::invalid_argument& ex)
    152  {
    153  show_invalid_port_input(0);
    154  }
    155 }
    156 
    157 void write_analog_output0(int)
    158 {
    159  try
    160  {
    161  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    162  if(port > 1023)
    163  throw std::invalid_argument("bad value");
    164 
    165  B15F& drv = B15F::getInstance();
    166  drv.analogWrite0(port);
    167  view_back(0);
    168  }
    169  catch(std::invalid_argument& ex)
    170  {
    171  show_invalid_dac_input(0);
    172  }
    173 }
    174 
    175 void write_analog_output1(int)
    176 {
    177  try
    178  {
    179  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    180  if(port > 1023)
    181  throw std::invalid_argument("bad value");
    182 
    183  B15F& drv = B15F::getInstance();
    184  drv.analogWrite1(port);
    185  view_back(0);
    186  }
    187  catch(std::invalid_argument& ex)
    188  {
    189  show_invalid_dac_input(0);
    190  }
    191 }
    192 
    193 void show_digital_output0(int)
    194 {
    195  ViewPromt* view = new ViewPromt();
    196  view->setTitle("Digitale Ausgabe BE0");
    197  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    198  view->setCancel("[ Zurueck ]", true);
    199  view->setConfirm("[ OK ]", &write_digital_output0);
    200  view->repaint();
    201 
    202  win_stack.push_back(view);
    203  input(0);
    204 }
    205 
    206 void show_digital_output1(int)
    207 {
    208  ViewPromt* view = new ViewPromt();
    209  view->setTitle("Digitale Ausgabe BE1");
    210  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    211  view->setCancel("[ Zurueck ]", true);
    212  view->setConfirm("[ OK ]", &write_digital_output1);
    213  view->repaint();
    214 
    215  win_stack.push_back(view);
    216  input(0);
    217 }
    218 
    219 void show_analog_output0(int)
    220 {
    221  ViewPromt* view = new ViewPromt();
    222  view->setTitle("Analoge Ausgabe AA0");
    223  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    224  view->setCancel("[ Zurueck ]", true);
    225  view->setConfirm("[ OK ]", &write_analog_output0);
    226  view->repaint();
    227 
    228  win_stack.push_back(view);
    229  input(0);
    230 }
    231 
    232 void show_analog_output1(int)
    233 {
    234  ViewPromt* view = new ViewPromt();
    235  view->setTitle("Analoge Ausgabe AA1");
    236  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    237  view->setCancel("[ Zurueck ]", true);
    238  view->setConfirm("[ OK ]", &write_analog_output1);
    239  view->repaint();
    240 
    241  win_stack.push_back(view);
    242  input(0);
    243 }
    244 
    245 void start_selftest(int)
    246 {
    247  B15F& drv = B15F::getInstance();
    248  drv.activateSelfTestMode();
    249 
    250  ViewInfo* view = new ViewInfo();
    251  view->setTitle("Selbsttest aktiv");
    252  view->setText("Das B15 befindet sich jetzt im Selbsttestmodus.\n \nSelbsttest:\nZu Beginn geht der Reihe nach jede LED von BA0 bis BA1 an.\nDanach leuchten die LEDs an AA0 und AA1 kurz auf.\nZum Schluss spiegelt in einer Endlosschleife:\n* BA0 Port BE0\n* BA1 die DIP-Schalter S7\n* AA0 ADC0\n* AA1 ADC1");
    253  view->setLabelClose("[ Selbsttest Beenden ]");
    254  view->setCall(&stop_selftest);
    255  view->repaint();
    256 
    257  win_stack.push_back(view);
    258  input(0);
    259 }
    260 
    261 void stop_selftest(int)
    262 {
    263  B15F& drv = B15F::getInstance();
    264  drv.discard();
    265  drv.delay_ms(B15F::WDT_TIMEOUT);
    266  drv.reconnect();
    267  drv.digitalWrite0(0);
    268  drv.digitalWrite1(0);
    269 }
    270 
    271 void show_selftest_info(int)
    272 {
    273  ViewInfo* view = new ViewInfo();
    274  view->setTitle("Selbsttest");
    275  view->setText("Bitte entfernen Sie jetzt alle Draehte von den Anschlussklemmen und bestaetigen\nmit Enter.");
    276  view->setLabelClose("[ Weiter ]");
    277  view->setCall(&start_selftest);
    278  view->repaint();
    279 
    280  win_stack.push_back(view);
    281  input(0);
    282 }
    - - -
    void delay_ms(uint16_t ms)
    Definition: b15f.cpp:290
    -
    bool analogWrite1(uint16_t)
    Definition: b15f.cpp:209
    -
    static B15F & getInstance(void)
    Definition: b15f.cpp:300
    -
    Definition: b15f.h:24
    -
    bool digitalWrite0(uint8_t)
    Definition: b15f.cpp:152
    -
    bool activateSelfTestMode(void)
    Definition: b15f.cpp:144
    - - -
    bool digitalWrite1(uint8_t)
    Definition: b15f.cpp:162
    +
    1 #include "ui.h"
    2 #include "../drv/b15f.h"
    3 
    4 std::vector<View*> win_stack;
    5 std::thread t_refresh;
    6 
    7 void show_main(int)
    8 {
    9  ViewSelection* view = new ViewSelection();
    10  view->setTitle("B15F - Command Line Interface");
    11  view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor);
    12  view->addChoice("[ Digitale Ausgabe BE0 ]", &show_digital_output0);
    13  view->addChoice("[ Digitale Ausgabe BE1 ]", &show_digital_output1);
    14  view->addChoice("[ Analoge Ausgabe AA0 ]", &show_analog_output0);
    15  view->addChoice("[ Analoge Ausgabe AA1 ]", &show_analog_output1);
    16  view->addChoice("[ Selbsttest des B15 ]", &show_selftest_info);
    17  view->addChoice("[ Informationen ]", &show_info);
    18  view->addChoice("", nullptr);
    19  view->addChoice("[ Beenden ]", &finish);
    20  view->repaint();
    21 
    22  win_stack.push_back(view);
    23  input(0);
    24 }
    25 
    26 void input(int)
    27 {
    28  call_t nextCall;
    29  int key;
    30  do
    31  {
    32  key = wgetch(View::getWinContext());
    33  win_stack.back()->repaint();
    34  nextCall = win_stack.back()->keypress(key);
    35 
    36  if(key == -1)
    37  view_back(key);
    38 
    39  if(nextCall)
    40  nextCall(key);
    41  }
    42  while(win_stack.size());
    43 }
    44 
    45 void view_back(int)
    46 {
    47  if(win_stack.size())
    48  {
    49  delete win_stack.back();
    50  win_stack.pop_back();
    51  }
    52  if(win_stack.size())
    53  win_stack.back()->repaint();
    54 }
    55 
    56 void finish(int)
    57 {
    58  cleanup();
    59  exit(EXIT_SUCCESS);
    60 }
    61 
    62 void cleanup()
    63 {
    64  if(t_refresh.joinable())
    65  t_refresh.join();
    66  clrtoeol();
    67  refresh();
    68  endwin();
    69 }
    70 
    71 void show_info(int)
    72 {
    73  ViewInfo* view = new ViewInfo();
    74  view->setTitle("Info");
    75  view->setText("Informationen zu Board 15 Famulus Edition\nEs war einmal...");
    76  view->setLabelClose("[ Zurueck ]");
    77  view->repaint();
    78 
    79  win_stack.push_back(view);
    80  input(0);
    81 }
    82 
    83 void show_monitor(int)
    84 {
    85  ViewMonitor* view = new ViewMonitor();
    86  view->setTitle("Monitor");
    87  view->setText("\nErfasse Messwerte...");
    88  view->setLabelClose("[ Zurueck ]");
    89  view->repaint();
    90 
    91  win_stack.push_back(view);
    92  input(0);
    93 }
    94 
    95 void show_invalid_port_input(int)
    96 {
    97  ViewInfo* view = new ViewInfo();
    98  view->setTitle("Falsche Eingabe");
    99  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, FF] an.");
    100  view->setLabelClose("[ Schliessen ]");
    101  view->repaint();
    102 
    103  win_stack.push_back(view);
    104  input(0);
    105 }
    106 
    107 void show_invalid_dac_input(int)
    108 {
    109  ViewInfo* view = new ViewInfo();
    110  view->setTitle("Falsche Eingabe");
    111  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, 1023] an.");
    112  view->setLabelClose("[ Schliessen ]");
    113  view->repaint();
    114 
    115  win_stack.push_back(view);
    116  input(0);
    117 }
    118 
    119 void write_digital_output0(int)
    120 {
    121  try
    122  {
    123  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    124  if(d > 255 || 0 > d)
    125  throw std::invalid_argument("bad value");
    126  uint8_t port = static_cast<uint8_t>(d);
    127 
    128  B15F& drv = B15F::getInstance();
    129  drv.digitalWrite0(port);
    130  view_back(0);
    131  }
    132  catch(std::invalid_argument& ex)
    133  {
    134  show_invalid_port_input(0);
    135  }
    136 }
    137 
    138 void write_digital_output1(int)
    139 {
    140  try
    141  {
    142  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    143  if(d > 255 || 0 > d)
    144  throw std::invalid_argument("bad value");
    145  uint8_t port = static_cast<uint8_t>(d);
    146 
    147  B15F& drv = B15F::getInstance();
    148  drv.digitalWrite1(port);
    149  view_back(0);
    150  }
    151  catch(std::invalid_argument& ex)
    152  {
    153  show_invalid_port_input(0);
    154  }
    155 }
    156 
    157 void write_analog_output0(int)
    158 {
    159  try
    160  {
    161  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    162  if(port > 1023)
    163  throw std::invalid_argument("bad value");
    164 
    165  B15F& drv = B15F::getInstance();
    166  drv.analogWrite0(port);
    167  view_back(0);
    168  }
    169  catch(std::invalid_argument& ex)
    170  {
    171  show_invalid_dac_input(0);
    172  }
    173 }
    174 
    175 void write_analog_output1(int)
    176 {
    177  try
    178  {
    179  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    180  if(port > 1023)
    181  throw std::invalid_argument("bad value");
    182 
    183  B15F& drv = B15F::getInstance();
    184  drv.analogWrite1(port);
    185  view_back(0);
    186  }
    187  catch(std::invalid_argument& ex)
    188  {
    189  show_invalid_dac_input(0);
    190  }
    191 }
    192 
    193 void show_digital_output0(int)
    194 {
    195  ViewPromt* view = new ViewPromt();
    196  view->setTitle("Digitale Ausgabe BE0");
    197  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    198  view->setCancel("[ Zurueck ]", true);
    199  view->setConfirm("[ OK ]", &write_digital_output0);
    200  view->repaint();
    201 
    202  win_stack.push_back(view);
    203  input(0);
    204 }
    205 
    206 void show_digital_output1(int)
    207 {
    208  ViewPromt* view = new ViewPromt();
    209  view->setTitle("Digitale Ausgabe BE1");
    210  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    211  view->setCancel("[ Zurueck ]", true);
    212  view->setConfirm("[ OK ]", &write_digital_output1);
    213  view->repaint();
    214 
    215  win_stack.push_back(view);
    216  input(0);
    217 }
    218 
    219 void show_analog_output0(int)
    220 {
    221  ViewPromt* view = new ViewPromt();
    222  view->setTitle("Analoge Ausgabe AA0");
    223  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    224  view->setCancel("[ Zurueck ]", true);
    225  view->setConfirm("[ OK ]", &write_analog_output0);
    226  view->repaint();
    227 
    228  win_stack.push_back(view);
    229  input(0);
    230 }
    231 
    232 void show_analog_output1(int)
    233 {
    234  ViewPromt* view = new ViewPromt();
    235  view->setTitle("Analoge Ausgabe AA1");
    236  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    237  view->setCancel("[ Zurueck ]", true);
    238  view->setConfirm("[ OK ]", &write_analog_output1);
    239  view->repaint();
    240 
    241  win_stack.push_back(view);
    242  input(0);
    243 }
    244 
    245 void start_selftest(int)
    246 {
    247  B15F& drv = B15F::getInstance();
    248  drv.activateSelfTestMode();
    249 
    250  ViewInfo* view = new ViewInfo();
    251  view->setTitle("Selbsttest aktiv");
    252  view->setText("Das B15 befindet sich jetzt im Selbsttestmodus.\n \nSelbsttest:\nZu Beginn geht der Reihe nach jede LED von BA0 bis BA1 an.\nDanach leuchten die LEDs an AA0 und AA1 kurz auf.\nZum Schluss spiegelt in einer Endlosschleife:\n* BA0 Port BE0\n* BA1 die DIP-Schalter S7\n* AA0 ADC0\n* AA1 ADC1");
    253  view->setLabelClose("[ Selbsttest Beenden ]");
    254  view->setCall(&stop_selftest);
    255  view->repaint();
    256 
    257  win_stack.push_back(view);
    258  input(0);
    259 }
    260 
    261 void stop_selftest(int)
    262 {
    263  B15F& drv = B15F::getInstance();
    264  drv.discard();
    266  drv.reconnect();
    267  drv.digitalWrite0(0);
    268  drv.digitalWrite1(0);
    269 }
    270 
    271 void show_selftest_info(int)
    272 {
    273  ViewInfo* view = new ViewInfo();
    274  view->setTitle("Selbsttest");
    275  view->setText("Bitte entfernen Sie jetzt alle Draehte von den Anschlussklemmen und bestaetigen\nmit Enter.");
    276  view->setLabelClose("[ Weiter ]");
    277  view->setCall(&start_selftest);
    278  view->repaint();
    279 
    280  win_stack.push_back(view);
    281  input(0);
    282 }
    + + +
    void delay_ms(uint16_t ms)
    Definition: b15f.cpp:432
    +
    static B15F & getInstance(void)
    Definition: b15f.cpp:442
    +
    Definition: b15f.h:31
    +
    bool digitalWrite0(uint8_t)
    Definition: b15f.cpp:179
    +
    bool activateSelfTestMode(void)
    Definition: b15f.cpp:166
    + +
    bool analogWrite1(uint16_t port)
    Definition: b15f.cpp:264
    + +
    bool digitalWrite1(uint8_t)
    Definition: b15f.cpp:193
    void discard(void)
    Definition: b15f.cpp:72
    -
    bool analogWrite0(uint16_t)
    Definition: b15f.cpp:199
    +
    constexpr static uint16_t WDT_TIMEOUT
    Time in ms after which the watch dog timer resets the MCU.
    Definition: b15f.h:241
    void reconnect(void)
    Definition: b15f.cpp:57
    +
    bool analogWrite0(uint16_t port)
    Definition: b15f.cpp:249
    diff --git a/docs/html/ui_8h_source.html b/docs/html/ui_8h_source.html index 4edb2a9..ee5e268 100644 --- a/docs/html/ui_8h_source.html +++ b/docs/html/ui_8h_source.html @@ -73,7 +73,7 @@ $(function() {
    1 #ifndef UI_H
    2 #define UI_H
    3 
    4 #include <vector>
    5 #include "view_selection.h"
    6 #include "view_info.h"
    7 #include "view_monitor.h"
    8 #include "view_promt.h"
    9 
    10 void show_main(int);
    11 void input(int);
    12 void view_back(int);
    13 void finish(int);
    14 void cleanup();
    15 
    16 void show_info(int);
    17 void show_monitor(int);
    18 void show_invalid_port_input(int);
    19 void show_invalid_dac_input(int);
    20 void write_digital_output0(int);
    21 void write_digital_output1(int);
    22 void write_analog_output0(int);
    23 void write_analog_output1(int);
    24 void show_digital_output0(int);
    25 void show_digital_output1(int);
    26 void show_analog_output0(int);
    27 void show_analog_output1(int);
    28 
    29 // selftest group
    30 void show_selftest_info(int);
    31 void start_selftest(int);
    32 void stop_selftest(int);
    33 
    34 
    35 extern std::vector<View*> win_stack;
    36 extern std::thread t_refresh;
    37 
    38 #endif // UI_H
    diff --git a/docs/html/usart_8cpp_source.html b/docs/html/usart_8cpp_source.html index 87f2c09..2fd9eec 100644 --- a/docs/html/usart_8cpp_source.html +++ b/docs/html/usart_8cpp_source.html @@ -70,26 +70,25 @@ $(function() {
    usart.cpp
    -
    1 #include "usart.h"
    2 
    3 void USART::openDevice(std::string device)
    4 {
    5  file_desc = open(device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY /* | O_NONBLOCK*/);
    6  if(file_desc <= 0)
    7  throw USARTException("Fehler beim Öffnen des Gerätes");
    8 
    9  struct termios options;
    10  int code = tcgetattr(file_desc, &options);
    11  if(code)
    12  throw USARTException("Fehler beim Lesen der Geräteparameter");
    13 
    14  options.c_cflag = CS8 | CLOCAL | CREAD;
    15  options.c_iflag = IGNPAR;
    16  options.c_oflag = 0;
    17  options.c_lflag = 0;
    18  options.c_cc[VMIN] = 0; // #bytes read returns at least
    19  options.c_cc[VTIME] = timeout;
    20  code = cfsetspeed(&options, baudrate);
    21  if(code)
    22  throw USARTException("Fehler beim Setzen der Baudrate");
    23 
    24  code = tcsetattr(file_desc, TCSANOW, &options);
    25  if(code)
    26  throw USARTException("Fehler beim Setzen der Geräteparameter");
    27 
    30 }
    31 
    33 {
    34  int code = close(file_desc);
    35  if(code)
    36  throw USARTException("Fehler beim Schließen des Gerätes");
    37 }
    38 
    40 {
    41  int code = tcflush(file_desc, TCIFLUSH);
    42  if(code)
    43  throw USARTException("Fehler beim Leeren des Eingangspuffers");
    44 }
    45 
    47 {
    48  int code = tcflush(file_desc, TCOFLUSH);
    49  if(code)
    50  throw USARTException("Fehler beim Leeren des Ausgangspuffers");
    51 }
    52 
    54 {
    55  int code = tcdrain(file_desc);
    56  if(code)
    57  throw USARTException("Fehler beim Versenden des Ausgangspuffers");
    58 }
    59 
    61 {
    62  double pz = 1e2 * n_blocks_failed / n_blocks_total;
    63  pz = std::round(pz * 1e2) / 1e2;
    64  std::cout << "blocks total: " << n_blocks_total << " ok: " << (n_blocks_total - n_blocks_failed) << " failed: " << n_blocks_failed << " (" << pz << "%)" << std::endl;
    65 }
    66 
    67 void USART::writeByte(uint8_t b)
    68 {
    69  int sent = write(file_desc, &b, 1);
    70  if(sent != 1)
    71  {
    72  std::cout << "WARNUNG: Fehler beim Senden (" << sent << "): writeByte(), wiederhole..." << std::endl;
    73  usleep(100000);
    74  sent = write(file_desc, &b, 1);
    75  if(sent != 1)
    76  throw USARTException("Fehler beim Senden: writeByte()");
    77  }
    78 
    79 }
    80 
    81 void USART::writeInt(uint16_t d)
    82 {
    83  int sent = write(file_desc, reinterpret_cast<char*>(&d), 2);
    84  if(sent != 2)
    85  throw USARTException("Fehler beim Senden: writeInt()");
    86 }
    87 
    88 
    89 
    90 int USART::read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout)
    91 {
    92  uint32_t elapsed = 0;
    93  int n_read = -1;
    94  auto start = std::chrono::steady_clock::now();
    95  auto end = start;
    96  while(elapsed < timeout)
    97  {
    98  n_read = read(file_desc, buffer + offset, len);
    99  if (n_read == len)
    100  return n_read;
    101 
    102  end = std::chrono::steady_clock::now();
    103  elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
    104  }
    105 
    106  return 0;
    107 }
    108 
    109 int USART::write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout)
    110 {
    111  uint32_t elapsed = 0;
    112  int n_sent = -1;
    113  auto start = std::chrono::steady_clock::now();
    114  auto end = start;
    115  while(elapsed < timeout)
    116  {
    117  n_sent = write(file_desc, buffer + offset, len);
    119  if (n_sent == len)
    120  return n_sent;
    121 
    122  end = std::chrono::steady_clock::now();
    123  elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
    124  }
    125 
    126  return n_sent;
    127 }
    128 
    129 void USART::writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len)
    130 {
    131  uint8_t crc;
    132  uint8_t aw;
    133  const uint16_t us_per_bit = (1000000 / baudrate) * 16;
    134  const uint16_t n_total = len + 3;
    135 
    136  n_blocks_total++;
    137  bool failed = false;
    138 
    139  do
    140  {
    141  // calc crc
    142  crc = 0;
    143  for(uint8_t i = 0; i < len; i++)
    144  {
    145  crc ^= buffer[i];
    146  for (uint8_t k = 0; k < 8; k++)
    147  {
    148  if (crc & 1)
    149  crc ^= CRC7_POLY;
    150  crc >>= 1;
    151  }
    152  }
    153 
    154  // construct block
    155  block_buffer[0] = len;
    156  std::memcpy(&block_buffer[1], buffer + offset, len);
    157  block_buffer[len + 1] = crc;
    158  block_buffer[len + 2] = BLOCK_END;
    159 
    160  // send block
    163  int n_sent = write_timeout(&block_buffer[0], 0, len + 3, us_per_bit * n_total);
    164  if(n_sent != n_total)
    165  throw std::runtime_error("fatal (send): " + std::to_string(n_sent));
    166 
    167  /*for(uint8_t i = 0; i < len + 3; i++)
    168  {
    169  write_timeout(&block_buffer[i], 0, 1, us_per_bit * n_total);
    170  //tcdrain(file_desc);
    171  //usleep(1000);
    172  }*/
    173 
    174  // flush output data
    175  tcdrain(file_desc);
    176 
    177  //usleep(us_per_bit * n_total * 10);
    178 
    179  // check response
    180  int n_read = read_timeout(&aw, 0, 1, us_per_bit * n_blocks_total * 10);
    181  for(uint16_t i = 0; i < 255 && n_read != 1; i++)
    182  {
    183  writeByte(0x80); // Stoppzeichen für Block
    184  if(tcdrain(file_desc))
    185  {
    186  std::cout << "drain failed" << std::endl;
    187  }
    188  std::cout << "WARNING: read error (" << n_read << "), retry #" << (int) i << std::endl;
    189  usleep(us_per_bit*100);
    190  n_read = read_timeout(&aw, 0, 1, us_per_bit);
    191  }
    192 
    193  if(n_read != 1)
    194  throw std::runtime_error("fatal: " + std::to_string(n_read));
    195 
    196  //clearInputBuffer();
    197 
    198  if(aw != 0xFF) {
    199  if(!failed)
    200  n_blocks_failed++;
    201  failed = true;
    202  std::cout << "block failed, retry" << std::endl;
    203  }
    204  }
    205  while(aw != 0xFF);
    206 
    207  //std::cout << "OK" << std::endl;
    208 }
    209 
    210 uint8_t USART::readByte(void)
    211 {
    212  char b;
    213  auto start = std::chrono::steady_clock::now();
    214  auto end = start;
    215  uint16_t elapsed = 0;
    216  while(elapsed < timeout * 100)
    217  {
    218  int code = read(file_desc, &b, 1);
    219  if (code > 0)
    220  return static_cast<uint8_t>(b);
    221 
    222  end = std::chrono::steady_clock::now();
    223  elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    224  }
    225 
    226  throw TimeoutException("Verbindung unterbrochen.", timeout);
    227 }
    228 
    229 uint16_t USART::readInt(void)
    230 {
    231  return readByte() | readByte() << 8;
    232 }
    233 
    234 bool USART::readBlock(uint8_t* buffer, uint16_t offset)
    235 {
    236  uint8_t len = readByte();
    237  uint8_t crc = 0;
    238  buffer += offset;
    239 
    240  uint32_t block_timeout = timeout / 10;
    241 
    242  // wait for block
    243  int n_ready;
    244  uint16_t elapsed = 0;
    245  auto start = std::chrono::steady_clock::now();
    246  auto end = start;
    247  while(elapsed < block_timeout)
    248  {
    249  int code = ioctl(file_desc, FIONREAD, &n_ready);
    250  if(code != 0)
    251  {
    252  std::cout << "n_ready code: " << code << std::endl;
    253  return false;
    254  }
    255 
    256  if(n_ready >= len + 1)
    257  break;
    258 
    259  end = std::chrono::steady_clock::now();
    260  elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    261  }
    262  if(elapsed >= timeout)
    263  {
    264  std::cout << "block timeout: " << std::endl;
    265  return false;
    266  }
    267 
    268  while(len--)
    269  {
    270  *buffer = readByte();
    271 
    272  crc ^= *buffer++;
    273  for (uint8_t i = 0; i < 8; i++)
    274  {
    275  if (crc & 1)
    276  crc ^= CRC7_POLY;
    277  crc >>= 1;
    278  }
    279  }
    280 
    281  crc ^= readByte();
    282  for (uint8_t i = 0; i < 8; i++)
    283  {
    284  if (crc & 1)
    285  crc ^= CRC7_POLY;
    286  crc >>= 1;
    287  }
    288 
    289  if(TEST == 1)
    290  crc = 1;
    291  if(TEST > 100)
    292  TEST = 0;
    293 
    294  if (crc == 0)
    295  {
    296  writeByte(0xFF);
    297  return true;
    298  }
    299  else
    300  {
    301  writeByte(0xFE);
    302  return false;
    303  }
    304 }
    305 
    307 {
    308  return baudrate;
    309 }
    310 
    312 {
    313  return timeout;
    314 }
    315 
    316 void USART::setBaudrate(uint32_t baudrate)
    317 {
    318  this->baudrate = baudrate;
    319 }
    320 
    321 void USART::setTimeout(uint8_t timeout)
    322 {
    323  this->timeout = timeout;
    324 }
    -
    uint32_t getBaudrate(void)
    Definition: usart.cpp:306
    -
    uint8_t readByte(void)
    Definition: usart.cpp:210
    +
    1 #include <stdexcept>
    2 #include "usart.h"
    3 
    5 {
    6  closeDevice();
    7 }
    8 
    9 void USART::openDevice(std::string device)
    10 {
    11  // Benutze blockierenden Modus
    12  file_desc = open(device.c_str(), O_RDWR | O_NOCTTY);// | O_NDELAY
    13  if (file_desc <= 0)
    14  throw USARTException("Fehler beim Öffnen des Gerätes");
    15 
    16  struct termios options;
    17  int code = tcgetattr(file_desc, &options);
    18  if (code)
    19  throw USARTException("Fehler beim Lesen der Geräteparameter");
    20 
    21  options.c_cflag = CS8 | CLOCAL | CREAD;
    22  options.c_iflag = IGNPAR;
    23  options.c_oflag = 0;
    24  options.c_lflag = 0;
    25  options.c_cc[VMIN] = 0;
    26  options.c_cc[VTIME] = timeout;
    27  code = cfsetspeed(&options, baudrate);
    28  if (code)
    29  throw USARTException("Fehler beim Setzen der Baudrate");
    30 
    31  code = tcsetattr(file_desc, TCSANOW, &options);
    32  if (code)
    33  throw USARTException("Fehler beim Setzen der Geräteparameter");
    34 
    35  code = fcntl(file_desc, F_SETFL, 0); // blockierender Modus
    36  if (code)
    37  throw USARTException("Fehler beim Aktivieren des blockierenden Modus'");
    38 
    41 }
    42 
    44 {
    45  if (file_desc > 0)
    46  {
    47  int code = close(file_desc);
    48  if (code)
    49  throw USARTException("Fehler beim Schließen des Gerätes");
    50  file_desc = -1;
    51  }
    52 }
    53 
    55 {
    56  int code = tcflush(file_desc, TCIFLUSH);
    57  if (code)
    58  throw USARTException("Fehler beim Leeren des Eingangspuffers");
    59 }
    60 
    62 {
    63  int code = tcflush(file_desc, TCOFLUSH);
    64  if (code)
    65  throw USARTException("Fehler beim Leeren des Ausgangspuffers");
    66 }
    67 
    69 {
    70  int code = tcdrain(file_desc);
    71  if (code)
    72  throw USARTException("Fehler beim Versenden des Ausgangspuffers");
    73 }
    74 
    75 void USART::transmit(uint8_t *buffer, uint16_t offset, uint8_t len)
    76 {
    77  int code = write(file_desc, buffer + offset, len);
    78  if (code != len)
    79  throw USARTException(
    80  std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) +
    81  ", " + strerror(code) + " (code " + std::to_string(code) + " / " + std::to_string(len) + ")");
    82 }
    83 
    84 void USART::receive(uint8_t *buffer, uint16_t offset, uint8_t len)
    85 {
    86  int bytes_avail, code;
    87  auto start = std::chrono::steady_clock::now();
    88  auto end = std::chrono::steady_clock::now();
    89  do
    90  {
    91  code = ioctl(file_desc, FIONREAD, &bytes_avail);
    92  if (code)
    93  throw USARTException(
    94  std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) +
    95  ", " + strerror(code) + " (code " + std::to_string(code) + ")");
    96 
    97  end = std::chrono::steady_clock::now();
    98  long elapsed =
    99  std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 100; // in Dezisekunden
    100  if (elapsed >= timeout)
    101  throw TimeoutException(
    102  std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) +
    103  ", " + std::to_string(elapsed) + " / " + std::to_string(timeout) + " ds");
    104  }
    105  while (bytes_avail < len);
    106 
    107  code = read(file_desc, buffer + offset, len);
    108  if (code != len)
    109  throw USARTException(
    110  std::string(__FUNCTION__) + " failed: " + std::string(__FILE__) + "#" + std::to_string(__LINE__) +
    111  ", " + strerror(code) + " (code " + std::to_string(code) + " / " + std::to_string(len) + ")");
    112 }
    113 
    114 void USART::drop(uint8_t len)
    115 {
    116  // Kann bestimmt noch eleganter gelöst werden
    117  uint8_t dummy[len];
    118  receive(&dummy[0], 0, len);
    119 }
    120 
    122 {
    123  return baudrate;
    124 }
    125 
    127 {
    128  return timeout;
    129 }
    130 
    131 void USART::setBaudrate(uint32_t baudrate)
    132 {
    133  this->baudrate = baudrate;
    134 }
    135 
    136 void USART::setTimeout(uint8_t timeout)
    137 {
    138  this->timeout = timeout;
    139 }
    +
    uint32_t getBaudrate(void)
    Definition: usart.cpp:121
    -
    void printStatistics(void)
    Definition: usart.cpp:60
    -
    void closeDevice(void)
    Definition: usart.cpp:32
    -
    void clearInputBuffer(void)
    Definition: usart.cpp:39
    -
    uint8_t getTimeout(void)
    Definition: usart.cpp:311
    -
    void clearOutputBuffer(void)
    Definition: usart.cpp:46
    -
    void setBaudrate(uint32_t baudrate)
    Definition: usart.cpp:316
    -
    void writeByte(uint8_t b)
    Definition: usart.cpp:67
    -
    void openDevice(std::string device)
    Definition: usart.cpp:3
    -
    uint16_t readInt(void)
    Definition: usart.cpp:229
    -
    void setTimeout(uint8_t timeout)
    Definition: usart.cpp:321
    -
    void flushOutputBuffer(void)
    Definition: usart.cpp:53
    - -
    void writeInt(uint16_t d)
    Definition: usart.cpp:81
    +
    void closeDevice(void)
    Definition: usart.cpp:43
    +
    void transmit(uint8_t *buffer, uint16_t offset, uint8_t len)
    Definition: usart.cpp:75
    +
    void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
    Definition: usart.cpp:84
    +
    void clearInputBuffer(void)
    Definition: usart.cpp:54
    +
    uint8_t getTimeout(void)
    Definition: usart.cpp:126
    +
    void clearOutputBuffer(void)
    Definition: usart.cpp:61
    +
    void setBaudrate(uint32_t baudrate)
    Definition: usart.cpp:131
    +
    virtual ~USART(void)
    Definition: usart.cpp:4
    +
    void openDevice(std::string device)
    Definition: usart.cpp:9
    +
    void drop(uint8_t len)
    Definition: usart.cpp:114
    +
    void setTimeout(uint8_t timeout)
    Definition: usart.cpp:136
    +
    void flushOutputBuffer(void)
    Definition: usart.cpp:68
    + diff --git a/docs/html/usart_8h_source.html b/docs/html/usart_8h_source.html index 7c8572b..7406ff7 100644 --- a/docs/html/usart_8h_source.html +++ b/docs/html/usart_8h_source.html @@ -70,25 +70,25 @@ $(function() {
    usart.h
    -
    1 #ifndef USART_H
    2 #define USART_H
    3 
    4 #include <iostream>
    5 #include <cstdint>
    6 #include <chrono>
    7 #include <unistd.h>
    8 #include <cstring>
    9 #include <fcntl.h>
    10 #include <sys/ioctl.h>
    11 #include <termios.h>
    12 #include <cmath>
    13 #include "usartexception.h"
    14 #include "timeoutexception.h"
    15 
    16 class USART
    17 {
    18 public:
    19 
    20  /*************************************************
    21  * Methoden für die Verwaltung der Schnittstelle *
    22  *************************************************/
    23 
    29  void openDevice(std::string device);
    30 
    35  void closeDevice(void);
    36 
    41  void clearInputBuffer(void);
    42 
    47  void clearOutputBuffer(void);
    48 
    53  void flushOutputBuffer(void);
    54 
    58  void printStatistics(void);
    59 
    60  /*************************************************/
    61 
    62 
    63 
    64  /*************************************
    65  * Methoden für die Datenübertragung *
    66  *************************************/
    67 
    73  void writeByte(uint8_t b);
    74 
    80  void writeInt(uint16_t d);
    81 
    86  uint8_t readByte(void);
    87 
    92  uint16_t readInt(void);
    93 
    94  int read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout);
    95  int write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout);
    96  void writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len);
    97  bool readBlock(uint8_t* buffer, uint16_t offset);
    98 
    99  /*************************************/
    100 
    101 
    102 
    103  /***************************************
    104  * Methoden für einstellbare Parameter *
    105  ***************************************/
    106 
    111  uint32_t getBaudrate(void);
    112 
    117  uint8_t getTimeout(void);
    118 
    123  void setBaudrate(uint32_t baudrate);
    124 
    129  void setTimeout(uint8_t timeout);
    130 
    131  /***************************************/
    132 
    133  constexpr static uint8_t CRC7_POLY = 0x91;
    134  constexpr static uint8_t MAX_BLOCK_SIZE = 64;
    135  constexpr static uint8_t BLOCK_END = 0x80;
    136 private:
    137 
    138  int file_desc = -1; // Linux Dateideskriptor
    139  uint32_t baudrate = 9600; // Standard-Baudrate, sollte mit setBaudrate() überschrieben werden!
    140  int TEST = 0;
    141  uint8_t timeout = 10; // in Dezisekunden
    142  uint8_t block_buffer[MAX_BLOCK_SIZE + 3];
    143 
    144  // debug statistics
    145  uint32_t n_blocks_total = 0;
    146  uint32_t n_blocks_failed = 0;
    147 };
    148 
    149 
    150 #endif // USART_H
    -
    uint32_t getBaudrate(void)
    Definition: usart.cpp:306
    -
    uint8_t readByte(void)
    Definition: usart.cpp:210
    -
    void printStatistics(void)
    Definition: usart.cpp:60
    -
    void closeDevice(void)
    Definition: usart.cpp:32
    -
    void clearInputBuffer(void)
    Definition: usart.cpp:39
    -
    uint8_t getTimeout(void)
    Definition: usart.cpp:311
    +
    1 #ifndef USART_H
    2 #define USART_H
    3 
    4 #include <cstdint>
    5 #include <chrono>
    6 #include <fcntl.h>
    7 #include <unistd.h>
    8 #include <termios.h>
    9 #include <sys/ioctl.h>
    10 #include <string.h>
    11 #include "usartexception.h"
    12 #include "timeoutexception.h"
    13 
    16 class USART
    17 {
    18 public:
    19 
    20  /*************************************************
    21  * Methoden für die Verwaltung der Schnittstelle *
    22  *************************************************/
    23 
    27  explicit USART() = default;
    28 
    32  virtual ~USART(void);
    33 
    39  void openDevice(std::string device);
    40 
    45  void closeDevice(void);
    46 
    51  void clearInputBuffer(void);
    52 
    57  void clearOutputBuffer(void);
    58 
    63  void flushOutputBuffer(void);
    64 
    65  /*************************************************/
    66 
    67 
    68 
    69  /*************************************
    70  * Methoden für die Datenübertragung *
    71  *************************************/
    72 
    80  void transmit(uint8_t *buffer, uint16_t offset, uint8_t len);
    81 
    89  void receive(uint8_t *buffer, uint16_t offset, uint8_t len);
    90 
    96  void drop(uint8_t len);
    97 
    98  /*************************************/
    99 
    100 
    101 
    102  /***************************************
    103  * Methoden für einstellbare Parameter *
    104  ***************************************/
    105 
    110  uint32_t getBaudrate(void);
    111 
    116  uint8_t getTimeout(void);
    117 
    122  void setBaudrate(uint32_t baudrate);
    123 
    128  void setTimeout(uint8_t timeout);
    129 
    130  /***************************************/
    131 
    132 private:
    133 
    134  int file_desc = -1;
    135  uint32_t baudrate = 9600;
    136  uint8_t timeout = 10;
    137 };
    138 
    139 #endif // USART_H
    +
    uint32_t getBaudrate(void)
    Definition: usart.cpp:121
    +
    USART()=default
    +
    void closeDevice(void)
    Definition: usart.cpp:43
    +
    void transmit(uint8_t *buffer, uint16_t offset, uint8_t len)
    Definition: usart.cpp:75
    +
    void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
    Definition: usart.cpp:84
    +
    void clearInputBuffer(void)
    Definition: usart.cpp:54
    +
    uint8_t getTimeout(void)
    Definition: usart.cpp:126
    Definition: usart.h:16
    -
    void clearOutputBuffer(void)
    Definition: usart.cpp:46
    -
    void setBaudrate(uint32_t baudrate)
    Definition: usart.cpp:316
    -
    void writeByte(uint8_t b)
    Definition: usart.cpp:67
    -
    void openDevice(std::string device)
    Definition: usart.cpp:3
    -
    uint16_t readInt(void)
    Definition: usart.cpp:229
    -
    void setTimeout(uint8_t timeout)
    Definition: usart.cpp:321
    -
    void flushOutputBuffer(void)
    Definition: usart.cpp:53
    -
    void writeInt(uint16_t d)
    Definition: usart.cpp:81
    +
    void clearOutputBuffer(void)
    Definition: usart.cpp:61
    +
    void setBaudrate(uint32_t baudrate)
    Definition: usart.cpp:131
    +
    virtual ~USART(void)
    Definition: usart.cpp:4
    +
    void openDevice(std::string device)
    Definition: usart.cpp:9
    +
    void drop(uint8_t len)
    Definition: usart.cpp:114
    +
    void setTimeout(uint8_t timeout)
    Definition: usart.cpp:136
    +
    void flushOutputBuffer(void)
    Definition: usart.cpp:68
    diff --git a/docs/html/usartexception_8h_source.html b/docs/html/usartexception_8h_source.html index aa66137..11a9fea 100644 --- a/docs/html/usartexception_8h_source.html +++ b/docs/html/usartexception_8h_source.html @@ -70,11 +70,16 @@ $(function() {
    usartexception.h
    -
    1 #ifndef USARTEXCEPTION_H
    2 #define USARTEXCEPTION_H
    3 
    4 #include <exception>
    5 #include <string>
    6 
    7 // SOURCE: https://stackoverflow.com/a/8152888
    8 
    9 class USARTException: public std::exception
    10 {
    11 public:
    12  explicit USARTException(const char* message) : msg(message)
    13  {
    14  }
    15 
    16  explicit USARTException(const std::string& message) : msg(message)
    17  {
    18  }
    19 
    20  virtual ~USARTException() throw ()
    21  {
    22  }
    23 
    24  virtual const char* what() const throw ()
    25  {
    26  return msg.c_str();
    27  }
    28 
    29 protected:
    30  std::string msg;
    31 };
    32 
    33 #endif // USARTEXCEPTION_H
    +
    1 #ifndef USARTEXCEPTION_H
    2 #define USARTEXCEPTION_H
    3 
    4 #include <exception>
    5 #include <string>
    6 
    9 class USARTException: public std::exception
    10 {
    11 public:
    16  explicit USARTException(const char* message) : msg(message)
    17  {
    18  }
    19 
    24  explicit USARTException(const std::string& message) : msg(message)
    25  {
    26  }
    27 
    31  virtual ~USARTException() = default;
    32 
    37  virtual const char* what() const throw ()
    38  {
    39  return msg.c_str();
    40  }
    41 
    42 protected:
    43  std::string msg;
    44 };
    45 
    46 #endif // USARTEXCEPTION_H
    +
    USARTException(const char *message)
    +
    virtual const char * what() const
    +
    std::string msg
    failure description
    +
    USARTException(const std::string &message)
    +
    virtual ~USARTException()=default
    diff --git a/docs/html/view_8cpp_source.html b/docs/html/view_8cpp_source.html index bb203a4..229408d 100644 --- a/docs/html/view_8cpp_source.html +++ b/docs/html/view_8cpp_source.html @@ -70,11 +70,11 @@ $(function() {
    view.cpp
    -
    1 #include "view.h"
    2 
    3 WINDOW* View::win = nullptr;
    4 
    5 View::View()
    6 {
    7  if(!win)
    8  {
    9  B15F::abort("View::win not initialized, missing context");
    10  }
    11  getmaxyx(win, height, width); // init width and height
    12  keypad(win, TRUE);
    13 }
    14 
    15 View::~View()
    16 {
    17 }
    18 
    19 void View::setWinContext(WINDOW* win)
    20 {
    21  View::win = win;
    22 }
    23 
    24 WINDOW* View::getWinContext()
    25 {
    26  return win;
    27 }
    28 
    29 // from: https://stackoverflow.com/a/37454181
    30 std::vector<std::string> View::str_split(const std::string& str, const std::string delim)
    31 {
    32  std::vector<std::string> tokens;
    33  size_t prev = 0, pos = 0;
    34  do
    35  {
    36  pos = str.find(delim, prev);
    37  if (pos == std::string::npos) pos = str.length();
    38  std::string token = str.substr(prev, pos-prev);
    39  if (!token.empty()) tokens.push_back(token);
    40  prev = pos + delim.length();
    41  }
    42  while (pos < str.length() && prev < str.length());
    43  return tokens;
    44 }
    45 
    46 
    47 void View::setTitle(std::string title)
    48 {
    49  this->title = title;
    50 }
    51 
    52 void View::repaint()
    53 {
    54  // get screen size
    55  struct winsize size;
    56  if (ioctl(0, TIOCGWINSZ, (char *) &size) < 0)
    57  throw std::runtime_error("TIOCGWINSZ error");
    58 
    59 
    60  start_x = floor((size.ws_col - width) / 2.);
    61  start_y = floor((size.ws_row - height) / 2.);
    62 
    63  curs_set(0); // hide cursor
    64  mvwin(win, start_y, start_x);
    65  clear();
    66  wclear(win);
    67 
    68  // generic draw
    69  box(win, 0, 0);
    70  int offset_x = (width - title.length()) / 2;
    71  mvwprintw(win, 1, offset_x, "%s", title.c_str());
    72 
    73  // specific draw
    74  draw();
    75 
    76  refresh();
    77  wrefresh(win);
    78 }
    -
    static void abort(std::string msg)
    Definition: b15f.cpp:322
    +
    1 #include "view.h"
    2 
    3 WINDOW* View::win = nullptr;
    4 
    5 View::View()
    6 {
    7  if(!win)
    8  {
    9  B15F::abort("View::win not initialized, missing context");
    10  }
    11  getmaxyx(win, height, width); // init width and height
    12  keypad(win, TRUE);
    13 }
    14 
    15 View::~View()
    16 {
    17 }
    18 
    19 void View::setWinContext(WINDOW* win)
    20 {
    21  View::win = win;
    22 }
    23 
    24 WINDOW* View::getWinContext()
    25 {
    26  return win;
    27 }
    28 
    29 // from: https://stackoverflow.com/a/37454181
    30 std::vector<std::string> View::str_split(const std::string& str, const std::string delim)
    31 {
    32  std::vector<std::string> tokens;
    33  size_t prev = 0, pos = 0;
    34  do
    35  {
    36  pos = str.find(delim, prev);
    37  if (pos == std::string::npos) pos = str.length();
    38  std::string token = str.substr(prev, pos-prev);
    39  if (!token.empty()) tokens.push_back(token);
    40  prev = pos + delim.length();
    41  }
    42  while (pos < str.length() && prev < str.length());
    43  return tokens;
    44 }
    45 
    46 
    47 void View::setTitle(std::string title)
    48 {
    49  this->title = title;
    50 }
    51 
    52 void View::repaint()
    53 {
    54  // get screen size
    55  struct winsize size;
    56  if (ioctl(0, TIOCGWINSZ, (char *) &size) < 0)
    57  throw std::runtime_error("TIOCGWINSZ error");
    58 
    59 
    60  start_x = floor((size.ws_col - width) / 2.);
    61  start_y = floor((size.ws_row - height) / 2.);
    62 
    63  curs_set(0); // hide cursor
    64  mvwin(win, start_y, start_x);
    65  clear();
    66  wclear(win);
    67 
    68  // generic draw
    69  box(win, 0, 0);
    70  int offset_x = (width - title.length()) / 2;
    71  mvwprintw(win, 1, offset_x, "%s", title.c_str());
    72 
    73  // specific draw
    74  draw();
    75 
    76  refresh();
    77  wrefresh(win);
    78 }
    +
    static void abort(std::string msg)
    Definition: b15f.cpp:467
    diff --git a/docs/html/view_8h_source.html b/docs/html/view_8h_source.html index 0cdb246..eb93903 100644 --- a/docs/html/view_8h_source.html +++ b/docs/html/view_8h_source.html @@ -70,11 +70,11 @@ $(function() {
    view.h
    -
    1 #ifndef VIEW_H
    2 #define VIEW_H
    3 
    4 #include <iostream>
    5 #include <cmath>
    6 #include <vector>
    7 #include <functional>
    8 #include <ncurses.h> // sudo apt-get install libncurses5-dev
    9 #include <sys/ioctl.h>
    10 #include <unistd.h>
    11 #include <signal.h>
    12 #include "../drv/b15f.h"
    13 
    14 extern std::string ERR_MSG;
    15 typedef std::function<void(int)> call_t;
    16 
    17 class View
    18 {
    19 public:
    20  View(void);
    21  virtual ~View(void);
    22 
    23  static void setWinContext(WINDOW* win);
    24  static WINDOW* getWinContext(void);
    25  static std::vector<std::string> str_split(const std::string& str, const std::string delim);
    26 
    27  virtual void setTitle(std::string title);
    28 
    29  virtual void repaint(void);
    30 
    31  virtual void draw(void) = 0;
    32  virtual call_t keypress(int& key) = 0;
    33 
    34 
    35 protected:
    36  int width, height;
    37  int start_x = 0, start_y = 0;
    38  std::string title;
    39  std::vector<call_t> calls;
    40 
    41  static WINDOW* win;
    42  constexpr static int KEY_ENT = 10;
    43 };
    44 
    45 #endif // VIEW_H
    -
    Definition: view.h:17
    +
    1 #ifndef VIEW_H
    2 #define VIEW_H
    3 
    4 #include <iostream>
    5 #include <cmath>
    6 #include <vector>
    7 #include <functional>
    8 #include <ncurses.h> // sudo apt-get install libncurses5-dev
    9 #include <sys/ioctl.h>
    10 #include <unistd.h>
    11 #include <signal.h>
    12 #include "../drv/b15f.h"
    13 
    14 extern std::string ERR_MSG;
    15 typedef std::function<void(int)> call_t;
    16 
    19 class View
    20 {
    21 public:
    22  View(void);
    23  virtual ~View(void);
    24 
    25  static void setWinContext(WINDOW* win);
    26  static WINDOW* getWinContext(void);
    27  static std::vector<std::string> str_split(const std::string& str, const std::string delim);
    28 
    29  virtual void setTitle(std::string title);
    30 
    31  virtual void repaint(void);
    32 
    33  virtual void draw(void) = 0;
    34  virtual call_t keypress(int& key) = 0;
    35 
    36 
    37 protected:
    38  int width, height;
    39  int start_x = 0, start_y = 0;
    40  std::string title;
    41  std::vector<call_t> calls;
    42 
    43  static WINDOW* win;
    44  constexpr static int KEY_ENT = 10;
    45 };
    46 
    47 #endif // VIEW_H
    +
    Definition: view.h:19
    diff --git a/docs/html/view__info_8cpp_source.html b/docs/html/view__info_8cpp_source.html index aaf6b4c..918aa93 100644 --- a/docs/html/view__info_8cpp_source.html +++ b/docs/html/view__info_8cpp_source.html @@ -70,10 +70,10 @@ $(function() {
    view_info.cpp
    -
    1 #include "view_info.h"
    2 
    3 ViewInfo::ViewInfo()
    4 {
    5  calls.push_back(nullptr);
    6 }
    7 
    8 void ViewInfo::setText(std::string text)
    9 {
    10  this->text = text;
    11 }
    12 
    13 void ViewInfo::setLabelClose(std::string label)
    14 {
    15  this->label_close = label;
    16 }
    17 
    18 void ViewInfo::setCall(call_t call)
    19 {
    20  calls[0] = call;
    21 }
    22 
    23 void ViewInfo::draw()
    24 {
    25  int li = 0;
    26  for(std::string line : str_split(text, "\n"))
    27  mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str());
    28 
    29  close_offset_x = (width - label_close.length()) / 2;
    30  close_offset_y = height - 2;
    31 
    32  wattron(win, A_REVERSE);
    33  mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str());
    34  wattroff(win, A_REVERSE);
    35 }
    36 
    37 call_t ViewInfo::keypress(int& key)
    38 {
    39  switch(key)
    40  {
    41 
    42  case KEY_MOUSE:
    43  {
    44  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    45  MEVENT event;
    46  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    47  {
    48  size_t column = start_x + close_offset_x;
    49  size_t row = start_y + close_offset_y;
    50  size_t mouse_x = event.x, mouse_y = event.y;
    51  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
    52  key = -1; // do return from view
    53  }
    54  break;
    55  }
    56  case KEY_ENT:
    57  key = -1; // do return from view
    58  break;
    59  default:
    60  break;
    61  }
    62  return calls[0];
    63 }
    +
    1 #include "view_info.h"
    2 
    3 ViewInfo::ViewInfo()
    4 {
    5  calls.push_back(nullptr);
    6 }
    7 
    8 void ViewInfo::setText(std::string text)
    9 {
    10  this->text = text;
    11 }
    12 
    13 void ViewInfo::setLabelClose(std::string label)
    14 {
    15  this->label_close = label;
    16 }
    17 
    18 void ViewInfo::setCall(call_t call)
    19 {
    20  calls[0] = call;
    21 }
    22 
    23 void ViewInfo::draw()
    24 {
    25  int li = 0;
    26  for(std::string line : str_split(text, "\n"))
    27  mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str());
    28 
    29  close_offset_x = (width - label_close.length()) / 2;
    30  close_offset_y = height - 2;
    31 
    32  wattron(win, A_REVERSE);
    33  mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str());
    34  wattroff(win, A_REVERSE);
    35 }
    36 
    37 call_t ViewInfo::keypress(int& key)
    38 {
    39  switch(key)
    40  {
    41 
    42  case KEY_MOUSE:
    43  {
    44  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    45  MEVENT event;
    46  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    47  {
    48  size_t column = start_x + close_offset_x;
    49  size_t row = start_y + close_offset_y;
    50  size_t mouse_x = event.x, mouse_y = event.y;
    51  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
    52  key = -1; // do return from view
    53  }
    54  break;
    55  }
    56  case KEY_ENT:
    57  key = -1; // do return from view
    58  break;
    59  default:
    60  break;
    61  }
    62  return calls[0];
    63 }
    diff --git a/docs/html/view__info_8h_source.html b/docs/html/view__info_8h_source.html index 0cdd6e1..512d90e 100644 --- a/docs/html/view__info_8h_source.html +++ b/docs/html/view__info_8h_source.html @@ -70,12 +70,12 @@ $(function() {
    view_info.h
    -
    1 #ifndef VIEW_INFO
    2 #define VIEW_INFO
    3 
    4 #include "view.h"
    5 
    6 class ViewInfo : public View
    7 {
    8 public:
    9  ViewInfo(void);
    10  virtual void setText(std::string text);
    11  virtual void setLabelClose(std::string label);;
    12  virtual void setCall(call_t call);
    13  virtual void draw(void) override;
    14  virtual call_t keypress(int& key) override;
    15 
    16 protected:
    17  std::string text;
    18  std::string label_close;
    19  int close_offset_x = 0;
    20  int close_offset_y = 0;
    21  constexpr static int text_offset_x = 2;
    22  constexpr static int text_offset_y = 3;
    23 };
    24 
    25 #endif // VIEW_INFO
    - -
    Definition: view.h:17
    +
    1 #ifndef VIEW_INFO
    2 #define VIEW_INFO
    3 
    4 #include "view.h"
    5 
    8 class ViewInfo : public View
    9 {
    10 public:
    11  ViewInfo(void);
    12  virtual void setText(std::string text);
    13  virtual void setLabelClose(std::string label);;
    14  virtual void setCall(call_t call);
    15  virtual void draw(void) override;
    16  virtual call_t keypress(int& key) override;
    17 
    18 protected:
    19  std::string text;
    20  std::string label_close;
    21  int close_offset_x = 0;
    22  int close_offset_y = 0;
    23  constexpr static int text_offset_x = 2;
    24  constexpr static int text_offset_y = 3;
    25 };
    26 
    27 #endif // VIEW_INFO
    + +
    Definition: view.h:19
    diff --git a/docs/html/view__monitor_8cpp_source.html b/docs/html/view__monitor_8cpp_source.html index 4513007..c1bb49e 100644 --- a/docs/html/view__monitor_8cpp_source.html +++ b/docs/html/view__monitor_8cpp_source.html @@ -70,21 +70,21 @@ $(function() {
    view_monitor.cpp
    -
    1 #include "view_monitor.h"
    2 
    3 ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this)
    4 {
    5 }
    6 
    7 call_t ViewMonitor::keypress(int& key)
    8 {
    9  switch(key)
    10  {
    11 
    12  case KEY_MOUSE:
    13  {
    14  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    15  MEVENT event;
    16  bool hit = false;
    17  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    18  {
    19  size_t column = start_x + close_offset_x;
    20  size_t row = start_y + close_offset_y;
    21  size_t mouse_x = event.x, mouse_y = event.y;
    22  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
    23  hit = true;
    24  }
    25  if(!hit)
    26  break;
    27 
    28  // fall through to next case
    29  [[fallthrough]];
    30  }
    31  case KEY_ENT:
    32  run_worker = false;
    33  key = -1; // do return from view
    34  wclear(win);
    35  wrefresh(win);
    36  t_worker.join();
    37  break;
    38  default:
    39  break;
    40  }
    41  return calls[0];
    42 }
    43 
    44 std::string ViewMonitor::fancyDigitalString(uint8_t& b)
    45 {
    46  std::stringstream str;
    47  str << std::bitset<8>(b).to_string();
    48  str << " ";
    49  str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
    50  return str.str();
    51 }
    52 
    53 std::string ViewMonitor::fancyAnalogString(uint16_t& v)
    54 {
    55  std::stringstream str;
    56  double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0;
    57 
    58  str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V ";
    59 
    60  str << "[";
    61  uint8_t p = round(v * 40.0 / 1023.0);
    62  for(uint8_t i = 0; i < p; i++)
    63  str << "X";
    64  for(uint8_t i = 0; i < 40 - p; i++)
    65  str << " ";
    66  str << "]" << std::endl;
    67 
    68  return str.str();
    69 }
    70 
    71 void ViewMonitor::worker()
    72 {
    73  B15F& drv = B15F::getInstance();
    74  while(run_worker)
    75  {
    76  try
    77  {
    78  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    79 
    80  uint8_t be0 = drv.digitalRead0();
    81  uint8_t be1 = drv.digitalRead1();
    82  uint8_t dsw = drv.readDipSwitch();
    83  uint16_t adc[8];
    84  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    85  adc[i] = drv.analogRead(i);
    86 
    87 
    88  std::stringstream str;
    89 
    90  // hline
    91  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    92  if(i % 2 == 0)
    93  str << "-";
    94  else
    95  str << " ";
    96  str << std::endl;
    97 
    98  str << "Digitale Enigaenge:" << std::endl;
    99  str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl;
    100  str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl;
    101  str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl;
    102 
    103  // hline
    104  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    105  if(i % 2 == 0)
    106  str << "-";
    107  else
    108  str << " ";
    109  str << std::endl;
    110 
    111  str << "Analoge Eingaenge:" << std::endl;
    112  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    113  {
    114  str << "Kanal " << std::to_string((int) i) << ": ";
    115  str << fancyAnalogString(adc[i]) << std::endl;
    116  }
    117 
    118  text = str.str();
    119  repaint();
    120  }
    121  catch(DriverException& ex)
    122  {
    123  std::cout << "DriverException: " << ex.what() << std::endl;
    124  drv.delay_ms(1000);
    125  }
    126  catch(...)
    127  {
    128  try
    129  {
    130  drv.reconnect();
    131  }
    132  catch(...)
    133  {
    134  B15F::abort("yoho meine dudes");
    135  return;
    136  }
    137  }
    138  }
    139 }
    - -
    uint8_t digitalRead0(void)
    Definition: b15f.cpp:172
    -
    uint8_t readDipSwitch(void)
    Definition: b15f.cpp:190
    -
    void delay_ms(uint16_t ms)
    Definition: b15f.cpp:290
    -
    static B15F & getInstance(void)
    Definition: b15f.cpp:300
    -
    Definition: b15f.h:24
    -
    static void abort(std::string msg)
    Definition: b15f.cpp:322
    -
    uint16_t analogRead(uint8_t channel)
    Definition: b15f.cpp:219
    -
    uint8_t digitalRead1(void)
    Definition: b15f.cpp:181
    +
    1 #include "view_monitor.h"
    2 
    3 ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this)
    4 {
    5 }
    6 
    7 call_t ViewMonitor::keypress(int& key)
    8 {
    9  switch(key)
    10  {
    11 
    12  case KEY_MOUSE:
    13  {
    14  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    15  MEVENT event;
    16  bool hit = false;
    17  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    18  {
    19  size_t column = start_x + close_offset_x;
    20  size_t row = start_y + close_offset_y;
    21  size_t mouse_x = event.x, mouse_y = event.y;
    22  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
    23  hit = true;
    24  }
    25  if(!hit)
    26  break;
    27 
    28  // fall through to next case
    29  [[fallthrough]];
    30  }
    31  case KEY_ENT:
    32  run_worker = false;
    33  key = -1; // do return from view
    34  wclear(win);
    35  wrefresh(win);
    36  t_worker.join();
    37  break;
    38  default:
    39  break;
    40  }
    41  return calls[0];
    42 }
    43 
    44 std::string ViewMonitor::fancyDigitalString(uint8_t& b)
    45 {
    46  std::stringstream str;
    47  str << std::bitset<8>(b).to_string();
    48  str << " ";
    49  str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
    50  return str.str();
    51 }
    52 
    53 std::string ViewMonitor::fancyAnalogString(uint16_t& v)
    54 {
    55  std::stringstream str;
    56  double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0;
    57 
    58  str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V ";
    59 
    60  str << "[";
    61  uint8_t p = round(v * 40.0 / 1023.0);
    62  for(uint8_t i = 0; i < p; i++)
    63  str << "X";
    64  for(uint8_t i = 0; i < 40 - p; i++)
    65  str << " ";
    66  str << "]" << std::endl;
    67 
    68  return str.str();
    69 }
    70 
    71 void ViewMonitor::worker()
    72 {
    73  B15F& drv = B15F::getInstance();
    74  while(run_worker)
    75  {
    76  try
    77  {
    78  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    79 
    80  uint8_t be0 = drv.digitalRead0();
    81  uint8_t be1 = drv.digitalRead1();
    82  uint8_t dsw = drv.readDipSwitch();
    83  uint16_t adc[8];
    84  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    85  adc[i] = drv.analogRead(i);
    86 
    87 
    88  std::stringstream str;
    89 
    90  // hline
    91  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    92  if(i % 2 == 0)
    93  str << "-";
    94  else
    95  str << " ";
    96  str << std::endl;
    97 
    98  str << "Digitale Enigaenge:" << std::endl;
    99  str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl;
    100  str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl;
    101  str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl;
    102 
    103  // hline
    104  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    105  if(i % 2 == 0)
    106  str << "-";
    107  else
    108  str << " ";
    109  str << std::endl;
    110 
    111  str << "Analoge Eingaenge:" << std::endl;
    112  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    113  {
    114  str << "Kanal " << std::to_string((int) i) << ": ";
    115  str << fancyAnalogString(adc[i]) << std::endl;
    116  }
    117 
    118  text = str.str();
    119  repaint();
    120  }
    121  catch(DriverException& ex)
    122  {
    123  std::cout << "DriverException: " << ex.what() << std::endl;
    124  drv.delay_ms(1000);
    125  }
    126  catch(...)
    127  {
    128  try
    129  {
    130  drv.reconnect();
    131  }
    132  catch(...)
    133  {
    134  B15F::abort("yoho meine dudes");
    135  return;
    136  }
    137  }
    138  }
    139 }
    + +
    uint8_t digitalRead0(void)
    Definition: b15f.cpp:207
    +
    uint8_t readDipSwitch(void)
    Definition: b15f.cpp:235
    +
    void delay_ms(uint16_t ms)
    Definition: b15f.cpp:432
    +
    static B15F & getInstance(void)
    Definition: b15f.cpp:442
    +
    Definition: b15f.h:31
    +
    static void abort(std::string msg)
    Definition: b15f.cpp:467
    +
    uint16_t analogRead(uint8_t channel)
    Definition: b15f.cpp:279
    +
    uint8_t digitalRead1(void)
    Definition: b15f.cpp:221
    void reconnect(void)
    Definition: b15f.cpp:57
    - + diff --git a/docs/html/view__monitor_8h_source.html b/docs/html/view__monitor_8h_source.html index e224df6..7943b12 100644 --- a/docs/html/view__monitor_8h_source.html +++ b/docs/html/view__monitor_8h_source.html @@ -70,12 +70,12 @@ $(function() {
    view_monitor.h
    -
    1 #ifndef VIEW_MONITOR_H
    2 #define VIEW_MONITOR_H
    3 
    4 #include <thread>
    5 #include <chrono>
    6 #include <sstream>
    7 #include <bitset>
    8 #include "view_info.h"
    9 #include "../drv/b15f.h"
    10 
    11 class ViewMonitor : public ViewInfo
    12 {
    13 
    14 public:
    15  ViewMonitor(void);
    16  virtual call_t keypress(int& key) override;
    17 
    18 private:
    19  std::string fancyDigitalString(uint8_t& b);
    20  std::string fancyAnalogString(uint16_t& v);
    21 
    22 protected:
    23  virtual void worker(void);
    24  volatile bool run_worker = true;
    25  std::thread t_worker;
    26 
    27 };
    28 
    29 #endif // VIEW_MONITOR_H
    - - +
    1 #ifndef VIEW_MONITOR_H
    2 #define VIEW_MONITOR_H
    3 
    4 #include <thread>
    5 #include <chrono>
    6 #include <sstream>
    7 #include <bitset>
    8 #include "view_info.h"
    9 #include "../drv/b15f.h"
    10 
    13 class ViewMonitor : public ViewInfo
    14 {
    15 
    16 public:
    17  ViewMonitor(void);
    18  virtual call_t keypress(int& key) override;
    19 
    20 private:
    21  std::string fancyDigitalString(uint8_t& b);
    22  std::string fancyAnalogString(uint16_t& v);
    23 
    24 protected:
    25  virtual void worker(void);
    26  volatile bool run_worker = true;
    27  std::thread t_worker;
    28 
    29 };
    30 
    31 #endif // VIEW_MONITOR_H
    + + diff --git a/docs/html/view__promt_8cpp_source.html b/docs/html/view__promt_8cpp_source.html index ce44e4d..d091fb4 100644 --- a/docs/html/view__promt_8cpp_source.html +++ b/docs/html/view__promt_8cpp_source.html @@ -70,10 +70,10 @@ $(function() {
    view_promt.cpp
    -
    1 #include "view_promt.h"
    2 
    3 void ViewPromt::draw()
    4 {
    5  curs_set(1); // show cursor
    6 
    7  int li = text_offset_y;
    8  int ci = 0;
    9  for(std::string line : str_split(message + input, "\n"))
    10  {
    11  mvwprintw(win, ++li, text_offset_x, "%s", line.c_str());
    12  ci = line.length() + text_offset_x;
    13  }
    14 
    15  button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2;
    16  button_offset_y = height - text_offset_y;
    17 
    18  if(selection == 0)
    19  {
    20  wattron(win, A_REVERSE);
    21  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
    22  wattroff(win, A_REVERSE);
    23  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
    24  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
    25  }
    26  else
    27  {
    28  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
    29  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
    30  wattron(win, A_REVERSE);
    31  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
    32  wattroff(win, A_REVERSE);
    33  }
    34  wmove(win, li, ci);
    35 }
    36 
    37 void ViewPromt::setMessage(std::string message)
    38 {
    39  this->message = message;
    40 }
    41 
    42 void ViewPromt::setConfirm(std::string name, std::function<void(int)> call)
    43 {
    44  label_confirm = name;
    45  call_confirm = call;
    46 }
    47 
    48 void ViewPromt::setCancel(std::string name, bool cancelable)
    49 {
    50  label_cancel = name;
    51  this->cancelable = cancelable;
    52 }
    53 
    54 std::string ViewPromt::getInput()
    55 {
    56  return input;
    57 }
    58 
    59 std::function<void(int)> ViewPromt::keypress(int& key)
    60 {
    61  std::function<void(int)> ret = nullptr;
    62  switch(key)
    63  {
    64  case KEY_BACKSPACE:
    65  if(input.length())
    66  input.pop_back();
    67  break;
    68  case '\t':
    69  case KEY_LEFT:
    70  case KEY_RIGHT:
    71  selection = (selection + 1 ) % 2;
    72  break;
    73  case KEY_MOUSE:
    74  {
    75  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    76  MEVENT event;
    77  bool hit = false;
    78  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    79  {
    80  size_t column_start = start_x + button_offset_x;
    81  size_t row_start = start_y + button_offset_y;
    82  size_t mouse_x = event.x, mouse_y = event.y;
    83  if(mouse_y == row_start)
    84  {
    85  if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length())
    86  {
    87  if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED)
    88  hit = true;
    89  selection = 0;
    90  }
    91  if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length())
    92  {
    93  if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED)
    94  hit = true;
    95  selection = 1;
    96  }
    97  }
    98  }
    99  if(!hit)
    100  break;
    101 
    102  // fall through to next case
    103  [[fallthrough]];
    104  }
    105  case KEY_ENT:
    106  if(selection == 0) // exit
    107  key = -1; // do return from view
    108  else
    109  ret = call_confirm;
    110  break;
    111  default:
    112  break;
    113  }
    114 
    115  if(key >= ' ' && key <= '~')
    116  input += (char) key;
    117 
    118  if(key != KEY_ENT)
    119  repaint();
    120  return ret;
    121 }
    +
    1 #include "view_promt.h"
    2 
    3 void ViewPromt::draw()
    4 {
    5  curs_set(1); // show cursor
    6 
    7  int li = text_offset_y;
    8  int ci = 0;
    9  for(std::string line : str_split(message + input, "\n"))
    10  {
    11  mvwprintw(win, ++li, text_offset_x, "%s", line.c_str());
    12  ci = line.length() + text_offset_x;
    13  }
    14 
    15  button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2;
    16  button_offset_y = height - text_offset_y;
    17 
    18  if(selection == 0)
    19  {
    20  wattron(win, A_REVERSE);
    21  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
    22  wattroff(win, A_REVERSE);
    23  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
    24  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
    25  }
    26  else
    27  {
    28  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
    29  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
    30  wattron(win, A_REVERSE);
    31  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
    32  wattroff(win, A_REVERSE);
    33  }
    34  wmove(win, li, ci);
    35 }
    36 
    37 void ViewPromt::setMessage(std::string message)
    38 {
    39  this->message = message;
    40 }
    41 
    42 void ViewPromt::setConfirm(std::string name, std::function<void(int)> call)
    43 {
    44  label_confirm = name;
    45  call_confirm = call;
    46 }
    47 
    48 void ViewPromt::setCancel(std::string name, bool cancelable)
    49 {
    50  label_cancel = name;
    51  this->cancelable = cancelable;
    52 }
    53 
    54 std::string ViewPromt::getInput()
    55 {
    56  return input;
    57 }
    58 
    59 std::function<void(int)> ViewPromt::keypress(int& key)
    60 {
    61  std::function<void(int)> ret = nullptr;
    62  switch(key)
    63  {
    64  case KEY_BACKSPACE:
    65  if(input.length())
    66  input.pop_back();
    67  break;
    68  case '\t':
    69  case KEY_LEFT:
    70  case KEY_RIGHT:
    71  selection = (selection + 1 ) % 2;
    72  break;
    73  case KEY_MOUSE:
    74  {
    75  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    76  MEVENT event;
    77  bool hit = false;
    78  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    79  {
    80  size_t column_start = start_x + button_offset_x;
    81  size_t row_start = start_y + button_offset_y;
    82  size_t mouse_x = event.x, mouse_y = event.y;
    83  if(mouse_y == row_start)
    84  {
    85  if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length())
    86  {
    87  if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED)
    88  hit = true;
    89  selection = 0;
    90  }
    91  if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length())
    92  {
    93  if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED)
    94  hit = true;
    95  selection = 1;
    96  }
    97  }
    98  }
    99  if(!hit)
    100  break;
    101 
    102  // fall through to next case
    103  [[fallthrough]];
    104  }
    105  case KEY_ENT:
    106  if(selection == 0) // exit
    107  key = -1; // do return from view
    108  else
    109  ret = call_confirm;
    110  break;
    111  default:
    112  break;
    113  }
    114 
    115  if(key >= ' ' && key <= '~')
    116  input += (char) key;
    117 
    118  if(key != KEY_ENT)
    119  repaint();
    120  return ret;
    121 }
    diff --git a/docs/html/view__promt_8h_source.html b/docs/html/view__promt_8h_source.html index f09c0c1..af3e350 100644 --- a/docs/html/view__promt_8h_source.html +++ b/docs/html/view__promt_8h_source.html @@ -70,12 +70,12 @@ $(function() {
    view_promt.h
    -
    1 #ifndef VIEW_PROMT_H
    2 #define VIEW_PROMT_H
    3 
    4 #include <vector>
    5 #include <string>
    6 #include "view.h"
    7 
    8 class ViewPromt : public View
    9 {
    10 public:
    11  virtual void draw(void) override;
    12  virtual void setMessage(std::string message);
    13  virtual void setConfirm(std::string name, call_t call);
    14  virtual void setCancel(std::string name, bool cancelable);
    15  virtual std::string getInput(void);
    16  virtual call_t keypress(int& key) override;
    17 
    18 protected:
    19  size_t selection = 1;
    20  std::string input;
    21  std::string message = "Input";
    22  std::string label_confirm = "[ OK ]";
    23  std::string sep = " ";
    24  std::string label_cancel = "[ Cancel ]";
    25  call_t call_confirm = nullptr;
    26  bool cancelable = true;
    27  int button_offset_x = 0, button_offset_y = 0;
    28  constexpr static int text_offset_x = 2;
    29  constexpr static int text_offset_y = 2;
    30 };
    31 
    32 #endif // VIEW_PROMT_H
    -
    Definition: view.h:17
    - +
    1 #ifndef VIEW_PROMT_H
    2 #define VIEW_PROMT_H
    3 
    4 #include <vector>
    5 #include <string>
    6 #include "view.h"
    7 
    10 class ViewPromt : public View
    11 {
    12 public:
    13  virtual void draw(void) override;
    14  virtual void setMessage(std::string message);
    15  virtual void setConfirm(std::string name, call_t call);
    16  virtual void setCancel(std::string name, bool cancelable);
    17  virtual std::string getInput(void);
    18  virtual call_t keypress(int& key) override;
    19 
    20 protected:
    21  size_t selection = 1;
    22  std::string input;
    23  std::string message = "Input";
    24  std::string label_confirm = "[ OK ]";
    25  std::string sep = " ";
    26  std::string label_cancel = "[ Cancel ]";
    27  call_t call_confirm = nullptr;
    28  bool cancelable = true;
    29  int button_offset_x = 0, button_offset_y = 0;
    30  constexpr static int text_offset_x = 2;
    31  constexpr static int text_offset_y = 2;
    32 };
    33 
    34 #endif // VIEW_PROMT_H
    +
    Definition: view.h:19
    + diff --git a/docs/html/view__selection_8cpp_source.html b/docs/html/view__selection_8cpp_source.html index 4a45641..014a553 100644 --- a/docs/html/view__selection_8cpp_source.html +++ b/docs/html/view__selection_8cpp_source.html @@ -70,10 +70,10 @@ $(function() {
    view_selection.cpp
    -
    1 #include "view_selection.h"
    2 
    3 void ViewSelection::draw()
    4 {
    5  //curs_set(0); // hide cursor
    6  for(size_t i = 0; i < choices.size(); i++)
    7  {
    8  if(selection == i)
    9  wattron(win, A_REVERSE);
    10  mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str());
    11  if(selection == i)
    12  wattroff(win, A_REVERSE);
    13  }
    14 }
    15 
    16 void ViewSelection::addChoice(std::string name, call_t call)
    17 {
    18  choices.push_back(name);
    19  calls.push_back(call);
    20 }
    21 
    22 call_t ViewSelection::keypress(int& key)
    23 {
    24  call_t ret = nullptr;
    25  switch(key)
    26  {
    27  case KEY_UP:
    28  do
    29  selection = (selection - 1 + choices.size()) % choices.size();
    30  while(!choices[selection].length() && choices.size());
    31  break;
    32 
    33  case '\t':
    34  case KEY_DOWN:
    35  do
    36  selection = (selection + 1) % choices.size();
    37  while(!choices[selection].length() && choices.size());
    38  break;
    39 
    40  case KEY_MOUSE:
    41  {
    42  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    43  MEVENT event;
    44  bool hit = false;
    45  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    46  {
    47  size_t column_start = start_x + choice_offset_x;
    48  size_t row_start = start_y + choice_offset_y;
    49  size_t mouse_x = event.x, mouse_y = event.y;
    50  for(size_t i = 0; i < choices.size(); i++)
    51  if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length())
    52  {
    53  if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED)
    54  hit = true;
    55  selection = i;
    56  }
    57  }
    58  if(!hit)
    59  break;
    60 
    61  // fall through to next case
    62  [[fallthrough]];
    63  }
    64 
    65  case KEY_ENT:
    66  if(selection == choices.size() - 1) // exit
    67  key = -1; // do return from view
    68  else
    69  ret = calls[selection];
    70  break;
    71  default:
    72  break;
    73  }
    74  repaint();
    75  return ret;
    76 }
    +
    1 #include "view_selection.h"
    2 
    3 void ViewSelection::draw()
    4 {
    5  //curs_set(0); // hide cursor
    6  for(size_t i = 0; i < choices.size(); i++)
    7  {
    8  if(selection == i)
    9  wattron(win, A_REVERSE);
    10  mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str());
    11  if(selection == i)
    12  wattroff(win, A_REVERSE);
    13  }
    14 }
    15 
    16 void ViewSelection::addChoice(std::string name, call_t call)
    17 {
    18  choices.push_back(name);
    19  calls.push_back(call);
    20 }
    21 
    22 call_t ViewSelection::keypress(int& key)
    23 {
    24  call_t ret = nullptr;
    25  switch(key)
    26  {
    27  case KEY_UP:
    28  do
    29  selection = (selection - 1 + choices.size()) % choices.size();
    30  while(!choices[selection].length() && choices.size());
    31  break;
    32 
    33  case '\t':
    34  case KEY_DOWN:
    35  do
    36  selection = (selection + 1) % choices.size();
    37  while(!choices[selection].length() && choices.size());
    38  break;
    39 
    40  case KEY_MOUSE:
    41  {
    42  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    43  MEVENT event;
    44  bool hit = false;
    45  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    46  {
    47  size_t column_start = start_x + choice_offset_x;
    48  size_t row_start = start_y + choice_offset_y;
    49  size_t mouse_x = event.x, mouse_y = event.y;
    50  for(size_t i = 0; i < choices.size(); i++)
    51  if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length())
    52  {
    53  if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED)
    54  hit = true;
    55  selection = i;
    56  }
    57  }
    58  if(!hit)
    59  break;
    60 
    61  // fall through to next case
    62  [[fallthrough]];
    63  }
    64 
    65  case KEY_ENT:
    66  if(selection == choices.size() - 1) // exit
    67  key = -1; // do return from view
    68  else
    69  ret = calls[selection];
    70  break;
    71  default:
    72  break;
    73  }
    74  repaint();
    75  return ret;
    76 }
    diff --git a/docs/html/view__selection_8h_source.html b/docs/html/view__selection_8h_source.html index 9cfd46e..9d49827 100644 --- a/docs/html/view__selection_8h_source.html +++ b/docs/html/view__selection_8h_source.html @@ -70,12 +70,12 @@ $(function() {
    view_selection.h
    -
    1 #ifndef VIEW_SELECTION_H
    2 #define VIEW_SELECTION_H
    3 
    4 #include <vector>
    5 #include <string>
    6 #include "view.h"
    7 
    8 class ViewSelection : public View
    9 {
    10 public:
    11  virtual void draw(void) override;
    12  virtual void addChoice(std::string name, call_t call);
    13  virtual call_t keypress(int& key) override;
    14 
    15 
    16 protected:
    17  size_t selection = 0;
    18  std::vector<std::string> choices;
    19 
    20  constexpr static int choice_offset_x = 2;
    21  constexpr static int choice_offset_y = 3;
    22 };
    23 
    24 #endif // VIEW_SELECTION_H
    -
    Definition: view.h:17
    - +
    1 #ifndef VIEW_SELECTION_H
    2 #define VIEW_SELECTION_H
    3 
    4 #include <vector>
    5 #include <string>
    6 #include "view.h"
    7 
    10 class ViewSelection : public View
    11 {
    12 public:
    13  virtual void draw(void) override;
    14  virtual void addChoice(std::string name, call_t call);
    15  virtual call_t keypress(int& key) override;
    16 
    17 
    18 protected:
    19  size_t selection = 0;
    20  std::vector<std::string> choices;
    21 
    22  constexpr static int choice_offset_x = 2;
    23  constexpr static int choice_offset_y = 3;
    24 };
    25 
    26 #endif // VIEW_SELECTION_H
    +
    Definition: view.h:19
    + diff --git a/docs/index.html b/docs/index.html index 1324b98..f4f7ec6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,14 +2,14 @@ - + Page Redirection - If you are not redirected automatically, follow this link to example. + If you are not redirected automatically, follow this link to example. diff --git a/firmware/Makefile b/firmware/Makefile index 15d169e..b4a8479 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -21,7 +21,7 @@ HEX = b15f.hex MCU = atmega1284p CFLAGS = -Wall -Wextra -std=c++14 -O3 -mmcu=$(MCU) -DF_CPU=$(F_CPU) $(DEBUG) LDFLAGS = -OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o global_vars.o usart.o requests.o interrupts.o +OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o global_vars.o usart.o requests.o interrupts.o pwm.o COMPILE = $(COMPILER_PATH) $(CFLAGS) diff --git a/firmware/MakefileWindoofs b/firmware/MakefileWindoofs deleted file mode 100644 index 7846f59..0000000 --- a/firmware/MakefileWindoofs +++ /dev/null @@ -1,36 +0,0 @@ -# Name: Makefile -# Project: B15F (board15 Famulus Edition) -# Author: Tristan Krause -# Creation Date: 2019-03-22 - -# Umgebungseinstellungen -COMPILER_PATH = C:\avr8-gnu-toolchain-win32_x86\bin\avr-g++.exe -OBJCOPY_PATH = C:\avr8-gnu-toolchain-win32_x86\bin\avr-objcopy.exe - - -OUTPUT = B15F.elf -HEX = B15F.hex -CFLAGS = -Wall -Wextra -std=c++14 -O3 -mmcu=atmega1284 -DF_CPU=20000000 -LDFLAGS = -OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o global_vars.o usart.o requests.o - - -COMPILE = $(COMPILER_PATH) $(CFLAGS) - -B15F: $(OBJECTS) - @echo "Linking..." - $(COMPILE) $(OBJECTS) -o $(OUTPUT) $(LDFLAGS) - - $(OBJCOPY_PATH) -O ihex -R .eeprom -R .fuse -R .lock -R .signature $(OUTPUT) $(HEX) - -help: - @echo "This Makefile has the following rules:" - @echo "make B15F .... to compile (default)" - @echo "make clean ... to delete objects, elf and hex file" - -clean: - @echo "Cleaning..." - rm -f $(OBJECTS) $(OUTPUT) $(HEX) - -.cpp.o: - $(COMPILE) -c $< -o $@ diff --git a/firmware/global_vars.cpp b/firmware/global_vars.cpp index 1359c7e..7297949 100644 --- a/firmware/global_vars.cpp +++ b/firmware/global_vars.cpp @@ -8,4 +8,5 @@ volatile TLC5615 dac0(spi, SPIADR::AA0); volatile TLC5615 dac1(spi, SPIADR::AA1); volatile ADU adu; volatile USART usart; +volatile PWM pwm; volatile bool nextRequest = false; diff --git a/firmware/global_vars.h b/firmware/global_vars.h index 749948c..218f50e 100644 --- a/firmware/global_vars.h +++ b/firmware/global_vars.h @@ -5,6 +5,7 @@ #include "tlc5615.h" #include "adu.h" #include "usart.h" +#include "pwm.h" #define WDT_TIMEOUT WDTO_15MS @@ -17,6 +18,7 @@ extern volatile TLC5615 dac0; extern volatile TLC5615 dac1; extern volatile ADU adu; extern volatile USART usart; +extern volatile PWM pwm; extern volatile bool nextRequest; #endif // GLOBAL_VARS_H diff --git a/firmware/main.cpp b/firmware/main.cpp index 6d9c5be..96f004f 100644 --- a/firmware/main.cpp +++ b/firmware/main.cpp @@ -6,6 +6,7 @@ #include "selftest.h" #include "requests.h" + int main() { // deactivate WDT ENTIRELY! @@ -27,8 +28,8 @@ int main() usart.init(); usart.initRX(); - - + + pwm.init(); // Hauptschleife, Verarbeitung der Requests while(1) diff --git a/firmware/pwm.cpp b/firmware/pwm.cpp new file mode 100644 index 0000000..f747725 --- /dev/null +++ b/firmware/pwm.cpp @@ -0,0 +1,32 @@ +#include "pwm.h" +const uint16_t PWM::PRESCALERS[] = {0, 1, 8, 64, 256, 1024}; +const uint8_t PWM::PRESCALER_COUNT = sizeof(PRESCALERS) / sizeof(uint16_t); + +void PWM::init() const volatile +{ + // fast pwm mode, top = OCR0A, non inverting mode + TCCR0A = _BV(COM0B1) | _BV(WGM00) | _BV(WGM01); + TCCR0B = _BV(WGM02); + + // output signal on PB4 + DDRB |= _BV(PB4); +} + +void PWM::setFrequency(uint32_t freq) const volatile +{ + uint16_t p_ideal = ceil(float(F_CPU) / (freq * 0x100)); + for(int8_t i = PRESCALER_COUNT - 1; i >= 0 && PRESCALERS[i] >= p_ideal; i--) + TCCR0B = (TCCR0B & 0xF8) | i; // set prescaler + if(p_ideal) + OCR0A = (uint8_t) (float(F_CPU) / (freq * PRESCALERS[TCCR0B & 0x07])); +} + +void PWM::setValue(uint8_t value) const volatile +{ + OCR0B = value; +} + +uint8_t PWM::getTop() const volatile +{ + return OCR0A; +} diff --git a/firmware/pwm.h b/firmware/pwm.h new file mode 100644 index 0000000..dcf0d63 --- /dev/null +++ b/firmware/pwm.h @@ -0,0 +1,20 @@ +#ifndef PWM_H +#define PWM_H + +#include +#include + +class PWM +{ +public: + void init(void) const volatile; + void setFrequency(uint32_t) const volatile; + void setValue(uint8_t) const volatile; + uint8_t getTop(void) const volatile; + +private: + const static uint16_t PRESCALERS[]; + const static uint8_t PRESCALER_COUNT; +}; + +#endif // PWM_H diff --git a/firmware/requests.cpp b/firmware/requests.cpp index a44eb73..bd3c014 100644 --- a/firmware/requests.cpp +++ b/firmware/requests.cpp @@ -62,6 +62,22 @@ void handleRequest() case RQ_ADC_DAC_STROKE: rqAdcDacStroke(); break; + + case RQ_PWM_SET_FREQ: + rqPwmSetFreq(); + break; + + case RQ_PWM_SET_VALUE: + rqPwmSetValue(); + break; + + case RQ_SET_REG: + rqSetRegister(); + break; + + case RQ_GET_REG: + rqGetRegister(); + break; default: break; @@ -216,3 +232,44 @@ void rqAdcDacStroke() usart.writeByte(USART::MSG_OK); usart.flush(); } + +void rqPwmSetFreq() +{ + usart.initTX(); + uint32_t freq = usart.readU32(); + pwm.setFrequency(freq); + + usart.writeByte(pwm.getTop()); + usart.flush(); +} + +void rqPwmSetValue() +{ + usart.initTX(); + uint16_t value = usart.readByte(); + pwm.setValue(value); + + usart.writeByte(USART::MSG_OK); + usart.flush(); +} + +void rqSetRegister() +{ + usart.initTX(); + uint16_t reg = usart.readByte(); + uint16_t val = usart.readByte(); + + (*(volatile uint8_t *) reg) = val; + usart.writeByte((*(volatile uint8_t *) reg)); + usart.flush(); +} + +void rqGetRegister() +{ + usart.initTX(); + uint16_t reg = usart.readByte(); + + usart.writeByte((*(volatile uint8_t *) reg)); + usart.flush(); +} + diff --git a/firmware/requests.h b/firmware/requests.h index 3910388..336f8f5 100644 --- a/firmware/requests.h +++ b/firmware/requests.h @@ -5,6 +5,7 @@ #include "global_vars.h" #include "selftest.h" #include "boardinfo.h" +#include "pwm.h" constexpr static uint8_t RQ_DISC = 0; constexpr static uint8_t RQ_TEST = 1; @@ -19,7 +20,11 @@ constexpr static uint8_t RQ_DSW = 9; constexpr static uint8_t RQ_AA0 = 10; constexpr static uint8_t RQ_AA1 = 11; constexpr static uint8_t RQ_ADC = 12; -constexpr static uint8_t RQ_ADC_DAC_STROKE = 13; +constexpr static uint8_t RQ_ADC_DAC_STROKE = 13; +constexpr static uint8_t RQ_PWM_SET_FREQ = 14; +constexpr static uint8_t RQ_PWM_SET_VALUE = 15; +constexpr static uint8_t RQ_SET_REG = 16; +constexpr static uint8_t RQ_GET_REG = 17; uint8_t const rq_len[] = { /* RQ_DISC */ 1, @@ -35,7 +40,11 @@ uint8_t const rq_len[] = { /* RQ_AA0 */ 3, /* RQ_AA1 */ 3, /* RQ_ADC */ 2, - /* RQ_ADC_DAC_STROKE */ 9 + /* RQ_ADC_DAC_STROKE */ 9, + /* RQ_PWM_SET_FREQ */ 5, + /* RQ_PWM_SET_VALUE */ 2, + /* RQ_SET_REG */ 3, + /* RQ_GET_REG */ 2 }; /** @@ -58,5 +67,9 @@ void rqAnalogWrite0(void); void rqAnalogWrite1(void); void rqAnalogRead(void); void rqAdcDacStroke(void); +void rqPwmSetFreq(void); +void rqPwmSetValue(void); +void rqSetRegister(void); +void rqGetRegister(void); #endif // REQUESTS_H diff --git a/firmware/usart.cpp b/firmware/usart.cpp index d039fcf..8be2392 100644 --- a/firmware/usart.cpp +++ b/firmware/usart.cpp @@ -130,3 +130,10 @@ uint16_t USART::readInt() volatile v |= readByte() << 8; return v; } + +uint32_t USART::readU32() volatile +{ + uint32_t v = readInt(); + v |= ((uint32_t) readInt()) << 16; + return v; +} diff --git a/firmware/usart.h b/firmware/usart.h index 5505a1b..a6cd610 100644 --- a/firmware/usart.h +++ b/firmware/usart.h @@ -102,6 +102,12 @@ public: * \return gelesenes Integer */ uint16_t readInt(void) volatile; + + /** + * Liest ein uint32_t aus dem Eingangspuffer + * \return gelesenes uint32_t + */ + uint32_t readU32(void) volatile; /**********************/