Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyboard.py Fix for rshell issue #7 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion rshell/pyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,22 @@ def __init__(self, device, baudrate=115200, user='micro', password='python'):
self.serial = TelnetToSerial(device, user, password, read_timeout=10)
else:
import serial
self.serial = serial.Serial(device, baudrate=baudrate, interCharTimeout=1)
done = False
for attempt in range(20):
try:
self.serial = serial.Serial(device, baudrate=baudrate, interCharTimeout=1)
done = True
break
except OSError:
if attempt == 0:
sys.stdout.write('Waiting for pyboard ')
time.sleep(1)
sys.stdout.write('.')
sys.stdout.flush()
print()
if not done:
print("Failed to access device")
sys.exit(1)

def close(self):
self.serial.close()
Expand Down