From b4be50f81a32b48f5313238243678f027118bfd7 Mon Sep 17 00:00:00 2001 From: Spencer Jackson Date: Mon, 27 May 2013 01:44:28 -0400 Subject: [PATCH 1/2] Allow service calls with empty requests std_srvs::Empty has a request message of size zero. SerialClient.send returns the size of the sent message, which is checked to ensure data crossed the serial line. Accommodate services with empty requests by modifying the check to acknowledge all transmissions of zero or more bytes as valid. --- rosserial_python/src/rosserial_python/SerialClient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosserial_python/src/rosserial_python/SerialClient.py b/rosserial_python/src/rosserial_python/SerialClient.py index cf732f8ba..db06b18ce 100644 --- a/rosserial_python/src/rosserial_python/SerialClient.py +++ b/rosserial_python/src/rosserial_python/SerialClient.py @@ -151,7 +151,7 @@ def callback(self, req): data_buffer = StringIO.StringIO() req.serialize(data_buffer) self.response = None - if self.parent.send(self.id, data_buffer.getvalue()) > 0: + if self.parent.send(self.id, data_buffer.getvalue()) >= 0: while self.response == None: pass return self.response From 8fb301db762fef54d30cb87fa20bce3813d0979f Mon Sep 17 00:00:00 2001 From: Spencer Jackson Date: Mon, 27 May 2013 01:46:40 -0400 Subject: [PATCH 2/2] Fix SeviceServer member names in error message 'm' prefix was omitted, causing an exception while trying to print an error about md5 mismatches. Fix this to allow the error to be presented to the user. --- rosserial_python/src/rosserial_python/SerialClient.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rosserial_python/src/rosserial_python/SerialClient.py b/rosserial_python/src/rosserial_python/SerialClient.py index db06b18ce..98ce51fab 100644 --- a/rosserial_python/src/rosserial_python/SerialClient.py +++ b/rosserial_python/src/rosserial_python/SerialClient.py @@ -443,7 +443,7 @@ def setupServiceServerPublisher(self, data): if srv.mres._md5sum == msg.md5sum: self.callbacks[msg.topic_id] = srv.handlePacket else: - raise Exception('Checksum does not match: ' + srv.res._md5sum + ',' + msg.md5sum) + raise Exception('Checksum does not match: ' + srv.mres._md5sum + ',' + msg.md5sum) except Exception as e: rospy.logerr("Creation of service server failed: %s", e) def setupServiceServerSubscriber(self, data): @@ -461,7 +461,7 @@ def setupServiceServerSubscriber(self, data): if srv.mreq._md5sum == msg.md5sum: srv.id = msg.topic_id else: - raise Exception('Checksum does not match: ' + srv.req._md5sum + ',' + msg.md5sum) + raise Exception('Checksum does not match: ' + srv.mreq._md5sum + ',' + msg.md5sum) except Exception as e: rospy.logerr("Creation of service server failed: %s", e) @@ -480,7 +480,7 @@ def setupServiceClientPublisher(self, data): if srv.mreq._md5sum == msg.md5sum: self.callbacks[msg.topic_id] = srv.handlePacket else: - raise Exception('Checksum does not match: ' + srv.req._md5sum + ',' + msg.md5sum) + raise Exception('Checksum does not match: ' + srv.mreq._md5sum + ',' + msg.md5sum) except Exception as e: rospy.logerr("Creation of service client failed: %s", e) def setupServiceClientSubscriber(self, data): @@ -498,7 +498,7 @@ def setupServiceClientSubscriber(self, data): if srv.mres._md5sum == msg.md5sum: srv.id = msg.topic_id else: - raise Exception('Checksum does not match: ' + srv.res._md5sum + ',' + msg.md5sum) + raise Exception('Checksum does not match: ' + srv.mres._md5sum + ',' + msg.md5sum) except Exception as e: rospy.logerr("Creation of service client failed: %s", e)