diff options
Diffstat (limited to 'src/host/osmocon')
-rw-r--r-- | src/host/osmocon/osmocon.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c index fb217b2b..0d5a3861 100644 --- a/src/host/osmocon/osmocon.c +++ b/src/host/osmocon/osmocon.c @@ -850,14 +850,16 @@ static int handle_read(void) printf("Received PROMPT1 from phone, responding with CMD\n"); dnload.print_hdlc = 0; dnload.state = WAITING_PROMPT2; - rc = write(dnload.serial_fd.fd, dnload_cmd, sizeof(dnload_cmd)); - - /* re-read file */ - rc = read_file(dnload.filename); - if (rc < 0) { - fprintf(stderr, "read_file(%s) failed with %d\n", - dnload.filename, rc); - exit(1); + if(dnload.filename) { + rc = write(dnload.serial_fd.fd, dnload_cmd, sizeof(dnload_cmd)); + + /* re-read file */ + rc = read_file(dnload.filename); + if (rc < 0) { + fprintf(stderr, "read_file(%s) failed with %d\n", + dnload.filename, rc); + exit(1); + } } } else if (!memcmp(buffer, phone_prompt2, sizeof(phone_prompt2))) { printf("Received PROMPT2 from phone, starting download\n"); @@ -1438,12 +1440,11 @@ int main(int argc, char **argv) } if (argc <= optind) { - fprintf(stderr, "You have to specify the filename\n"); - usage(argv[0]); + dnload.filename = NULL; + } else { + dnload.filename = argv[optind]; } - dnload.filename = argv[optind]; - dnload.serial_fd.fd = serial_init(serial_dev); if (dnload.serial_fd.fd < 0) { fprintf(stderr, "Cannot open serial device %s\n", serial_dev); |