From 48babcab4da45b435497c2ab1402861d333fb986 Mon Sep 17 00:00:00 2001 From: Alessio Igor Bogani <alessio.bogani@elettra.eu> Date: Mon, 8 Apr 2024 10:14:19 +0200 Subject: [PATCH] Little changes --- src/Socket2.cpp | 21 +++++++++++---------- src/Socket2.h | 9 +++++---- src/Socket2.xmi | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Socket2.cpp b/src/Socket2.cpp index 6d6e8a8..0729b04 100644 --- a/src/Socket2.cpp +++ b/src/Socket2.cpp @@ -292,6 +292,13 @@ void Socket2::get_device_property() /*----- PROTECTED REGION ID(Socket2::get_device_property_after) ENABLED START -----*/ // Check device property data members init + transform(iOMultiplexing.begin(), iOMultiplexing.end(), iOMultiplexing.begin(), ::tolower); + if (iOMultiplexing == "sleep") { + multiplexing = SLEEP; + } else { + multiplexing = SELECT; + } + transform(protocol.begin(), protocol.end(), protocol.begin(), ::tolower); if (protocol == "udp") { proto = UDP; @@ -299,13 +306,6 @@ void Socket2::get_device_property() proto = TCP; } - transform(iOMultiplexing.begin(), iOMultiplexing.end(), iOMultiplexing.begin(), ::tolower); - if (iOMultiplexing == "sleep") { - multiplexing = SLEEP; - } else { - multiplexing = SELECT; - } - if (port <= 0 || port > 65535) init_error = "Invalid port"; @@ -522,7 +522,6 @@ void Socket2::write(const Tango::DevVarCharArray *argin) goto error; /* Continue if multiplexing == SLEEP */ } else { /* bytes_written < 0 */ - check_state(false); goto error; } } @@ -541,6 +540,7 @@ void Socket2::write(const Tango::DevVarCharArray *argin) return; error: + check_state(false); sleep(tout); timeout: Tango::Except::throw_exception( @@ -735,7 +735,7 @@ void Socket2::close() if(input_len + output_len) { - WARN_STREAM << " Bytes dropped: " << input_len << " input, " + WARN_STREAM << " Bytes dropped: " << input_len << " (" << data.size() << ") input, " << output_len << " output" << endl; } @@ -779,12 +779,12 @@ void Socket2::_read(size_t bytes_to_read) goto error; /* Continue if multiplexing == SLEEP */ } else { /* bytes_readed < 0 */ - check_state(true); goto error; } } return; error: + check_state(false); sleep(tout); timeout: Tango::Except::throw_exception( @@ -843,6 +843,7 @@ void Socket2::check_state(bool forcing) set_state(Tango::INIT); set_status("Reconnecting due: " + mesg); + DEBUG_STREAM << "Reconnecting due: " << mesg << endl; close(); resolve(); diff --git a/src/Socket2.h b/src/Socket2.h index 06bf334..c69e284 100644 --- a/src/Socket2.h +++ b/src/Socket2.h @@ -75,12 +75,8 @@ class Socket2 : public TANGO_BASE_CLASS // Add your own data members string init_error; - enum {TCP, UDP} proto; - int fd; int conn_state; - sockaddr_in sa; - socklen_t sa_len; enum event_type {READ, WRITE}; @@ -91,6 +87,11 @@ class Socket2 : public TANGO_BASE_CLASS enum {SLEEP, SELECT} multiplexing; timeval timeout_timeval, tout; + + enum {TCP, UDP} proto; + + sockaddr_in sa; + socklen_t sa_len; /*----- PROTECTED REGION END -----*/ // Socket2::Data Members // Device property data members diff --git a/src/Socket2.xmi b/src/Socket2.xmi index e8453a8..eea2cda 100644 --- a/src/Socket2.xmi +++ b/src/Socket2.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="Socket2" pogoRevision="9.7"> - <description description="" title="" sourcePath="/home/alessio.bogani/Sources/git-trees/linkstabilizer/deps/socket2/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="" title="" sourcePath="/home/alessio/Sources/git-trees/4uhv/deps/socket2/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at elettra.eu> - Alessio Igor Bogani <alessio.bogani" author="Alessio Igor Bogani <alessio.bogani" emailDomain="elettra.eu>" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="Socket" manufacturer="none" reference=""/> </description> -- GitLab