Help me fix a problem

17 views
Skip to first unread message

Spencer Du

unread,
Sep 6, 2019, 11:53:59 AM9/6/19
to MQTT
Hi 

I want to print yes in gui.py but it does not get printed because of the json. How do I fix this. Execute embedded.py and then gui.py to test.

Regards 
Spencer
embedded.py
gui.py
mqtt.py

Nick O'Leary

unread,
Sep 6, 2019, 12:09:09 PM9/6/19
to mq...@googlegroups.com
Hi,

this mailing list is about the MQTT protocol in general - it isn't a support forum for specific client libraries or languages.

Given you've not had much response on your previous questions along these lines, you may need to find a more appropriate forum to ask in.



--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mqtt/3fe0b7ca-757a-47d0-ad4f-42172127507d%40googlegroups.com.

Julien Christophe

unread,
Sep 6, 2019, 2:55:40 PM9/6/19
to mq...@googlegroups.com
Hello!

I think it is a pure python question, but it is occulted because of the library you use. 

In the line :

if msg.payload[name] == "Hello world!": print("yes")


The variable "name" isn't defined, but as it is in an handler, i think you don't got the exception thrown in the main thread. 

You probably wanted to provide the string "name" instead. 

Another thing : you "decode" the message payload, it probably just decode from bytes to str, then you have to parse it again ("decode") to have a json data structure. 

I didn't try but this is my first thoughts.

Please provide more logs about what happens next time ;) 

Programingly speaking, you could also catch the whole function exceptions to see better which exceptions could happend, or add an "else" clause with logs :) 

Regards, 
Julien

Spencer Du

unread,
Sep 7, 2019, 4:24:38 PM9/7/19
to MQTT
So how do I do this:

"Another thing : you "decode" the message payload, it probably just decode from bytes to str, then you have to parse it again ("decode") to have a json data structure."

Regards 
Spencer
To unsubscribe from this group and stop receiving emails from it, send an email to mq...@googlegroups.com.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mq...@googlegroups.com.

Julien Christophe

unread,
Sep 7, 2019, 4:33:13 PM9/7/19
to mq...@googlegroups.com
Stack ovetflow is your friend ;)



To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mqtt/b2b23643-d535-4630-964c-f808aac931a2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages