Skip to content

Commit

Permalink
Add firmware loader for the GIMX adapter #457
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Laurendeau committed Jun 14, 2017
1 parent a540470 commit e54b546
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions loader/gimx-loader.cpp
Expand Up @@ -38,10 +38,10 @@

using namespace std;

#define MAX_PORT 256
#define MAX_PORT_NB 257 // 0 to 256

#ifdef WIN32
static int check_port(int i) {
static void check_port(int i) {

char path[sizeof("\\\\.\\COM256")];
snprintf(path, sizeof(path), "\\\\.\\COM%d", i);
Expand All @@ -66,10 +66,10 @@ static int check_port(int i) {
}
#endif

static void list_ports(int ports[MAX_PORT]) {
static void list_ports(int ports[MAX_PORT_NB]) {

int i;
for (i = 1; i <= MAX_PORT; ++i) {
for (i = 0; i < MAX_PORT_NB; ++i) {
if (check_port(i) != -1) {
ports[i] = 1;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ void loaderFrame::OnButtonLoadClick(wxCommandEvent& event __attribute__((unused)
return;
}

int ports[MAX_PORT] = {};
int ports[MAX_PORT_NB] = {};

list_ports(ports);

Expand All @@ -222,14 +222,14 @@ void loaderFrame::OnButtonLoadClick(wxCommandEvent& event __attribute__((unused)
wxBusyInfo wait(_("Unplug/replug the USB cable (Pro Micro side of the adapter)."));

for (count = 0; count < 40; ++count) {
for (i = 0; i <= MAX_PORT; ++i) {
for (i = 0; i < MAX_PORT_NB; ++i) {
if (ports[i] == 0) {
if (check_port(i) != -1) {
break;
}
}
}
if (i <= MAX_PORT) {
if (i < MAX_PORT_NB) {
break;
}
usleep(250000);
Expand Down

0 comments on commit e54b546

Please sign in to comment.