added Simple Serial Analyzer source and VS project.
This commit is contained in:
parent
1c420ee1b8
commit
2770b314a8
|
@ -0,0 +1,3 @@
|
|||
[submodule "AnalyzerSDK"]
|
||||
path = AnalyzerSDK
|
||||
url = ../AnalyzerSDK.git
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 31af8aa1576c397c9b95eee92b1b7bc49e04e18e
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSerialAnalyzer", "SimpleSerialAnalyzer.vcxproj", "{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|x64.Build.0 = Debug|x64
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|Win32.Build.0 = Release|Win32
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|x64.ActiveCfg = Release|x64
|
||||
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,183 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}</ProjectGuid>
|
||||
<RootNamespace>SimpleSerialAnalyzer</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>14.0.24720.0</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\AnalyzerSDK\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLESERIALANALYZER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Analyzer.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\AnalyzerSDK\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\AnalyzerSDK\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLESERIALANALYZER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Analyzer64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\AnalyzerSDK\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\AnalyzerSDK\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLESERIALANALYZER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Analyzer.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\AnalyzerSDK\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\AnalyzerSDK\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLESERIALANALYZER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Analyzer64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\AnalyzerSDK\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Source\SimpleSerialAnalyzer.cpp" />
|
||||
<ClCompile Include="..\Source\SimpleSerialAnalyzerResults.cpp" />
|
||||
<ClCompile Include="..\Source\SimpleSerialAnalyzerSettings.cpp" />
|
||||
<ClCompile Include="..\Source\SimpleSerialSimulationDataGenerator.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Source\SimpleSerialAnalyzer.h" />
|
||||
<ClInclude Include="..\Source\SimpleSerialAnalyzerResults.h" />
|
||||
<ClInclude Include="..\Source\SimpleSerialAnalyzerSettings.h" />
|
||||
<ClInclude Include="..\Source\SimpleSerialSimulationDataGenerator.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,111 @@
|
|||
#include "SimpleSerialAnalyzer.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include <AnalyzerChannelData.h>
|
||||
|
||||
SimpleSerialAnalyzer::SimpleSerialAnalyzer()
|
||||
: Analyzer(),
|
||||
mSettings( new SimpleSerialAnalyzerSettings() ),
|
||||
mSimulationInitilized( false )
|
||||
{
|
||||
SetAnalyzerSettings( mSettings.get() );
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzer::~SimpleSerialAnalyzer()
|
||||
{
|
||||
KillThread();
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzer::WorkerThread()
|
||||
{
|
||||
mResults.reset( new SimpleSerialAnalyzerResults( this, mSettings.get() ) );
|
||||
SetAnalyzerResults( mResults.get() );
|
||||
mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
||||
|
||||
mSampleRateHz = GetSampleRate();
|
||||
|
||||
mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
||||
|
||||
if( mSerial->GetBitState() == BIT_LOW )
|
||||
mSerial->AdvanceToNextEdge();
|
||||
|
||||
U32 samples_per_bit = mSampleRateHz / mSettings->mBitRate;
|
||||
U32 samples_to_first_center_of_first_data_bit = U32( 1.5 * double( mSampleRateHz ) / double( mSettings->mBitRate ) );
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
U8 data = 0;
|
||||
U8 mask = 1 << 7;
|
||||
|
||||
mSerial->AdvanceToNextEdge(); //falling edge -- beginning of the start bit
|
||||
|
||||
U64 starting_sample = mSerial->GetSampleNumber();
|
||||
|
||||
mSerial->Advance( samples_to_first_center_of_first_data_bit );
|
||||
|
||||
for( U32 i=0; i<8; i++ )
|
||||
{
|
||||
//let's put a dot exactly where we sample this bit:
|
||||
mResults->AddMarker( mSerial->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mInputChannel );
|
||||
|
||||
if( mSerial->GetBitState() == BIT_HIGH )
|
||||
data |= mask;
|
||||
|
||||
mSerial->Advance( samples_per_bit );
|
||||
|
||||
mask = mask >> 1;
|
||||
}
|
||||
|
||||
|
||||
//we have a byte to save.
|
||||
Frame frame;
|
||||
frame.mData1 = data;
|
||||
frame.mFlags = 0;
|
||||
frame.mStartingSampleInclusive = starting_sample;
|
||||
frame.mEndingSampleInclusive = mSerial->GetSampleNumber();
|
||||
|
||||
mResults->AddFrame( frame );
|
||||
mResults->CommitResults();
|
||||
ReportProgress( frame.mEndingSampleInclusive );
|
||||
}
|
||||
}
|
||||
|
||||
bool SimpleSerialAnalyzer::NeedsRerun()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
U32 SimpleSerialAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels )
|
||||
{
|
||||
if( mSimulationInitilized == false )
|
||||
{
|
||||
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() );
|
||||
mSimulationInitilized = true;
|
||||
}
|
||||
|
||||
return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
|
||||
}
|
||||
|
||||
U32 SimpleSerialAnalyzer::GetMinimumSampleRateHz()
|
||||
{
|
||||
return mSettings->mBitRate * 4;
|
||||
}
|
||||
|
||||
const char* SimpleSerialAnalyzer::GetAnalyzerName() const
|
||||
{
|
||||
return "Simple Serial";
|
||||
}
|
||||
|
||||
const char* GetAnalyzerName()
|
||||
{
|
||||
return "Simple Serial";
|
||||
}
|
||||
|
||||
Analyzer* CreateAnalyzer()
|
||||
{
|
||||
return new SimpleSerialAnalyzer();
|
||||
}
|
||||
|
||||
void DestroyAnalyzer( Analyzer* analyzer )
|
||||
{
|
||||
delete analyzer;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef SIMPLESERIAL_ANALYZER_H
|
||||
#define SIMPLESERIAL_ANALYZER_H
|
||||
|
||||
#include <Analyzer.h>
|
||||
#include "SimpleSerialAnalyzerResults.h"
|
||||
#include "SimpleSerialSimulationDataGenerator.h"
|
||||
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
class ANALYZER_EXPORT SimpleSerialAnalyzer : public Analyzer
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzer();
|
||||
virtual ~SimpleSerialAnalyzer();
|
||||
virtual void WorkerThread();
|
||||
|
||||
virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels );
|
||||
virtual U32 GetMinimumSampleRateHz();
|
||||
|
||||
virtual const char* GetAnalyzerName() const;
|
||||
virtual bool NeedsRerun();
|
||||
|
||||
protected: //vars
|
||||
std::auto_ptr< SimpleSerialAnalyzerSettings > mSettings;
|
||||
std::auto_ptr< SimpleSerialAnalyzerResults > mResults;
|
||||
AnalyzerChannelData* mSerial;
|
||||
|
||||
SimpleSerialSimulationDataGenerator mSimulationDataGenerator;
|
||||
bool mSimulationInitilized;
|
||||
|
||||
//Serial analysis vars:
|
||||
U32 mSampleRateHz;
|
||||
U32 mStartOfStopBitOffset;
|
||||
U32 mEndOfStopBitOffset;
|
||||
};
|
||||
|
||||
extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
|
||||
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer( );
|
||||
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_H
|
|
@ -0,0 +1,81 @@
|
|||
#include "SimpleSerialAnalyzerResults.h"
|
||||
#include <AnalyzerHelpers.h>
|
||||
#include "SimpleSerialAnalyzer.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
SimpleSerialAnalyzerResults::SimpleSerialAnalyzerResults( SimpleSerialAnalyzer* analyzer, SimpleSerialAnalyzerSettings* settings )
|
||||
: AnalyzerResults(),
|
||||
mSettings( settings ),
|
||||
mAnalyzer( analyzer )
|
||||
{
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzerResults::~SimpleSerialAnalyzerResults()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base )
|
||||
{
|
||||
ClearResultStrings();
|
||||
Frame frame = GetFrame( frame_index );
|
||||
|
||||
char number_str[128];
|
||||
AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );
|
||||
AddResultString( number_str );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::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();
|
||||
|
||||
file_stream << "Time [s],Value" << std::endl;
|
||||
|
||||
U64 num_frames = GetNumFrames();
|
||||
for( U32 i=0; i < num_frames; i++ )
|
||||
{
|
||||
Frame frame = GetFrame( i );
|
||||
|
||||
char time_str[128];
|
||||
AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );
|
||||
|
||||
char number_str[128];
|
||||
AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );
|
||||
|
||||
file_stream << time_str << "," << number_str << std::endl;
|
||||
|
||||
if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
|
||||
{
|
||||
file_stream.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
file_stream.close();
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateFrameTabularText( U64 frame_index, DisplayBase display_base )
|
||||
{
|
||||
Frame frame = GetFrame( frame_index );
|
||||
ClearResultStrings();
|
||||
|
||||
char number_str[128];
|
||||
AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );
|
||||
AddResultString( number_str );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GeneratePacketTabularText( U64 packet_id, DisplayBase display_base )
|
||||
{
|
||||
ClearResultStrings();
|
||||
AddResultString( "not supported" );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base )
|
||||
{
|
||||
ClearResultStrings();
|
||||
AddResultString( "not supported" );
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef SIMPLESERIAL_ANALYZER_RESULTS
|
||||
#define SIMPLESERIAL_ANALYZER_RESULTS
|
||||
|
||||
#include <AnalyzerResults.h>
|
||||
|
||||
class SimpleSerialAnalyzer;
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
|
||||
class SimpleSerialAnalyzerResults : public AnalyzerResults
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzerResults( SimpleSerialAnalyzer* analyzer, SimpleSerialAnalyzerSettings* settings );
|
||||
virtual ~SimpleSerialAnalyzerResults();
|
||||
|
||||
virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base );
|
||||
virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id );
|
||||
|
||||
virtual void GenerateFrameTabularText(U64 frame_index, DisplayBase display_base );
|
||||
virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base );
|
||||
virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base );
|
||||
|
||||
protected: //functions
|
||||
|
||||
protected: //vars
|
||||
SimpleSerialAnalyzerSettings* mSettings;
|
||||
SimpleSerialAnalyzer* mAnalyzer;
|
||||
};
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_RESULTS
|
|
@ -0,0 +1,73 @@
|
|||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include <AnalyzerHelpers.h>
|
||||
|
||||
|
||||
SimpleSerialAnalyzerSettings::SimpleSerialAnalyzerSettings()
|
||||
: mInputChannel( UNDEFINED_CHANNEL ),
|
||||
mBitRate( 9600 )
|
||||
{
|
||||
mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
|
||||
mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard Simple Serial" );
|
||||
mInputChannelInterface->SetChannel( mInputChannel );
|
||||
|
||||
mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
|
||||
mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
|
||||
mBitRateInterface->SetMax( 6000000 );
|
||||
mBitRateInterface->SetMin( 1 );
|
||||
mBitRateInterface->SetInteger( mBitRate );
|
||||
|
||||
AddInterface( mInputChannelInterface.get() );
|
||||
AddInterface( mBitRateInterface.get() );
|
||||
|
||||
AddExportOption( 0, "Export as text/csv file" );
|
||||
AddExportExtension( 0, "text", "txt" );
|
||||
AddExportExtension( 0, "csv", "csv" );
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Serial", false );
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzerSettings::~SimpleSerialAnalyzerSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
||||
{
|
||||
mInputChannel = mInputChannelInterface->GetChannel();
|
||||
mBitRate = mBitRateInterface->GetInteger();
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Simple Serial", true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
||||
{
|
||||
mInputChannelInterface->SetChannel( mInputChannel );
|
||||
mBitRateInterface->SetInteger( mBitRate );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerSettings::LoadSettings( const char* settings )
|
||||
{
|
||||
SimpleArchive text_archive;
|
||||
text_archive.SetString( settings );
|
||||
|
||||
text_archive >> mInputChannel;
|
||||
text_archive >> mBitRate;
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Simple Serial", true );
|
||||
|
||||
UpdateInterfacesFromSettings();
|
||||
}
|
||||
|
||||
const char* SimpleSerialAnalyzerSettings::SaveSettings()
|
||||
{
|
||||
SimpleArchive text_archive;
|
||||
|
||||
text_archive << mInputChannel;
|
||||
text_archive << mBitRate;
|
||||
|
||||
return SetReturnString( text_archive.GetString() );
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef SIMPLESERIAL_ANALYZER_SETTINGS
|
||||
#define SIMPLESERIAL_ANALYZER_SETTINGS
|
||||
|
||||
#include <AnalyzerSettings.h>
|
||||
#include <AnalyzerTypes.h>
|
||||
|
||||
class SimpleSerialAnalyzerSettings : public AnalyzerSettings
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzerSettings();
|
||||
virtual ~SimpleSerialAnalyzerSettings();
|
||||
|
||||
virtual bool SetSettingsFromInterfaces();
|
||||
void UpdateInterfacesFromSettings();
|
||||
virtual void LoadSettings( const char* settings );
|
||||
virtual const char* SaveSettings();
|
||||
|
||||
|
||||
Channel mInputChannel;
|
||||
U32 mBitRate;
|
||||
|
||||
protected:
|
||||
std::auto_ptr< AnalyzerSettingInterfaceChannel > mInputChannelInterface;
|
||||
std::auto_ptr< AnalyzerSettingInterfaceInteger > mBitRateInterface;
|
||||
};
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_SETTINGS
|
|
@ -0,0 +1,71 @@
|
|||
#include "SimpleSerialSimulationDataGenerator.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
|
||||
#include <AnalyzerHelpers.h>
|
||||
|
||||
SimpleSerialSimulationDataGenerator::SimpleSerialSimulationDataGenerator()
|
||||
: mSerialText( "My first analyzer, woo hoo!" ),
|
||||
mStringIndex( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
SimpleSerialSimulationDataGenerator::~SimpleSerialSimulationDataGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleSerialSimulationDataGenerator::Initialize( U32 simulation_sample_rate, SimpleSerialAnalyzerSettings* settings )
|
||||
{
|
||||
mSimulationSampleRateHz = simulation_sample_rate;
|
||||
mSettings = settings;
|
||||
|
||||
mSerialSimulationData.SetChannel( mSettings->mInputChannel );
|
||||
mSerialSimulationData.SetSampleRate( simulation_sample_rate );
|
||||
mSerialSimulationData.SetInitialBitState( BIT_HIGH );
|
||||
}
|
||||
|
||||
U32 SimpleSerialSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel )
|
||||
{
|
||||
U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, sample_rate, mSimulationSampleRateHz );
|
||||
|
||||
while( mSerialSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested )
|
||||
{
|
||||
CreateSerialByte();
|
||||
}
|
||||
|
||||
*simulation_channel = &mSerialSimulationData;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SimpleSerialSimulationDataGenerator::CreateSerialByte()
|
||||
{
|
||||
U32 samples_per_bit = mSimulationSampleRateHz / mSettings->mBitRate;
|
||||
|
||||
U8 byte = mSerialText[ mStringIndex ];
|
||||
mStringIndex++;
|
||||
if( mStringIndex == mSerialText.size() )
|
||||
mStringIndex = 0;
|
||||
|
||||
//we're currenty high
|
||||
//let's move forward a little
|
||||
mSerialSimulationData.Advance( samples_per_bit * 10 );
|
||||
|
||||
mSerialSimulationData.Transition(); //low-going edge for start bit
|
||||
mSerialSimulationData.Advance( samples_per_bit ); //add start bit time
|
||||
|
||||
U8 mask = 0x1 << 7;
|
||||
for( U32 i=0; i<8; i++ )
|
||||
{
|
||||
if( ( byte & mask ) != 0 )
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_HIGH );
|
||||
else
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_LOW );
|
||||
|
||||
mSerialSimulationData.Advance( samples_per_bit );
|
||||
mask = mask >> 1;
|
||||
}
|
||||
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_HIGH ); //we need to end high
|
||||
|
||||
//lets pad the end a bit for the stop bit:
|
||||
mSerialSimulationData.Advance( samples_per_bit );
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
||||
#define SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
||||
|
||||
#include <SimulationChannelDescriptor.h>
|
||||
#include <string>
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
|
||||
class SimpleSerialSimulationDataGenerator
|
||||
{
|
||||
public:
|
||||
SimpleSerialSimulationDataGenerator();
|
||||
~SimpleSerialSimulationDataGenerator();
|
||||
|
||||
void Initialize( U32 simulation_sample_rate, SimpleSerialAnalyzerSettings* settings );
|
||||
U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel );
|
||||
|
||||
protected:
|
||||
SimpleSerialAnalyzerSettings* mSettings;
|
||||
U32 mSimulationSampleRateHz;
|
||||
|
||||
protected:
|
||||
void CreateSerialByte();
|
||||
std::string mSerialText;
|
||||
U32 mStringIndex;
|
||||
|
||||
SimulationChannelDescriptor mSerialSimulationData;
|
||||
|
||||
};
|
||||
#endif //SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
Loading…
Reference in New Issue