FreeCalypso > hg > freecalypso-tools
comparison loadtools/bpmain.c @ 85:c5766d12360d
fc-buzplay started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 27 Oct 2016 05:28:30 +0000 |
parents | loadtools/ltmain.c@e7502631a0f9 |
children | 96332d875fc9 |
comparison
equal
deleted
inserted
replaced
84:54a6864cabf4 | 85:c5766d12360d |
---|---|
1 /* | |
2 * This module contains the main() function for fc-buzplay | |
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_buzplayer_image[]; | |
15 extern void (*default_exit)(); | |
16 extern int gta_modem_poweron; | |
17 | |
18 extern struct baudrate *find_baudrate_by_name(); | |
19 | |
20 static struct baudrate *reattach; | |
21 | |
22 main(argc, argv) | |
23 char **argv; | |
24 { | |
25 extern char *optarg; | |
26 extern int optind; | |
27 int c; | |
28 char command[512]; | |
29 | |
30 while ((c = getopt(argc, argv, "a:b:c:C:h:H:i:nr:")) != EOF) | |
31 switch (c) { | |
32 case 'a': | |
33 iramimage.filename = optarg; | |
34 continue; | |
35 case 'b': | |
36 set_romload_baudrate(optarg); | |
37 continue; | |
38 case 'c': | |
39 set_compalstage_short(optarg); | |
40 continue; | |
41 case 'C': | |
42 set_compalstage_fullpath(optarg); | |
43 continue; | |
44 case 'h': | |
45 read_hwparam_file_shortname(optarg); | |
46 continue; | |
47 case 'H': | |
48 read_hwparam_file_fullpath(optarg); | |
49 continue; | |
50 case 'i': | |
51 set_beacon_interval(optarg); | |
52 continue; | |
53 case 'n': | |
54 gta_modem_poweron = 0; | |
55 continue; | |
56 case 'r': | |
57 reattach = find_baudrate_by_name(optarg); | |
58 if (!reattach) | |
59 exit(1); /* error msg already printed */ | |
60 continue; | |
61 case '?': | |
62 default: | |
63 usage: fprintf(stderr, | |
64 "usage: fc-buzplay [options] ttyport\n"); | |
65 exit(1); | |
66 } | |
67 if (argc - optind != 1) | |
68 goto usage; | |
69 target_ttydev = argv[optind]; | |
70 if (!iramimage.filename) | |
71 iramimage.filename = default_buzplayer_image; | |
72 | |
73 open_target_serial(); | |
74 if (reattach) | |
75 switch_baud_rate(reattach); | |
76 else { | |
77 perform_compal_stage(1); | |
78 perform_romload(); | |
79 putchar('\n'); | |
80 if (tpinterf_pass_output(1) < 0) | |
81 exit(1); | |
82 putchar('\n'); | |
83 } | |
84 for (;;) { | |
85 if (isatty(0)) { | |
86 fputs("buzplay> ", stdout); | |
87 fflush(stdout); | |
88 } | |
89 if (!fgets(command, sizeof command, stdin)) | |
90 default_exit(); | |
91 buzplay_dispatch_cmd(command); | |
92 } | |
93 } |