altos/test: Adjust CRC error rate after FEC fix
[fw/altos] / ao-tools / ao-view / aoview_main.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #include "aoview.h"
20
21 static const char aoview_glade[] = {
22 #include "aoview_glade.h"
23 };
24
25 static void usage(void) {
26         printf("aoview [--device|-d device_file]");
27         exit(1);
28 }
29
30 static void destroy_event(GtkWidget *widget, gpointer data)
31 {
32         gtk_main_quit();
33 }
34
35 char *aoview_tty = NULL;
36
37 int main(int argc, char **argv)
38 {
39         GladeXML *xml = NULL;
40         GtkWidget *mainwindow;
41         GtkAboutDialog *about_dialog;
42
43         static struct option long_options[] = {
44                 { "tty", 1, 0, 'T'},
45                 { 0, 0, 0, 0 }
46         };
47         for (;;) {
48                 int c, temp;
49
50                 c = getopt_long_only(argc, argv, "T:", long_options, &temp);
51                 if (c == -1)
52                         break;
53
54                 switch (c) {
55                 case 'T':
56                         aoview_tty = optarg;
57                         break;
58                 default:
59                         usage();
60                 }
61         }
62
63         g_thread_init(NULL);
64         gtk_init(&argc, &argv);
65         glade_init();
66
67         xml = glade_xml_new_from_buffer(aoview_glade, sizeof (aoview_glade), NULL, NULL);
68
69         /* connect the signals in the interface */
70         glade_xml_signal_autoconnect(xml);
71
72         /* Hook up the close button. */
73         mainwindow = glade_xml_get_widget(xml, "aoview");
74         assert(mainwindow);
75
76         g_signal_connect (G_OBJECT(mainwindow), "destroy",
77             G_CALLBACK(destroy_event), NULL);
78
79         about_dialog = GTK_ABOUT_DIALOG(glade_xml_get_widget(xml, "about_dialog"));
80         assert(about_dialog);
81         gtk_about_dialog_set_version(about_dialog, AOVIEW_VERSION);
82
83         aoview_voice_init(xml);
84
85         aoview_channel_init(xml);
86
87         aoview_dev_dialog_init(xml);
88
89         aoview_state_init(xml);
90
91         aoview_file_init(xml);
92
93         aoview_log_init(xml);
94
95         aoview_table_init(xml);
96
97         aoview_eeprom_init(xml);
98
99         aoview_replay_init(xml);
100
101         aoview_label_init(xml);
102
103         if (aoview_tty) {
104                 if (!aoview_monitor_connect(aoview_tty)) {
105                         perror(aoview_tty);
106                         exit(1);
107                 }
108         }
109         aoview_voice_speak("rocket flight monitor ready\n");
110
111         gtk_main();
112
113         return 0;
114 }