Example #1
0
// This function starts a new log file in the DataFlash
void DataFlash_Block::start_new_log(void)
{
    uint16_t last_page = find_last_page();

    StartRead(last_page);
    //Serial.print("last page: ");	Serial.println(last_page);
    //Serial.print("file #: ");	Serial.println(GetFileNumber());
    //Serial.print("file page: ");	Serial.println(GetFilePage());

    if(find_last_log() == 0 || GetFileNumber() == 0xFFFF) {
        SetFileNumber(1);
        StartWrite(1);
        //Serial.println("start log from 0");
        return;
    }

    // Check for log of length 1 page and suppress
    if(GetFilePage() <= 1) {
        SetFileNumber(GetFileNumber());                 // Last log too short, reuse its number
        StartWrite(last_page);                                          // and overwrite it
        //Serial.println("start log from short");
    } else {
        if(last_page == 0xFFFF) last_page=0;
        SetFileNumber(GetFileNumber()+1);
        StartWrite(last_page + 1);
        //Serial.println("start log normal");
    }
}
	void Plugin::checkSavedReports ()
	{
		const auto& dolozheeDir = Util::CreateIfNotExists ("dolozhee");

		auto news = dolozheeDir;
		if (!news.cd ("crashreports"))
			return;

		news.mkdir ("old");

		QStringList names;
		for (const auto& name : news.entryList (QDir::Files | QDir::NoDotAndDotDot))
		{
			const auto& newName = news.absoluteFilePath ("old/" + name);
			if (!QFile::rename (news.absoluteFilePath (name), newName))
				continue;

			names << newName;
		}

		if (names.isEmpty ())
			return;

		auto wizard = initiateReporting ();
		wizard->GetReportTypePage ()->ForceReportType (ReportTypePage::Type::Bug);

		auto attachPage = wizard->GetFilePage ();
		for (const auto& name : names)
			attachPage->AddFile (name);
	}
Example #3
0
/*
  dump header information from all log pages
 */
