From d4bb253f44948898b622726e92656da5c6d91409 Mon Sep 17 00:00:00 2001
From: Alessio Igor Bogani <alessio.bogani@elettra.eu>
Date: Thu, 18 Apr 2024 10:34:24 +0200
Subject: [PATCH] Write() always throws exception if buffer != 0

---
 src/Serial2.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/Serial2.cpp b/src/Serial2.cpp
index bf4add6..151cb2a 100644
--- a/src/Serial2.cpp
+++ b/src/Serial2.cpp
@@ -533,7 +533,6 @@ void Serial2::write(const Tango::DevVarCharArray *argin)
 	vector<unsigned char> argin_data;
 	argin_data << *argin;
 	size_t bytes_total = 0, bytes_to_write = argin_data.size();
-	int olength;
 
 	while (bytes_total < bytes_to_write) {
 		int s = select(WRITE);
@@ -561,12 +560,10 @@ void Serial2::write(const Tango::DevVarCharArray *argin)
 	timeval twait;
 	timerclear(&twait);
 	twait.tv_usec = 1000;
-	olength = max(output_queue_length(), 0);
-	while ((bytes_total - olength) != bytes_to_write) {
+	while (max(output_queue_length(), 0) != 0) {
 		if (! sleep(twait))
 			goto timeout;
 		timeradd(&twait, &twait, &twait);
-		olength = max(output_queue_length(), 0);
 	}
 
 	return;
-- 
GitLab