tools, pyboard.py: Allow exec argument to be bytes or str.

This commit is contained in:
Damien George 2014-10-19 14:54:52 +01:00
parent 1a55b6a787
commit 9c9db3a7a1
1 changed files with 4 additions and 1 deletions

View File

@ -71,7 +71,10 @@ class Pyboard:
return ret
def exec(self, command):
command_bytes = bytes(command, encoding='ascii')
if isinstance(command, bytes):
command_bytes = command
else:
command_bytes = bytes(command, encoding='ascii')
for i in range(0, len(command_bytes), 32):
self.serial.write(command_bytes[i:min(i+32, len(command_bytes))])
time.sleep(0.01)