FreeCalypso > hg > freecalypso-sw
comparison loadtools/ltmain.c @ 22:e658a84b37df
loadtool coming along
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Sat, 04 May 2013 04:36:29 +0000 |
| parents | |
| children | aca1948e9713 |
comparison
equal
deleted
inserted
replaced
| 21:67a39d8914a8 | 22:e658a84b37df |
|---|---|
| 1 /* | |
| 2 * This module contains the main() function for fc-loadtool | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <stdint.h> | |
| 7 #include <stdio.h> | |
| 8 #include <stdlib.h> | |
| 9 #include <unistd.h> | |
| 10 #include "srecreader.h" | |
| 11 | |
| 12 extern char *target_ttydev; | |
| 13 extern struct srecreader iramimage; | |
| 14 extern char default_loadagent_image[]; | |
| 15 | |
| 16 char loadtool_command[512]; | |
| 17 | |
| 18 main(argc, argv) | |
| 19 char **argv; | |
| 20 { | |
| 21 extern char *optarg; | |
| 22 extern int optind; | |
| 23 int c; | |
| 24 | |
| 25 while ((c = getopt(argc, argv, "a:h:H:i:")) != EOF) | |
| 26 switch (c) { | |
| 27 case 'a': | |
| 28 iramimage.filename = optarg; | |
| 29 continue; | |
| 30 case 'h': | |
| 31 read_hwparam_file_shortname(optarg); | |
| 32 continue; | |
| 33 case 'H': | |
| 34 read_hwparam_file_fullpath(optarg); | |
| 35 continue; | |
| 36 case 'i': | |
| 37 set_beacon_interval(optarg); | |
| 38 continue; | |
| 39 case '?': | |
| 40 default: | |
| 41 usage: fprintf(stderr, | |
| 42 "usage: fc-loadtool [options] ttyport\n"); | |
| 43 exit(1); | |
| 44 } | |
| 45 if (argc - optind != 1) | |
| 46 goto usage; | |
| 47 target_ttydev = argv[optind]; | |
| 48 if (!iramimage.filename) | |
| 49 iramimage.filename = default_loadagent_image; | |
| 50 | |
| 51 open_target_serial(); | |
| 52 perform_romload(); | |
| 53 putchar('\n'); | |
| 54 if (tpinterf_pass_output() < 0) { | |
| 55 fprintf(stderr, | |
| 56 "loadtool error: no '=' prompt received from target\n"); | |
| 57 exit(1); | |
| 58 } | |
| 59 for (;;) { | |
| 60 if (isatty(0)) { | |
| 61 fputs("loadtool> ", stdout); | |
| 62 fflush(stdout); | |
| 63 } | |
| 64 if (!fgets(loadtool_command, sizeof loadtool_command, stdin)) | |
| 65 exit(0); | |
| 66 loadtool_dispatch_cmd(); | |
| 67 } | |
| 68 } |
