Skip to content

Commit 9ea79f2

Browse files
committedFeb 26, 2017
gpdevboard: Fixed bug in last commit causing board to not initialize correctly unless it's in bootloader mode
1 parent ff9f145 commit 9ea79f2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
 

‎src/gpdevboard/utils.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ hdevice OpenBoard(int nboard, bool test)
8282

8383
//Takes a while to switch and re-enumerate
8484
switching = true;
85-
for(int i=0; i<10; i++)
86-
{
87-
usleep(1000 * 1000);
88-
hdev = OpenDevice(0x0f0f, 0x0006, nboard);
89-
if(hdev)
90-
break;
91-
}
85+
}
86+
87+
//Try up to ten times to open the board if we're switching mode.
88+
//Stop after the first failure if we're not switching b/c there's no point.
89+
for(int i=0; i<10; i++)
90+
{
91+
hdev = OpenDevice(0x0f0f, 0x0006, nboard);
92+
if(hdev || !switching)
93+
break;
94+
95+
usleep(1000 * 1000);
9296
}
9397

9498
//By this point, it should be in "orange" mode

0 commit comments

Comments
 (0)
Please sign in to comment.