Exemplo n.º 1
0
void Cmd_ListFlags(ITEM *i)
{
/*
 *	LISTFLAG lists all flags, LISTFLAG @NAME lists flag 'name'
 *	LISTFLAG n lists flag n
 */
	int v;
	GetAll();
	if(!strlen(WordBuffer))
	{
		short c=0;
		while(c<512)
		{
			if(FlagName[c])
				SendItem(i,"%-3d   %s\n",c,GetFlagName(c)+1);
			c++;
		}
		return;
	}
	if(sscanf(WordBuffer,"%d",&v)==0)
	{
		if(*WordBuffer=='@')
		{
			if(GetFlagByName(WordBuffer))
				SendItem(i,"%-3d     %s\n",
					GetFlagByName(WordBuffer),WordBuffer);
			return;
		}
		else
			SendItem(i,"Flag names always start with '@'.\n");
	}
	else
	{
		if(FlagName[v])
		{
			SendItem(i,"%-3d     %s\n",v,GetFlagName((short)v));
		}
	}
}
void AtmelSWIAnalyzerResults::GenerateExportFile(const char* file, DisplayBase display_base, U32 export_type_user_id)
{
	std::ofstream file_stream(file, std::ios::out);

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	Frame f;
	char time_str[128], number_str[128];
	const U64 num_frames = GetNumFrames();
	std::vector<std::string> texts;
	for (U64 fcnt = 0; fcnt < num_frames; fcnt++)
	{
		// get the frame
		f = GetFrame(fcnt);

		// make the time string
		AnalyzerHelpers::GetTimeString(f.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, sizeof(time_str));

		switch (f.mType)
		{
		case FrameToken:
			file_stream << "Token ";

			if (f.mData1 == SWI_Wake)
				file_stream << "Wake";
			else if (f.mData1 == SWI_One)
				file_stream << "One";
			else if (f.mData1 == SWI_Zero)
				file_stream << "Zero";

			file_stream << " at " << time_str << std::endl << std::endl;

			break;
		case FrameByte:
			AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, sizeof(number_str));
			file_stream << "Byte (" << number_str << ") at " << time_str << std::endl;
			break;
		case FrameFlag:
			AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, sizeof(number_str));
			file_stream << "Flag " << GetFlagName(static_cast<SWI_Flag>(f.mData1)) 
						<< " (" << number_str << ") at " << time_str << std::endl << std::endl;
			break;
		case FrameCount:
			// start the IO block section and write the count byte
			AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, sizeof(number_str));
			file_stream << "I/O Block at " << time_str << std::endl;
			file_stream << "Count (" << number_str << ")" << std::endl;

			break;
		case FramePacketSegment:

			// get the packet segment texts
			GetTextsForPacketSegmentFrame(f, display_base, texts);
			file_stream << texts.front() << std::endl;

			break;
		case FrameChecksum:

			// get the checksum texts
			GetTextsForChecksumFrame(f, display_base, texts);
			file_stream << texts.front() << std::endl << std::endl;

			break;
		}

		if (UpdateExportProgressAndCheckForCancel(fcnt, num_frames))
			return;
	}

	// end
	UpdateExportProgressAndCheckForCancel(num_frames, num_frames);
}
void AtmelSWIAnalyzerResults::GenerateBubbleText(U64 frame_index, Channel& channel, DisplayBase display_base)
{
	const int BUFF_SIZE = 128;
	char number_str[BUFF_SIZE];
	ClearResultStrings();
	Frame f = GetFrame(frame_index);

	if (f.mType == FrameToken)
	{
		if (f.mData1 == SWI_Wake)
		{
			AddResultString("Wake");
			AddResultString("Token Wake");
		} else if (f.mData1 == SWI_One) {
			AddResultString("1");
			AddResultString("One");
			AddResultString("Token One");
		} else if (f.mData1 == SWI_Zero) {
			AddResultString("0");
			AddResultString("Zero");
			AddResultString("Token Zero");
		}

	} else if (f.mType == FrameByte) {
		AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, BUFF_SIZE);
		AddResultString(number_str);

	} else if (f.mType == FrameChecksum) {

		std::vector<std::string> texts;
		GetTextsForChecksumFrame(f, display_base, texts);

		std::vector<std::string>::iterator i(texts.begin());
		while (i != texts.end())
		{
			AddResultString(i->c_str());
			++i;
		}

	} else if (f.mType == FrameFlag) {
		AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, BUFF_SIZE);
		AddResultString(number_str);
		if (f.mData2)
		{
			const char* FlagName = GetFlagName(static_cast<SWI_Flag>(f.mData1));
			AddResultString(FlagName);
			AddResultString("Flag ", FlagName, " (", number_str, ")");
		} else {
			AddResultString("Bad Flag (", number_str, ")");
		}

	} else if (f.mType == FrameCount) {
		AnalyzerHelpers::GetNumberString(f.mData1, display_base, 8, number_str, BUFF_SIZE);
		AddResultString(number_str);
		AddResultString("Count (", number_str, ")");

	} else if (f.mType == FramePacketSegment) {

		std::vector<std::string> texts;
		GetTextsForPacketSegmentFrame(f, display_base, texts);

		std::vector<std::string>::iterator i(texts.begin());
		while (i != texts.end())
		{
			AddResultString(i->c_str());
			++i;
		}
	}
}