[Fawkes Git] branch/timn/protobuf-clips: created (0.5.0-3085-gfd10f4d)

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Mon May 9 10:49:38 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, timn/protobuf-clips has been created
        at  fd10f4d510501845070428938976598605d481e8 (commit)

http://git.fawkesrobotics.org/fawkes.git/timn/protobuf-clips

- *Log* ---------------------------------------------------------------
commit d40e1ccd54d9252791bd3a64ce4efa3928564cf3
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Apr 24 21:29:56 2013 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri May 6 17:13:11 2016 +0200

    protobuf_clips: proper message validity checks

http://git.fawkesrobotics.org/fawkes.git/commit/d40e1cc
http://trac.fawkesrobotics.org/changeset/d40e1cc

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit f9473faa9cdde4b2526a0500b727209406c6283b
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Thu Apr 25 16:45:00 2013 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri May 6 17:16:24 2016 +0200

    protobuf_clips: some helpful debugging output
    
    In case of errors print something to the console.

http://git.fawkesrobotics.org/fawkes.git/commit/f9473fa
http://trac.fawkesrobotics.org/changeset/f9473fa

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit ca9855de93f78fbe23ea36b65c12100a095090dd
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Jun 12 15:57:32 2013 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri May 6 17:21:34 2016 +0200

    protobuf_clips: do not run agenda on events
    
    Events might be triggered from within the CLIPS environment, e.g. when
    explicitly disonnecting a client. This would lead to the successful
    acquisition of the (recursive) mutex lock. That in turn would cause the
    CLIPS environment's run() function to be called multiple times
    simultaneously corrupting the CLIPS context. Therefore, do not run the
    agenda from the communicator, but rely on the outside to invoke it.

http://git.fawkesrobotics.org/fawkes.git/commit/ca9855d
http://trac.fawkesrobotics.org/changeset/ca9855d

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit fd10f4d510501845070428938976598605d481e8
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Apr 17 23:27:57 2015 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri May 6 17:21:45 2016 +0200

    protobuf_clips: properly set rcvd-via slot

http://git.fawkesrobotics.org/fawkes.git/commit/fd10f4d
http://trac.fawkesrobotics.org/changeset/fd10f4d

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/libs/protobuf_clips/communicator.cpp |   17 +++++++----------
 src/libs/protobuf_clips/communicator.h   |    2 --
 2 files changed, 7 insertions(+), 12 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* d40e1ccd54d9252791bd3a64ce4efa3928564cf3 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Apr 24 21:29:56 2013 +0200
Subject: protobuf_clips: proper message validity checks

 src/libs/protobuf_clips/communicator.cpp |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_clips/communicator.cpp b/src/libs/protobuf_clips/communicator.cpp
index 763dfb0..f89bfb4 100644
--- a/src/libs/protobuf_clips/communicator.cpp
+++ b/src/libs/protobuf_clips/communicator.cpp
@@ -523,7 +523,7 @@ ClipsProtobufCommunicator::clips_pb_set_field(void *msgptr, std::string field_na
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!*m) return;
+  if (!(m && *m)) return;
 
   const Descriptor *desc       = (*m)->GetDescriptor();
   const FieldDescriptor *field = desc->FindFieldByName(field_name);
@@ -606,7 +606,7 @@ ClipsProtobufCommunicator::clips_pb_add_list(void *msgptr, std::string field_nam
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) return;
+  if (!(m && *m)) return;
 
   const Descriptor *desc       = (*m)->GetDescriptor();
   const FieldDescriptor *field = desc->FindFieldByName(field_name);
