Skip to content

Commit f5f0134

Browse files
noopwafeljannau
authored andcommitted
proxy: wait for device to reappear
Signed-off-by: Alyssa Milburn <[email protected]>
1 parent ba6835d commit f5f0134

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

proxyclient/m1n1/proxy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def __init__(self, device=None, debug=False):
149149
self.devpath = device
150150
self.baudrate = baud
151151

152+
# wait for it to come back
153+
if os.environ.get("M1N1WAIT", 0) and not os.path.exists(self.devpath):
154+
print("Waiting for %s to appear.." % self.devpath)
155+
for n in range(100): # 10s
156+
time.sleep(0.1)
157+
if os.path.exists(self.devpath):
158+
break
159+
time.sleep(0.1) # wait for udev to settle (avoid permissions issues)
160+
152161
device = Serial(self.devpath, baud)
153162

154163
self.dev = device

0 commit comments

Comments
 (0)