2 * This file is part of the sigrok-qt project.
4 * Copyright (C) 2010-2012 Uwe Hermann <uwe@hermann-uwe.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
24 #include <libsigrok/libsigrok.h>
28 #include <QtGui/QApplication>
29 #include <QTranslator>
32 #include "mainwindow.h"
34 uint8_t *sample_buffer;
37 int main(int argc, char *argv[])
39 QString locale = QLocale::system().name();
40 QApplication a(argc, argv);
41 QTranslator translator;
42 struct sr_context *sr_ctx;
43 sr_dev_driver **drivers;
46 translator.load(QString("locale/sigrok-qt_") + locale);
47 a.installTranslator(&translator);
49 /* Set some application metadata. */
50 QApplication::setApplicationVersion(APP_VERSION);
51 QApplication::setApplicationName("sigrok-qt");
52 QApplication::setOrganizationDomain("http://www.sigrok.org");
54 /* Disable this to actually allow running the (pre-alpha!) Qt GUI. */
55 qDebug() << "The Qt GUI is not yet usable, aborting.";
58 if ((ret = sr_init(&sr_ctx)) != SR_OK) {
59 qDebug() << "ERROR: libsigrok init failed (%s): %s."
60 << sr_strerror_name(ret), sr_strerror(ret);
63 qDebug() << "libsigrok initialized successfully.";
65 /* Initialize all libsigrok drivers. */
66 drivers = sr_driver_list();
67 for (int i = 0; drivers[i]; ++i) {
68 if (sr_driver_init(sr_ctx, drivers[i]) != SR_OK) {
69 qDebug("Failed to initialize driver '%s'.",
75 if (srd_init(NULL) != SRD_OK) {
76 qDebug() << "ERROR: libsigrokdecode init failed.";
79 qDebug() << "libsigrokdecode initialized successfully.";
84 /* The GUI wants to show a list of all PDs before use, so we
85 * might as well load them now.
87 srd_decoder_load_all();
89 /* Run the application. */
92 /* Shutdown libsigrok. */
93 if ((ret = sr_exit(sr_ctx)) != SR_OK) {
94 qDebug() << "ERROR: libsigrok shutdown failed (%s): %s."
95 << sr_strerror_name(ret), sr_strerror(ret);
97 qDebug() << "libsigrok shutdown was successful.";
99 /* Shutdown libsigrokdecode. */
100 if ((ret = srd_exit()) != SRD_OK) {
101 qDebug() << "ERROR: libsigrokdecode shutdown failed: %d.";
103 qDebug() << "libsigrokdecode shutdown was successful.";