diff --git a/driver/cli b/driver/cli index df76089..c291f80 100755 Binary files a/driver/cli and b/driver/cli differ diff --git a/driver/cli.cpp b/driver/cli.cpp index c2f9a06..aa57de7 100644 --- a/driver/cli.cpp +++ b/driver/cli.cpp @@ -19,9 +19,6 @@ #include "ui/view_monitor.h" #include "ui/view_promt.h" -// global error message -std::string ERR_MSG; - volatile int win_changed_cooldown = 0; volatile bool t_refresh_active = false; @@ -54,8 +51,6 @@ void signal_handler(int signal) { cleanup(); std::cout << "SIGINT - Abbruch." << std::endl; - if(ERR_MSG.length()) - std::cout << "ERR_MSG: " << ERR_MSG << std::endl; exit(EXIT_FAILURE); } } diff --git a/driver/drv/b15f.cpp b/driver/drv/b15f.cpp index 79b310b..59dbf72 100644 --- a/driver/drv/b15f.cpp +++ b/driver/drv/b15f.cpp @@ -16,7 +16,7 @@ void B15F::init() device.pop_back(); if(device.length() == 0) - throw DriverException("Adapter nicht gefunden"); + abort("Adapter nicht gefunden"); std::cout << PRE << "Verwende Adapter: " << device << std::endl; @@ -45,7 +45,7 @@ void B15F::init() break; } if(tries == 0) - throw DriverException("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?"); + abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?"); std::cout << "OK" << std::endl; @@ -68,7 +68,7 @@ void B15F::reconnect() } - throw DriverException("Verbindung kann nicht repariert werden"); + abort("Verbindung kann nicht repariert werden"); } void B15F::discard(void) @@ -131,7 +131,7 @@ std::vector B15F::getBoardInfo(void) uint8_t aw = usart.readByte(); if(aw != MSG_OK) - throw DriverException("Board Info fehlerhalft: code " + std::to_string((int) aw)); + abort("Board Info fehlerhalft: code " + std::to_string((int) aw)); return info; } @@ -215,7 +215,7 @@ uint16_t B15F::analogRead(uint8_t channel) { usart.clearInputBuffer(); if(channel > 7) - throw DriverException("Bad ADC channel: " + std::to_string(channel)); + abort("Bad ADC channel: " + std::to_string(channel)); uint8_t rq[] = { RQ_ADC, @@ -224,12 +224,12 @@ uint16_t B15F::analogRead(uint8_t channel) int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000); if(n_sent != sizeof(rq)) - throw DriverException("Sent failed"); + abort("Sent failed"); uint16_t adc = usart.readInt(); if(adc > 1023) - throw DriverException("Bad ADC data detected (1)"); + abort("Bad ADC data detected (1)"); return adc; } @@ -252,12 +252,12 @@ void B15F::analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset buffer_a[i] = usart.readInt(); buffer_b[i] = usart.readInt(); if(buffer_a[i] > 1023 || buffer_b[i] > 1023) - throw DriverException("Bad ADC data detected (2)"); + abort("Bad ADC data detected (2)"); } uint8_t aw = usart.readByte(); if(aw != MSG_OK) - throw DriverException("Sequenz unterbrochen"); + abort("Sequenz unterbrochen"); delay_us(10); } @@ -294,21 +294,20 @@ std::string B15F::exec(std::string cmd) { return result; } - void B15F::abort(std::string msg) { DriverException ex(msg); abort(ex); } - void B15F::abort(std::exception& ex) { if(errorhandler) errorhandler(ex); else { - std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl; - throw ex; + std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl; + std::cout << ex.what() << std::endl; + throw DriverException(ex.what()); } } diff --git a/driver/ui/view.cpp b/driver/ui/view.cpp index d84baf7..dd674eb 100644 --- a/driver/ui/view.cpp +++ b/driver/ui/view.cpp @@ -6,8 +6,7 @@ View::View() { if(!win) { - ERR_MSG = "View::win not initialized, missing context!"; - raise(SIGINT); + B15F::abort("View::win not initialized, missing context"); } getmaxyx(win, height, width); // init width and height keypad(win, TRUE); diff --git a/driver/ui/view.h b/driver/ui/view.h index 4bf2ab5..1445035 100644 --- a/driver/ui/view.h +++ b/driver/ui/view.h @@ -9,6 +9,7 @@ #include #include #include +#include "../drv/b15f.h" extern std::string ERR_MSG; typedef std::function call_t;