hologram-io / hologram-python

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!
https://hologram.io/
MIT License
89 stars 47 forks source link

Unable to receive data message from dashboard #71

Closed donbonjenbi closed 3 years ago

donbonjenbi commented 3 years ago

Describe the problem

Upon receiving a data message from the dashboard, I'm getting the following error:

Actual behavior

Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.7/dist-packages/Hologram/CustomCloud.py", line 336, in __incoming_connection_thread recv += result TypeError: can only concatenate str (not "bytes") to str

Steps to reproduce the behavior

result = hologram.network.connect()
hologram.initializeReceiveSocket()
for i in range(20):
   message = self.hologram.popReceivedMessage()
   print(f"Data_msg received:  {message}" if message else "no data_msg")

System information

donbonjenbi commented 3 years ago

I got it to work if I modify the following in CustomCloud.py:

    def __incoming_connection_thread(self, clientsocket):

        clientsocket.settimeout(RECEIVE_TIMEOUT)

        # Keep parsing the received data until timeout or receive no more data.
        recv = ''

changed to:

    def __incoming_connection_thread(self, clientsocket):

        clientsocket.settimeout(RECEIVE_TIMEOUT)

        # Keep parsing the received data until timeout or receive no more data.
        recv = b''
DomAmato commented 3 years ago

Thanks for pointing this out, ill make a fix for it

DomAmato commented 3 years ago

Should be fixed by https://github.com/hologram-io/hologram-python/pull/74