From abd3d692d6ac4704ff0cbdbb5be03d6aacceca90 Mon Sep 17 00:00:00 2001 From: Alessio Igor Bogani <alessio.bogani@elettra.eu> Date: Tue, 23 Jul 2024 07:51:02 +0000 Subject: [PATCH] Close connection if Write() is executed with buffer != 0 --- src/Serial2.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Serial2.cpp b/src/Serial2.cpp index 4327f26..97efc0f 100644 --- a/src/Serial2.cpp +++ b/src/Serial2.cpp @@ -524,15 +524,23 @@ void Serial2::write(const Tango::DevVarCharArray *argin) { DEBUG_STREAM << "Serial2::Write() - " << device_name << std::endl; /*----- PROTECTED REGION ID(Serial2::write) ENABLED START -----*/ + vector<unsigned char> argin_data; + argin_data << *argin; + size_t bytes_total = 0, bytes_to_write = argin_data.size(); + if (! init_error.empty()) { sleep(tout); Tango::Except::throw_exception( "", init_error.c_str(), __PRETTY_FUNCTION__); } - vector<unsigned char> argin_data; - argin_data << *argin; - size_t bytes_total = 0, bytes_to_write = argin_data.size(); + if (max(output_queue_length(), 0) != 0) { + close(); + resolve(); + open(); + reconnections += 1; + goto error; + } while (bytes_total < bytes_to_write) { int s = select(WRITE); -- GitLab