@@ -704,7 +704,7 @@ ClipsProtobufCommunicator::clips_pb_send(long int client_id, void *msgptr)
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) {
+  if (!(m && *m)) {
     if (logger_) {
       logger_->log_warn("CLIPS-Protobuf",
 			"Cannot send to %li: invalid message", client_id);
@@ -755,7 +755,7 @@ ClipsProtobufCommunicator::clips_pb_tostring(void *msgptr)
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) {
+  if (!(m && *m)) {
     if (logger_) {
       logger_->log_warn("CLIPS-Protobuf",
 			"Cannot convert message to string: invalid message");
@@ -772,7 +772,7 @@ ClipsProtobufCommunicator::clips_pb_broadcast(long int peer_id, void *msgptr)
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) {
+  if (!(m && *m)) {
     if (logger_) {
       logger_->log_warn("CLIPS-Protobuf", "Cannot send broadcast: invalid message");
     }
@@ -840,7 +840,7 @@ ClipsProtobufCommunicator::clips_pb_field_list(void *msgptr, std::string field_n
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) return CLIPS::Values(1, CLIPS::Value("INVALID-MESSAGE", CLIPS::TYPE_SYMBOL));
+  if (!(m && *m)) return CLIPS::Values(1, CLIPS::Value("INVALID-MESSAGE", CLIPS::TYPE_SYMBOL));
 
   const Descriptor *desc       = (*m)->GetDescriptor();
   const FieldDescriptor *field = desc->FindFieldByName(field_name);
@@ -925,7 +925,7 @@ ClipsProtobufCommunicator::clips_pb_field_is_list(void *msgptr, std::string fiel
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!(m || *m)) return CLIPS::Value("FALSE", CLIPS::TYPE_SYMBOL);
+  if (!(m && *m)) return CLIPS::Value("FALSE", CLIPS::TYPE_SYMBOL);
 
   const Descriptor *desc       = (*m)->GetDescriptor();
   const FieldDescriptor *field = desc->FindFieldByName(field_name);

- *commit* f9473faa9cdde4b2526a0500b727209406c6283b - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Thu Apr 25 16:45:00 2013 +0200
Subject: protobuf_clips: some helpful debugging output

 src/libs/protobuf_clips/communicator.cpp |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_clips/communicator.cpp b/src/libs/protobuf_clips/communicator.cpp
index f89bfb4..85894a2 100644
--- a/src/libs/protobuf_clips/communicator.cpp
+++ b/src/libs/protobuf_clips/communicator.cpp
@@ -458,7 +458,12 @@ ClipsProtobufCommunicator::clips_pb_field_value(void *msgptr, std::string field_
 {
   std::shared_ptr<google::protobuf::Message> *m =
     static_cast<std::shared_ptr<google::protobuf::Message> *>(msgptr);
-  if (!*m) return CLIPS::Value("INVALID-MESSAGE", CLIPS::TYPE_SYMBOL);
+  if (!(m && *m)) {
+		if (logger_) {
+			logger_->log_warn("CLIPS-Protobuf", "Invalid message when setting %s", field_name.c_str());
+		}
+		return CLIPS::Value("INVALID-MESSAGE", CLIPS::TYPE_SYMBOL);
+	}
 
   const Descriptor *desc       = (*m)->GetDescriptor();
   const FieldDescriptor *field = desc->FindFieldByName(field_name);

- *commit* ca9855de93f78fbe23ea36b65c12100a095090dd - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Jun 12 15:57:32 2013 +0200
Subject: protobuf_clips: do not run agenda on events

 src/libs/protobuf_clips/communicator.cpp |    8 --------
 src/libs/protobuf_clips/communicator.h   |    2 --
 2 files changed, 0 insertions(+), 10 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_clips/communicator.cpp b/src/libs/protobuf_clips/communicator.cpp
index 85894a2..d0c4cc3 100644
--- a/src/libs/protobuf_clips/communicator.cpp
+++ b/src/libs/protobuf_clips/communicator.cpp
@@ -1006,8 +1006,6 @@ ClipsProtobufCommunicator::handle_server_client_connected(ProtobufStreamServer::
   fawkes::MutexLocker lock(&clips_mutex_);
   clips_->assert_fact_f("(protobuf-server-client-connected %li %s %u)", client_id,
 			endpoint.address().to_string().c_str(), endpoint.port());
-  clips_->refresh_agenda();
-  clips_->run();
 }
 
 
@@ -1029,8 +1027,6 @@ ClipsProtobufCommunicator::handle_server_client_disconnected(ProtobufStreamServe
   if (client_id >= 0) {
     fawkes::MutexLocker lock(&clips_mutex_);
     clips_->assert_fact_f("(protobuf-server-client-disconnected %li)", client_id);
-    clips_->refresh_agenda();
-    clips_->run();
   }
 }
 
@@ -1133,8 +1129,6 @@ ClipsProtobufCommunicator::handle_client_connected(long int client_id)
 {
   fawkes::MutexLocker lock(&clips_mutex_);
   clips_->assert_fact_f("(protobuf-client-connected %li)", client_id);
-  clips_->refresh_agenda();
-  clips_->run();
 }
 
 void
@@ -1143,8 +1137,6 @@ ClipsProtobufCommunicator::handle_client_disconnected(long int client_id,
 {
   fawkes::MutexLocker lock(&clips_mutex_);
   clips_->assert_fact_f("(protobuf-client-disconnected %li)", client_id);
-  clips_->refresh_agenda();
-  clips_->run();
 }
 
 void
diff --git a/src/libs/protobuf_clips/communicator.h b/src/libs/protobuf_clips/communicator.h
index efb2e93..e549826 100644
--- a/src/libs/protobuf_clips/communicator.h
+++ b/src/libs/protobuf_clips/communicator.h
@@ -143,8 +143,6 @@ class ClipsProtobufCommunicator
   void          clips_pb_peer_setup_crypto(long int peer_id,
 					   std::string crypto_key, std::string cipher);
 
-  CLIPS::Value  clips_pb_connect(std::string host, int port);
-
 
   typedef enum {
     CT_SERVER, CT_CLIENT, CT_PEER

- *commit* fd10f4d510501845070428938976598605d481e8 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Apr 17 23:27:57 2015 +0200
Subject: protobuf_clips: properly set rcvd-via slot

 src/libs/protobuf_clips/communicator.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_clips/communicator.cpp b/src/libs/protobuf_clips/communicator.cpp
index d0c4cc3..f3a3171 100644
--- a/src/libs/protobuf_clips/communicator.cpp
+++ b/src/libs/protobuf_clips/communicator.cpp
@@ -956,7 +956,7 @@ ClipsProtobufCommunicator::clips_assert_message(std::pair<std::string, unsigned
     fact->set_slot("comp-id", comp_id);
     fact->set_slot("msg-type", msg_type);
     fact->set_slot("rcvd-via",
-      CLIPS::Value((client_id == 0) ? "BROADCAST" : "STREAM", CLIPS::TYPE_SYMBOL));
+		   CLIPS::Value((ct == CT_PEER) ? "BROADCAST" : "STREAM", CLIPS::TYPE_SYMBOL));
     CLIPS::Values rcvd_at(2, CLIPS::Value(CLIPS::TYPE_INTEGER));
     rcvd_at[0] = tv.tv_sec;
     rcvd_at[1] = tv.tv_usec;




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list