void Logic::getMsg(QString msg) { // qDebug()<<msg; QRegExp regExp; regExp.setPattern("(\\d\\d)(\\d\\d)(\\d\\d).....(\\D).(\\d\\d)(\\d\\d.\\d{0,10}).(\\D).(\\d\\d\\d)(\\d\\d.\\d{0,10}).(\\D).(\\d{0,4}.\\d{0,4}).(\\d{0,3}.\\d{0,5})"); regExp.indexIn(msg); if(regExp.cap(0)!="") { m_gpsTime = regExp.cap(1)+":"+regExp.cap(2)+":"+regExp.cap(3); if(regExp.cap(4)=="A")//dostovernost'? { ship->setLongitude(regExp.cap(8).toDouble()+regExp.cap(9).toDouble()/60,regExp.cap(10)); ship->setLatitude(regExp.cap(5).toDouble()+regExp.cap(6).toDouble()/60,regExp.cap(7)); ship->setSpeed(regExp.cap(11).toDouble()); ship->setCourse(regExp.cap(12).toDouble()); emit updateShipPosition(); } } else { QStringList strList; strList = msg.split(','); if(strList[0]=="$GL") { if(strList[1] == "0") { gals->clear(); emit updateGals(0); return; } Gals* tmpGals= new Gals(); tmpGals->setNumGals(strList[1].toInt()); for(int i = 2;i<=strList.size()-4;i+=4) { QRegExp regExpLat; QRegExp regExpLon; regExpLat.setPattern("(\\d\\d)(\\d\\d.\\d{0,6})"); regExpLon.setPattern("(\\d\\d\\d)(\\d\\d.\\d{0,6})"); regExpLat.indexIn(" "+strList[i]); regExpLon.indexIn("d"+strList[i+2]); qDebug()<<regExpLon.cap(1)<<regExpLon.cap(2)<<"lon"<<strList[i+1]+strList[i+3]; qDebug()<<regExpLat.cap(1)<<regExpLat.cap(2)<<"lat"<<strList[i+1]+strList[i+3];//.toDouble()+regExpLat.cap(2).toDouble()/60<<regExpLon.cap(1).toDouble()+regExpLon.cap(2).toDouble()/60; tmpGals->addPoint(QPointF(regExpLon.cap(1).toDouble()+regExpLon.cap(2).toDouble()/60,regExpLat.cap(1).toDouble()+regExpLat.cap(2).toDouble()/60),strList[i+1]+strList[i+3]);// if degree.min //tmpGals->addPoint(QPointF(strList[i].toDouble(),strList[i+2].toDouble()),strList[i+1]+strList[i+3]); //if degree } gals->append(tmpGals); emit updateGals(1); } if(strList[0]=="$GLP") { qDebug()<<strList; emit setPlaneName(strList[1]); } if(strList[0] == "$DEV") { emit setDeviation(strList[1].toDouble()); } } }
void Si446x::init() { pinMode(VCXO_ENABLE_PIN, OUTPUT); pinMode(GPIO0_PIN, OUTPUT); digitalWrite(VCXO_ENABLE_PIN,HIGH); //Serial.println("VCXO is enabled"); delay(100); //ToDo: put the VCXO to mid frequency digitalWrite(RADIO_SDN_PIN, HIGH); // active high shutdown = reset delay(600); digitalWrite(RADIO_SDN_PIN, LOW); // booting //Serial.println("Radio is powered up"); // Start talking to the Si446X radio chip const char PART_INFO_command[] = {0x01}; // Part Info SendCmdReceiveAnswer(1, 9, PART_INFO_command); //Serial.println("Part info was checked"); //divide VCXO_FREQ into its bytes; MSB first unsigned int x3 = VCXO_FREQ / 0x1000000; unsigned int x2 = (VCXO_FREQ - x3 * 0x1000000) / 0x10000; unsigned int x1 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000) / 0x100; unsigned int x0 = (VCXO_FREQ - x3 * 0x1000000 - x2 * 0x10000 - x1 * 0x100); //POWER_UP const char init_command[] = {0x02, 0x01, 0x01, x3, x2, x1, x0};// no patch, boot main app. img, FREQ_VCXO, return 1 byte SendCmdReceiveAnswer(7, 1 ,init_command); //Serial.println("Radio booted"); const char get_int_status_command[] = {0x20, 0x00, 0x00, 0x00}; // Clear all pending interrupts and get the interrupt status back SendCmdReceiveAnswer(4, 9, get_int_status_command); //Serial.println("Radio ready"); const char gpio_pin_cfg_command[] = {0x13, 0x04, 0x02, 0x02, 0x02, 0x08, 0x11, 0x00}; // Set GPIO0 as input, all other GPIOs LOW; Link NIRQ to CTS; Link SDO to MISO; Max drive strength SendCmdReceiveAnswer(8, 8, gpio_pin_cfg_command); //Serial.println("LEDs should be switched off at this point"); sendFrequencyToSi446x(active_freq); //Serial.println("Frequency set"); setModem(); //Serial.println("CW mode set"); setDeviation(active_shift); tune_tx(); //Serial.println("TX tune"); setHighTone(); }