void DataFlash_Block::DumpPageInfo(AP_HAL::BetterStream *port)
{
    for (uint16_t count=1; count<=df_NumPages; count++) {
        StartRead(count);
        port->printf_P(PSTR("DF page, log file #, log page: %u,\t"), (unsigned)count);
        port->printf_P(PSTR("%u,\t"), (unsigned)GetFileNumber());
        port->printf_P(PSTR("%u\n"), (unsigned)GetFilePage());
    }
}
Example #4
0
// This function finds the last page of the last file
uint16_t DataFlash_Block::find_last_page(void)
{
    uint16_t look;
    uint16_t bottom = 1;
    uint16_t top = df_NumPages;
    uint32_t look_hash;
    uint32_t bottom_hash;
    uint32_t top_hash;

    StartRead(bottom);
    bottom_hash = ((int32_t)GetFileNumber()<<16) | GetFilePage();

    while(top-bottom > 1) {
        look = (top+bottom)/2;
        StartRead(look);
        look_hash = (int32_t)GetFileNumber()<<16 | GetFilePage();
        if (look_hash >= 0xFFFF0000) look_hash = 0;

        if(look_hash < bottom_hash) {
            // move down
            top = look;
        } else {
            // move up
            bottom = look;
            bottom_hash = look_hash;
        }
    }

    StartRead(top);
    top_hash = ((int32_t)GetFileNumber()<<16) | GetFilePage();
    if (top_hash >= 0xFFFF0000) {
        top_hash = 0;
    }
    if (top_hash > bottom_hash) {
        return top;
    }

    return bottom;
}
Example #5
0
// This function finds the last page of a particular log file
uint16_t DataFlash_Block::find_last_page_of_log(uint16_t log_number)
{
    uint16_t look;
    uint16_t bottom;
    uint16_t top;
    uint32_t look_hash;
    uint32_t check_hash;

    if(check_wrapped())
    {
        StartRead(1);
        bottom = GetFileNumber();
        if (bottom > log_number)
        {
            bottom = find_last_page();
            top = df_NumPages;
        } else {
            bottom = 1;
            top = find_last_page();
        }
    } else {
        bottom = 1;
        top = find_last_page();
    }

    check_hash = (int32_t)log_number<<16 | 0xFFFF;

    while(top-bottom > 1)
    {
        look = (top+bottom)/2;
        StartRead(look);
        look_hash = (int32_t)GetFileNumber()<<16 | GetFilePage();
        if (look_hash >= 0xFFFF0000) look_hash = 0;

        if(look_hash > check_hash) {
            // move down
            top = look;
        } else {
            // move up
            bottom = look;
        }
    }

    StartRead(top);
    if (GetFileNumber() == log_number) return top;

    StartRead(bottom);
    if (GetFileNumber() == log_number) return bottom;

    return -1;
}
Example #6
0
	void PreviewPage::initializePage ()
	{
		auto wiz = qobject_cast<ReportWizard*> (wizard ());
		if (!wiz)
			return;

		const auto typePage = wiz->GetReportTypePage ();
		const auto type = typePage->GetReportType ();

		QString title;
		QList<QPair<QString, QString>> sections;
		QString typeText;
		switch (type)
		{
		case ReportTypePage::Type::Bug:
			title = wiz->GetBugReportPage ()->GetTitle ();
			sections = wiz->GetBugReportPage ()->GetReportSections ();
			typeText = tr ("Bug");
			break;
		case ReportTypePage::Type::Feature:
			title = wiz->GetFRPage ()->GetTitle ();
			sections = wiz->GetFRPage ()->GetReportSections ();
			typeText = tr ("Feature");
			break;
		}

		QString preview = "<strong>User:</strong><br/>" +
				((wiz->GetChooseUserPage ()->GetUser () == ChooseUserPage::User::Anonymous) ?
					"Anonymous" :
					wiz->GetChooseUserPage ()->GetLogin ()) + "<br/><br/>";
		preview += "<strong>Title:</strong><br/>" + title + "<br/><br/>";
		preview += "<strong>Type:</strong><br/>" + typeText + "<br/><br/>";
		preview += "<strong>Category:</strong><br/>" + wiz->GetReportTypePage ()->GetCategoryName () + "<br/><br/>";
		preview += "<strong>Priority:</strong><br/>" + PriorityToString (wiz->GetReportTypePage ()->GetPriority ()) + "<br/><br/>";
		for (const auto& section : sections)
			preview += QString ("<strong>%1:</strong><br/>%2<br/><br/>")
					.arg (section.first)
					.arg (Util::Escape (section.second));
		preview += "<strong>Attached files:</strong><br/>" + wiz->GetFilePage ()->GetFiles ().join ("<br/>");

		preview.remove ("\r");
		preview.replace ("\n", "<br/>");

		Ui_.Preview_->setHtml (preview);
	}
Example #7
0
// This function starts a new log file in the DataFlash
uint16_t DataFlash_Block::start_new_log(void)
{
    uint16_t last_page = find_last_page();

    StartRead(last_page);
    //Serial.print("last page: ");	Serial.println(last_page);
    //Serial.print("file #: ");	Serial.println(GetFileNumber());
    //Serial.print("file page: ");	Serial.println(GetFilePage());

    if(find_last_log() == 0 || GetFileNumber() == 0xFFFF) {
        SetFileNumber(1);
        StartWrite(1);
        //Serial.println("start log from 0");
        log_write_started = true;
        return 1;
    }

    uint16_t new_log_num;

    // Check for log of length 1 page and suppress
    if(GetFilePage() <= 1) {
        new_log_num = GetFileNumber();
        // Last log too short, reuse its number
        // and overwrite it
        SetFileNumber(new_log_num);
        StartWrite(last_page);
    } else {
        new_log_num = GetFileNumber()+1;
        if (last_page == 0xFFFF) {
            last_page=0;
        }
        SetFileNumber(new_log_num);
        StartWrite(last_page + 1);
    }
    log_write_started = true;
    return new_log_num;
}