diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-16 18:04:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-03-29 00:04:47 +0200 |
commit | c2b1db1c6cbbcc58f69abf18ce6b704b6b767bac (patch) | |
tree | 1deb32f47ab1d68a4bee6755df4cbc2311467880 | |
parent | aab125f42116b993b5c03f451cf7fe377c2bc53b (diff) |
tracker/trackhat: buffer flush
-rw-r--r-- | tracker-trackhat/camera.cpp | 17 | ||||
-rw-r--r-- | tracker-trackhat/trackhat.hpp | 5 |
2 files changed, 16 insertions, 6 deletions
diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp index 1ec3bbe7..10feef47 100644 --- a/tracker-trackhat/camera.cpp +++ b/tracker-trackhat/camera.cpp @@ -90,7 +90,7 @@ error: if (TH_ErrorCode status_ = (x); status_ != TH_SUCCESS) \ { \ qDebug() << "trackhat: error" \ - << (void*)status_ << "in" << #x; \ + << (void*)-status_ << "in" << #x; \ error_code = status_; \ goto error; \ } \ @@ -147,6 +147,7 @@ error: bool trackhat_camera::start(const pt_settings&) { int attempts = 0; + constexpr int max_attempts = 5; set_pt_options(); @@ -170,10 +171,18 @@ start: return true; error: stop(); - if (++attempts < 5) + switch (error_code) { - portable::sleep(100); - goto start; + case TH_ERROR_DEVICE_NOT_DETECTED: + case TH_ERROR_CAMERA_SELFT_TEST_FAILD: + case TH_ERROR_CAMERA_INTERNAL_BROKEN: + break; + default: + if (attempts++ < max_attempts) + { + portable::sleep(10); + goto start; + } } return false; } diff --git a/tracker-trackhat/trackhat.hpp b/tracker-trackhat/trackhat.hpp index d8d66f0e..a6309f9c 100644 --- a/tracker-trackhat/trackhat.hpp +++ b/tracker-trackhat/trackhat.hpp @@ -85,8 +85,6 @@ struct trackhat_camera final : pt_camera bool start(const pt_settings& s) override; void stop() override; - [[nodiscard]] int init_regs(); - void set_pt_options(); pt_camera::result get_frame(pt_frame& frame) override; pt_camera::result get_info() const override; @@ -106,6 +104,9 @@ private: enum device_status { th_noinit, th_init, th_detect, th_connect, th_running, }; trackhat_impl::setting_receiver sig; + [[nodiscard]] int init_regs(); + void set_pt_options(); + trackHat_Device_t device {}; device_status status = th_noinit; TH_ErrorCode error_code = TH_SUCCESS; |