int main( int argc, char *argv[] ) { bool need_config_sync = false; int timeout = 3000; int timezone = 0; QApplication a(argc, argv); QTextCodec *codec = QTextCodec::codecForName("utf8"); QTextCodec::setCodecForTr( codec ); QCoreApplication::setOrganizationName("KamertonUberSoft"); QCoreApplication::setApplicationName("telemetry"); QSettings *config = new QSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); if (!config->contains("port")) need_config_sync = true; QString portname = config->value("port", DEFAULT_PORT_NAME).toString(); config->setValue("port", portname); if (need_config_sync) config->sync(); QextSerialPort *p = new QextSerialPort(portname); p->open(QextSerialPort::ReadWrite); p->setBaudRate(BAUD115200); HUD2 *window = new HUD2(p, timeout, timezone); window->show(); return a.exec(); }
void ArduinoDriver::run() { QextSerialPort port; thread_port = &port; port.setPortName(QString(m_portname.c_str())); port.setBaudRate(BAUD9600); connect(&port, SIGNAL(readyRead()), this, SLOT(onDataAvailable())); if(!port.open(QIODevice::ReadWrite)) { qDebug() << "cannot connect to " << port.portName(); return; } arduinoSetup = true; exec(); //thread ended, cleanup if (port.lineStatus() != 0) { qDebug() << "closing port"; port.close(); } }