Fix a problem where an error is reported when only -P is specified.

This commit is contained in:
David Betz 2015-02-21 09:52:01 -05:00
parent c5cc730fb8
commit 76f6814f6b

View File

@ -45,6 +45,7 @@ int main(int argc, char *argv[])
int baudRate, baudRate2, verbose, terminalMode, pstMode, i;
int loadType = LOAD_TYPE_RUN;
int loadTypeOptionSeen = FALSE;
int actionSpecified = FALSE;
char *file = NULL;
long imageSize;
uint8_t *image;
@ -135,6 +136,7 @@ int main(int argc, char *argv[])
break;
case 'P':
ShowPorts(&state, PORT_PREFIX);
actionSpecified = TRUE;
break;
case 'r':
if (!loadTypeOptionSeen) {
@ -148,6 +150,7 @@ int main(int argc, char *argv[])
// fall through
case 't':
terminalMode = TRUE;
actionSpecified = TRUE;
break;
case 'v':
verbose = TRUE;
@ -165,30 +168,33 @@ int main(int argc, char *argv[])
if (file)
Usage();
file = argv[i];
actionSpecified = TRUE;
}
}
/* complain about nothing to do */
if (!file && !terminalMode) {
if (!actionSpecified) {
printf("error: must specify either a file to load or -t\n");
return 1;
}
/* open the serial port */
switch (InitPort(&state, PORT_PREFIX, port, baudRate, verbose, actualPort)) {
case CHECK_PORT_OK:
printf("Found propeller version %d on %s\n", state.version, actualPort);
break;
case CHECK_PORT_OPEN_FAILED:
printf("error: opening serial port '%s'\n", port);
perror("Error is ");
return 1;
case CHECK_PORT_NO_PROPELLER:
if (port)
printf("error: no propeller chip on port '%s'\n", port);
else
printf("error: can't find a port with a propeller chip\n");
return 1;
if (file || terminalMode) {
switch (InitPort(&state, PORT_PREFIX, port, baudRate, verbose, actualPort)) {
case CHECK_PORT_OK:
printf("Found propeller version %d on %s\n", state.version, actualPort);
break;
case CHECK_PORT_OPEN_FAILED:
printf("error: opening serial port '%s'\n", port);
perror("Error is ");
return 1;
case CHECK_PORT_NO_PROPELLER:
if (port)
printf("error: no propeller chip on port '%s'\n", port);
else
printf("error: can't find a port with a propeller chip\n");
return 1;
}
}
/* check for a file to load */