From 802dd4543b7634f498bd44909461eae6d7975abb Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 28 Feb 2017 21:02:30 +0100 Subject: Make device-level reconnect on problem with sending Make it 3 times before throwing exception Call hid_exit on last device disconnection Signed-off-by: Szczepan Zalega --- include/device.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/device.h b/include/device.h index 5d7ee12..7b300e5 100644 --- a/include/device.h +++ b/include/device.h @@ -50,6 +50,7 @@ public: cnt busy_progressbar; cnt command_result_not_equal_0_recv; cnt communication_successful; + cnt low_level_reconnect; std::string get_as_string(); } m_counters = {}; @@ -59,7 +60,7 @@ public: const milliseconds send_receive_delay, const int retry_receiving_count, const milliseconds retry_timeout); - virtual ~Device(){show_stats(); disconnect();} + virtual ~Device(); // lack of device is not actually an error, // so it doesn't throw @@ -97,6 +98,9 @@ public: DeviceModel get_device_model() const {return m_model;} private: std::atomic last_command_status; + void _reconnect(); + bool _connect(); + bool _disconnect(); protected: const uint16_t m_vid; @@ -115,6 +119,8 @@ protected: std::atomicmp_devhandle; + + static std::atomic_int instances_count; }; class Stick10 : public Device { -- cgit v1.2.1