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,16 +168,18 @@ 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 */
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);
@ -190,6 +195,7 @@ int main(int argc, char *argv[])
printf("error: can't find a port with a propeller chip\n");
return 1;
}
}
/* check for a file to load */
if (file) {