UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) { m_config = new Ui_UploaderWidget(); m_config->setupUi(this); currentStep = IAP_STATE_READY; resetOnly=false; dfu = NULL; m_timer = 0; m_progress = 0; // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); getSerialPorts(); QIcon rbi; rbi.addFile(QString(":uploader/images/view-refresh.svg")); m_config->refreshPorts->setIcon(rbi); connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) onAutopilotConnect(); }
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) { m_config = new Ui_UploaderWidget(); m_config->setupUi(this); currentStep = IAP_STATE_READY; rescueStep = RESCUE_STEP0; resetOnly=false; dfu = NULL; // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // Note: remove listening to the connection manager, it overlaps with // listening to the telemetry manager, we should only listen to one, not both. // Also listen to disconnect actions from the user: // Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); // connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onAutopilotDisconnect())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(goToBootloader())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); getSerialPorts(); QIcon rbi; rbi.addFile(QString(":uploader/images/view-refresh.svg")); m_config->refreshPorts->setIcon(rbi); connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts())); }
void checkSerial() { int16_t x ; while ( ( x = get_fifo32() ) != -1 ) { uint8_t y = x ; switch ( SerialInputState ) { case SI_WAIT_FIRST : #ifdef SERIAL_RECEIVE if ( y == 0x20 ) { if ( LastSerialRx == 0x30 ) { // Go to Bootloader goToBootloader() ; } } else if ( ( y == 0x1B ) || ( y == 0x1C ) ) { // tx_single_byte( 'E' ) ; if ( LastSerialRx == 0x1B ) { // tx_single_byte( 'F' ) ; BootReason = (y - 0x1A) ; } } else #endif if ( y == 0x1D ) { SerialInputState = SI_GET_COUNT_BL ; } else if ( y == 0x1F ) { SerialInputState = SI_GET_COUNT_V ; } break ; case SI_GET_COUNT_BL : SerialInputState = SI_GET_BL ; break ; case SI_GET_COUNT_V : SerialInputState = SI_GET_VL ; break ; case SI_GET_BL : if ( y ) { PORTB |= 2 ; } else { PORTB &= 0xFD ; } SerialInputState = SI_WAIT_FIRST ; break ; case SI_GET_VL : SerialInputLow = y ; SerialInputState = SI_GET_VH ; break ; case SI_GET_VH : x = SerialInputLow | (y << 8 ) ; Command = x ; GPIOR0 |= 0x20 ; SerialInputState = SI_WAIT_FIRST ; break ; } LastSerialRx = y ; } }