Skip to content

Commit

Permalink
logging for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sasilva1998 committed Sep 20, 2020
1 parent d5ca030 commit 5bed97a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/uros/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from rosserial_msgs import TopicInfo
import sys
import os
import logging

# for now threads are used, will be changed with asyncio in the future
if sys.platform == "esp32":
Expand All @@ -24,6 +25,8 @@
# rosserial protocol header
header = [0xFF, 0xFE]

logging.basicConfig(level=logging.INFO)

# class to manage publish and subscribe
# COULD BE CHANGED AFTERWARDS
class NodeHandle(object):
Expand Down Expand Up @@ -87,7 +90,7 @@ def _advertise_topic(self, topic_name, msg, endpoint, buffer_size):
try:
register.buffer_size = buffer_size
except Exception as e:
print("No buffer size could be defined for topic negotiation.")
logging.info("No buffer size could be defined for topic negotiation.")

# serialization
packet = uio.StringIO()
Expand Down Expand Up @@ -164,9 +167,7 @@ def _listen(self):
# incoming object msg initialized
msgobj = self.subscribing_topics.get(inid)[0]
except Exception:
print(
"TX request was made or got message from not available subscribed topic."
)
logging.info("TX request was made or got message from not available subscribed topic.")
# object sent to callback
callback = self.subscribing_topics.get(inid)[1]
fdata = msgobj()
Expand All @@ -176,7 +177,7 @@ def _listen(self):
raise ValueError("Message plus Topic ID Checksum is wrong!")

except Exception as e:
print("No incoming data could be read for subscribes.")
logging.info("No incoming data could be read for subscribes.")


# functions to be used in class
Expand Down

0 comments on commit 5bed97a

Please sign in to comment.