소스 검색

decode payload as utf string before splitting

David 8 년 전
부모
커밋
cc9da85044
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      camera1/rotate-servo.py

+ 3 - 2
camera1/rotate-servo.py

@@ -20,9 +20,10 @@ def on_message(client, userdata, msg):
     if msg.topic == "video/servo1/restart":
     if msg.topic == "video/servo1/restart":
         restart_servos()
         restart_servos()
     if msg.topic == "video/servo1/rotate":
     if msg.topic == "video/servo1/rotate":
-        servo_arg = msg.payload.split()[0]
+        payload = msg.payload.decode("utf-8", errors="ignore")
+        servo_arg = payload.split()[0]
         try:
         try:
-            offset = int(msg.payload.split()[1])
+            offset = int(payload.split()[1])
         except:
         except:
             return
             return
         servo = -1
         servo = -1