Skip to content

Commit 5088495

Browse files
committed
fix bug
1 parent 79bcb94 commit 5088495

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pymycobot/common.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ def write(self, command, method=None):
467467
if method == "socket":
468468
log_command = []
469469
for i in command:
470-
if isinstance(i, str):
470+
if isinstance(command, str):
471+
log_command.append(command)
472+
elif isinstance(i, str):
471473
log_command.append(i)
472474
else:
473475
log_command.append(hex(i))
@@ -477,7 +479,11 @@ def write(self, command, method=None):
477479
if py_version == 2:
478480
self.sock.sendall("".join([chr(b) for b in command]))
479481
else:
480-
self.sock.sendall(bytes(command))
482+
if isinstance(command, str):
483+
command = command.encode()
484+
else:
485+
command = bytes(command)
486+
self.sock.sendall(command)
481487
else:
482488
self._serial_port.reset_input_buffer()
483489
self.log.debug("_write: {}".format([hex(i) for i in command]))

pymycobot/mybuddysocket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ def _mesg(self, genre, *args, **kwargs):
9393
"""
9494
real_command, has_reply = super(
9595
MyBuddySocket, self)._mesg(genre, *args, **kwargs)
96-
data = self._write(self._flatten(real_command), "socket")
97-
if data:
96+
self._write(self._flatten(real_command), "socket")
97+
if has_reply:
98+
data = self._read(genre, 'socket')
9899
res = self._process_received(data, genre, arm=12)
99100
if genre in [
100101
ProtocolCode.ROBOT_VERSION,

0 commit comments

Comments
 (0)