Merge pull request #16 from saleae/modernization-2022

Modernization Update
This commit is contained in:
Mark
2022-02-20 01:34:00 -08:00
committed by GitHub
53 changed files with 1863 additions and 779 deletions

32
.clang-format Normal file
View File

@@ -0,0 +1,32 @@
# Logic style
Language: Cpp
# manually added flags
FixNamespaceComments: 'false'
SortIncludes: 'false'
# flags copied from web editor, https://zed0.co.uk/clang-format-configurator/
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: 'true'
BreakBeforeBraces: Allman
ColumnLimit: '140'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
IndentWidth: '4'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: All
PointerAlignment: Left
SpaceBeforeParens: Never
SpaceInEmptyParentheses: 'false'
SpacesInCStyleCastParentheses: 'true'
SpacesInParentheses: 'true'
SpacesInSquareBrackets: 'true'
TabWidth: '4'
UseTab: Never

71
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Build
on:
push:
branches: [master]
tags:
- '*'
pull_request:
branches: [master]
jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: |
cmake -B ${{github.workspace}}/build -A x64
cmake --build ${{github.workspace}}/build --config Release
- name: Upload windows build
uses: actions/upload-artifact@v2
with:
name: windows
path: ${{github.workspace}}/build/Analyzers/Release/*.dll
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/build
- name: Upload MacOS build
uses: actions/upload-artifact@v2
with:
name: macos
path: ${{github.workspace}}/build/Analyzers/*.so
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/build
- name: Upload Linux build
uses: actions/upload-artifact@v2
with:
name: linux
path: ${{github.workspace}}/build/Analyzers/*.so
publish:
needs: [windows, macos, linux]
runs-on: ubuntu-latest
steps:
- name: download individual builds
uses: actions/download-artifact@v2
with:
path: ${{github.workspace}}/artifacts
- name: zip
run: |
cd ${{github.workspace}}/artifacts
zip -r ${{github.workspace}}/analyzer.zip .
- uses: actions/upload-artifact@v2
with:
name: all-platforms
path: ${{github.workspace}}/artifacts/**
- name: create release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{github.workspace}}/analyzer.zip

9
.gitignore vendored
View File

@@ -1,8 +1 @@
Debug/
Release/
Debug-Legacy-1.1.14/
*.VC.db
*.VC.opendb
*.suo
*.sln.ecd
*.vcxproj.user
/build

6
.gitmodules vendored
View File

@@ -1,6 +0,0 @@
[submodule "AnalyzerSDK"]
path = AnalyzerSDK
url = https://github.com/saleae/AnalyzerSDK.git
[submodule "LegacyAnalyzerSDK"]
path = LegacyAnalyzerSDK
url = https://github.com/saleae/AnalyzerSDK.git

Submodule AnalyzerSDK deleted from 560b7cb584

26
CMakeLists.txt Normal file
View File

@@ -0,0 +1,26 @@
cmake_minimum_required (VERSION 3.13)
project(SimpleSerialAnalyzer)
add_definitions( -DLOGIC2 )
# enable generation of compile_commands.json, helpful for IDEs to locate include files.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# custom CMake Modules are located in the cmake directory.
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(ExternalAnalyzerSDK)
set(SOURCES
src/SimpleSerialAnalyzer.cpp
src/SimpleSerialAnalyzer.h
src/SimpleSerialAnalyzerResults.cpp
src/SimpleSerialAnalyzerResults.h
src/SimpleSerialAnalyzerSettings.cpp
src/SimpleSerialAnalyzerSettings.h
src/SimpleSerialSimulationDataGenerator.cpp
src/SimpleSerialSimulationDataGenerator.h
)
add_analyzer_plugin(${PROJECT_NAME} SOURCES ${SOURCES})

View File

@@ -1,34 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
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
Debug-Legacy-1.1.14|Win32 = Debug-Legacy-1.1.14|Win32
Debug-Legacy-1.1.14|x64 = Debug-Legacy-1.1.14|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}.Debug-Legacy-1.1.14|Win32.ActiveCfg = Debug-Legacy-1.1.14|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug-Legacy-1.1.14|Win32.Build.0 = Debug-Legacy-1.1.14|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug-Legacy-1.1.14|x64.ActiveCfg = Debug-Legacy-1.1.14|x64
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug-Legacy-1.1.14|x64.Build.0 = Debug-Legacy-1.1.14|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

View File

@@ -1,255 +0,0 @@
<?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-Legacy-1.1.14|Win32">
<Configuration>Debug-Legacy-1.1.14</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-Legacy-1.1.14|x64">
<Configuration>Debug-Legacy-1.1.14</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<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-Legacy-1.1.14|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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Legacy-1.1.14|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-Legacy-1.1.14|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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Legacy-1.1.14|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-Legacy-1.1.14|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)'=='Debug-Legacy-1.1.14|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>MultiThreadedDebugDLL</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-Legacy-1.1.14|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\LegacyAnalyzerSDK\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLESERIALANALYZER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>Analyzer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\LegacyAnalyzerSDK\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>MultiThreadedDebugDLL</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)'=='Debug-Legacy-1.1.14|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\LegacyAnalyzerSDK\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)..\LegacyAnalyzerSDK\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>MultiThreadedDLL</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>MultiThreadedDLL</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>

View File

@@ -1,120 +0,0 @@
# Python 3 script to build the analyzer
import os, glob, platform
#find out if we're running on mac or linux and set the dynamic library extension
if platform.system().lower() == "darwin":
dylib_ext = ".dylib"
else:
dylib_ext = ".so"
print("Running on " + platform.system())
#make sure the release folder exists, and clean out any .o/.so file if there are any
if not os.path.exists( "release" ):
os.makedirs( "release" )
os.chdir( "release" )
o_files = glob.glob( "*.o" )
o_files.extend( glob.glob( "*" + dylib_ext ) )
for o_file in o_files:
os.remove( o_file )
os.chdir( ".." )
#make sure the debug folder exists, and clean out any .o/.so files if there are any
if not os.path.exists( "debug" ):
os.makedirs( "debug" )
os.chdir( "debug" )
o_files = glob.glob( "*.o" );
o_files.extend( glob.glob( "*" + dylib_ext ) )
for o_file in o_files:
os.remove( o_file )
os.chdir( ".." )
#find all the cpp files in /source. We'll compile all of them
os.chdir( "source" )
cpp_files = glob.glob( "*.cpp" );
os.chdir( ".." )
#specify the search paths/dependencies/options for gcc
include_paths = [ "./AnalyzerSDK/include" ]
link_paths = [ "./AnalyzerSDK/lib" ]
link_dependencies = [ "-lAnalyzer" ] #refers to libAnalyzer.dylib or libAnalyzer.so
debug_compile_flags = "-O0 -w -c -fpic -g"
release_compile_flags = "-O3 -w -c -fpic"
def run_command(cmd):
"Display cmd, then run it in a subshell, raise if there's an error"
print(cmd)
if os.system(cmd):
raise Exception("Shell execution returned nonzero status")
#loop through all the cpp files, build up the gcc command line, and attempt to compile each cpp file
for cpp_file in cpp_files:
#g++
command = "g++ "
#include paths
for path in include_paths:
command += "-I\"" + path + "\" "
release_command = command
release_command += release_compile_flags
release_command += " -o\"release/" + cpp_file.replace( ".cpp", ".o" ) + "\" " #the output file
release_command += "\"" + "source/" + cpp_file + "\"" #the cpp file to compile
debug_command = command
debug_command += debug_compile_flags
debug_command += " -o\"debug/" + cpp_file.replace( ".cpp", ".o" ) + "\" " #the output file
debug_command += "\"" + "source/" + cpp_file + "\"" #the cpp file to compile
#run the commands from the command line
run_command(release_command)
run_command(debug_command)
#lastly, link
#g++
command = "g++ "
#add the library search paths
for link_path in link_paths:
command += "-L\"" + link_path + "\" "
#add libraries to link against
for link_dependency in link_dependencies:
command += link_dependency + " "
#make a dynamic (shared) library (.so/.dylib)
if dylib_ext == ".dylib":
command += "-dynamiclib "
else:
command += "-shared "
#figgure out what the name of this analyzer is
analyzer_name = ""
for cpp_file in cpp_files:
if cpp_file.endswith( "Analyzer.cpp" ):
analyzer_name = cpp_file.replace( "Analyzer.cpp", "" )
break
#the files to create (.so/.dylib files)
if dylib_ext == ".dylib":
release_command = command + "-o release/lib" + analyzer_name + "Analyzer.dylib "
debug_command = command + "-o debug/lib" + analyzer_name + "Analyzer.dylib "
else:
release_command = command + "-o\"release/lib" + analyzer_name + "Analyzer.so\" "
debug_command = command + "-o\"debug/lib" + analyzer_name + "Analyzer.so\" "
#add all the object files to link
for cpp_file in cpp_files:
release_command += "release/" + cpp_file.replace( ".cpp", ".o" ) + " "
debug_command += "debug/" + cpp_file.replace( ".cpp", ".o" ) + " "
#run the commands from the command line
run_command(release_command)
run_command(debug_command)

View File

@@ -0,0 +1,57 @@
include(FetchContent)
# Use the C++11 standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY OR NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/)
endif()
# Fetch the Analyzer SDK if the target does not already exist.
if(NOT TARGET Saleae::AnalyzerSDK)
FetchContent_Declare(
analyzersdk
GIT_REPOSITORY https://github.com/saleae/AnalyzerSDK.git
GIT_TAG alpha
GIT_SHALLOW True
GIT_PROGRESS True
)
FetchContent_GetProperties(analyzersdk)
if(NOT analyzersdk_POPULATED)
FetchContent_Populate(analyzersdk)
include(${analyzersdk_SOURCE_DIR}/AnalyzerSDKConfig.cmake)
if(APPLE OR WIN32)
get_target_property(analyzersdk_lib_location Saleae::AnalyzerSDK IMPORTED_LOCATION)
if(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
file(COPY ${analyzersdk_lib_location} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
message(WARNING "Please define CMAKE_RUNTIME_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY if you want unit tests to locate ${analyzersdk_lib_location}")
endif()
endif()
endif()
endif()
function(add_analyzer_plugin TARGET)
set(options )
set(single_value_args )
set(multi_value_args SOURCES)
cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}" ${ARGN} )
add_library(${TARGET} MODULE ${_p_SOURCES})
target_link_libraries(${TARGET} PRIVATE Saleae::AnalyzerSDK)
set(ANALYZER_DESTINATION "Analyzers")
install(TARGETS ${TARGET} RUNTIME DESTINATION ${ANALYZER_DESTINATION}
LIBRARY DESTINATION ${ANALYZER_DESTINATION})
set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION})
endfunction()

View File

@@ -1,331 +0,0 @@
# Setting up an Analyzer SDK Project
This document details setting up your analyzer project for development on Windows, Mac, and Linux.
Documentation for the Analyzer SDK code is still in the older Saleae Analyzer SDK.pdf.
## Initial Setup (All Platforms)
Before continuing this setup guide, please follow the instructions in the readme file to download, fork or clone this repository, and then run the rename_analyzer.py script.
## Visual Studio
To build on Windows, open the visual studio project in the Visual Studio folder, and build. The Visual Studio solution has configurations for 32 bit and 64 bit builds. You will likely need to switch the configuration to 64 bit and build that in order to get the analyzer to load in the Windows software.
To test your analyzer, you will need to tell the Saleae Logic software where to load find your compiled analyzer dll.
The four build combinations produce analyzer dll files in the following locations:
```
.\Visual Studio\Win32\Debug\<Your Analyzer's Name>Analyzer.dll
.\Visual Studio\Win32\Release\<Your Analyzer's Name>Analyzer.dll
.\Visual Studio\x64\Debug\<Your Analyzer's Name>Analyzer.dll
.\Visual Studio\x64\Release\<Your Analyzer's Name>Analyzer.dll
```
Instructions to tell the Saleae Logic software where to find your new analyzer dll can be found here:
[How to set the developer directory in the Saleae software to use third party or user created analyzers.](https://support.saleae.com/faq/technical-faq/setting-up-developer-directory)
Once you have set that directory and restarted the software, your new custom analyzer should appear in the list of analyzers you can add.
## Debugging an Analyzer with Visual Studio
Newer versions of the Saleae software cannot be used to debug custom analyzers on Windows. This means that older versions of the software and SDK must be used if you wish to attach a debugger and step through your code. This complicates debugging on Windows, unfortunately, but it can be done.
*Note: it is impossible to attach a debugger to any version of the software that supports the new products. We are working on a solution to this problem, but for now that means you must rely on the simulation data generator for your analyzer to produce captures you can then debug in the older software.*
To debug your custom analyzer, you will need to download the 32-bit standalone copy of our older, 1.1.18 software.
http://downloads.saleae.com/betas/1.1.18/Logic1.1.18BetaWin32Standalone.zip
This is a sandalone download and does not need to be installed. Just extract the zip file and run the contained Logic.exe.
Please note - switching between Saleae Logic software versions has a tendency to reset the software's settings. This could cause the analyzer developer directory to get reset. If you no longer see your analyzer in the list, please verify that the analyzer developer directory is still set properly.
To build and and debug your custom analyzer using the 1.1.14 software, follow these steps:
- Using Visual Studio, open the solution file in the Visual Studio Folder.
- Select the solution configuration "Debug-Legacy-1.1.14"
- Select the platform "Win32"
- Build the solution
- Launch the 1.1.18 32-bit Logic software. If the analyzer directory is not already configured, set that to the `Visual Studio\Win32\Debug-Legacy-1.1.14` directory, and restart the software.
- The analyzer should now be visible in the list of analyzers you can add.
- In visual studio, open the Debug Menu, and select "Attach to process..."
- Locate Logic.exe in the list, select it, and click the Attach button.
- Add a break point on any line near the top of the WorkerThread() function, such as line 27, mSampleRateHz = GetSampleRate();
- In the Logic software, add your custom analyzer if you haven't already, and start a simulation.
- The breakpoint should hit
Optionally you can change the debugger command in visual studio to point to the older Logic.exe binary. Then you will be able to start debugging simply by pressing run in Visual Studio.
**Common issues on Windows**
- The 'Options' button is missing.
On Logic software version 1.1.18, the 'Options' button is hidden because of the Windows Aero theme. It is still clickable right below the (X) button. More information [here](https://support.saleae.com/faq/technical-faq/why-is-the-options-button-missing).
- The software says "Unable to 'LoadLibrary' on dll ... is not a valid Win32 application"
This is most likely because the analyzer was not built for the same platform architecture as the software running it. In almost all cases, this means the analyzer was compiled for 32 bit instead of 64 bit. Details to switch from 32 bit to 64 bit are included in the Analyzer SDK documentation on page 9. First, [add a x64 target to your project](https://msdn.microsoft.com/en-us/library/ms185328(v=vs.120).aspx). Then, edit the linker settings for the 64 bit configuration. Change the additional dependencies item from Analyzer.dll to Analyzer64.dll.
Note: Only the software versions 1.1.16 and later were built for 64 bit. Previous releases, including 1.1.15, were 32 bit only, which is why no 64 bit analyzer dll was provided.
- The Saleae software crashes on launch when the debugger is attached.
Versions after about 1.1.18 no longer allow debuggers to attach. In these cases, we recommend building with the 32 bit version of the 1.1.18 beta and the 1.1.14 SDK, and debug there. This restriction only applies to Windows.
## Linux
*Note: When using git clone, please remember to use --recursive to automatically also clone the AnalyzerSDK submodule*
After you have cloned, forked, or downloaded the repository, and ran the rename_analyzer.py script, there are two additional steps required to run the analyzer.
First, if you are using Linux 64 bit, you need to delete the 32 bit libAnalyzer.so file, and rename the libAnalyzer64.so file to just libAnalyzer.so.
```
mv AnalyzerSDK/lib/libAnalyzer64.so AnalyzerSDK/lib/libAnalyzer.so
```
Then run build_analyzer.py
```
python build_analyzer.py
```
That's it! To debug the analyzer, you need to first tell the Saleae Logic software where to find your newly compiled *.so file.
[How to set the developer directory in the Saleae software to use third party or user created analyzers.](https://support.saleae.com/faq/technical-faq/setting-up-developer-directory)
The two variants of the newly compiled analyzer can be found here:
```
debug/lib<Your Analyzer's Name>Analyzer.so
release/lib<Your Analyzer's Name>Analyzer.so
```
### Debugging with GDB on Linux
To debug your analyzer, you will need to attach gdb to the Logic application, something like this:
```
gdb /Home/YourUserName/Desktop/Logic 1.2.14 (64-bit)/Logic
```
And then test setting a breakpoint like this:
```
break MyAnalyzer::WorkerThread
```
Because your analyzer hasn't been loaded yet, GDB will notify you that it can't find this function, and ask if you want to automatically set this breakpoint if a library with a matching function is loaded in the future. Type y <enter>
Then type run to start the application. Add your custom analyzer and start a simulation. This will trigger the breakpoint.
## MacOS
### Build Script Based Project
*Note: When using git clone, please remember to use --recursive to automatically also clone the AnalyzerSDK submodule*
After you have cloned, forked, or downloaded the repository, and ran the rename_analyzer.py script, there is one additional step required to run the analyzer.
run build_analyzer.py
```
python build_analyzer.py
```
That's it! To debug the analyzer, you need to first tell the Saleae Logic software where to find your newly compiled *.dylib file.
[How to set the developer directory in the Saleae software to use third party or user created analyzers.](https://support.saleae.com/faq/technical-faq/setting-up-developer-directory)
```
debug/lib<Your Analyzer's Name>Analyzer.dylib
release/lib<Your Analyzer's Name>Analyzer.dylib
```
### Debugging with GDB on MacOS
To debug your analyzer, you will need to attach gdb to the Logic application, something like this:
```
gdb /Applications/Logic.app/Contents/MacOS/Logic
```
And then test setting a breakpoint like this:
```
break MyAnalyzer::WorkerThread
```
Because your analyzer hasn't been loaded yet, GDB will notify you that it can't find this function, and ask if you want to automatically set this breakpoint if a library with a matching function is loaded in the future. Type y <enter>
Then type run to start the application. Add your custom analyzer and start a simulation. This will trigger the breakpoint.
### XCode Based Project
**Note: This section hasn't yet been updated to describe the proper setup using a fork or clone of the new Github repository for the Sample Analyzer. The instructions will still work, but need improvement to work well with the git repository.**
This section was written using the 1.1.32 Analyzer SDK, Xcode version 7.2.1, and OSX 10.10.5. however it is likely to work with other versions as well.
- Start Xcode
- Click "Create a new Xcode project"
![1](./images/1_-_new_project.png)
- select "Other" from the left column, and "Empty" from the templates list.
- Click next.
![2](./images/2_-_empty_project.png)
- Enter a name for your Xcode Project.
![2.5](./images/2_5_analyzer_name.png)
- The location should be set to the analyzer SDK folder recently downloaded, "SaleaeAnalyzerSdk-1.1.32". Do not create a new folder, this will be done for you by Xcode.
- Click "Create"
![2.75](./images/2_75_-_project_location.png)
- Back in Finder, copy the file "rename_analyzer.py" and "source" from the downloaded SDK directory into the freshly created folder, which will have the same name as your new analyzer. Shown here the name is "XcodeAnalyzer"
![3](./images/3_-_copy_files.png)
- Open a terminal, and browse to the new project folder in the downloaded SDK folder.
- Run the python script with:
python rename_analyzer.py
- first, it will prompt you for the class prefix for all of the source files. All classes and files will be re-named with this prefix. If you type "I2C" the classes and files will be named with "I2CAnalyzer". Please avoid using analyzer in this name, as it will get repeated like this: "I2CAnalyzerAnalyzer"
- Second, it will ask you for the name to display to the user in the "Add Analyzers" menu. This should be the user facing name, and can include spaces.
![4](./images/4_-_rename_analyzer_script.png)
- Next, we need to add a target to the Xcode project. Be sure that the project is selected in the Project Navigator on the left, and then click the menu highlighted below to add a target.
![5](./images/5_-_add_target_button.png)
- This is the target menu.
![6](./images/6_-_add_target_menu.png)
- Select "Framework & Library" under "OS X" in the left column, and select "Library" in the main area.
- Click Next.
![7](./images/7_-_library_target.png)
- Enter a product name, we recommend the the same name as the project, since there will only be one product.
- Under framework, select "None (Plain C/C++ Library)
- For Type, select "Dynamic"
![8](./images/8_-_library_settings.png)
- Next, we need to add the source files. Click File -> Add Files to "<project name>"...
- Note: if this is disabled, it is because you do not have the project selected in the Project Navigator.
![8.5](./images/8_5_-_add_files_menu.png)
- Browse to the source folder in the Xcode project folder, and select it. Don't select the contents, be sure to select the folder itself.
- select "Create groups" in the "added folders" section.
- Click Add.
![9](./images/9_-_add_files.png)
- Verify that the files were automatically added to the build phases "Compile Sources" and "Headers".
- Select the project from the Project Navigator if not already selected.
- Click "Build Phases".
- Expand "Compile Sources" and "Headers"
- Under "Headers", also expand "Project".
- Verify that each has 4 files.
![9.5](./images/9_5_-_verify_sources_added.png)
- Click "Build Settings"
- If "Levels" is selected, switch it to "Combined"
![10](./images/10_-_build_settings_page.png)
- Expand the section "Search Paths"
- Locate "Header Search Paths" and edit the value.
- Click the "+" button and enter "../include" in the new entry.
![11](./images/11_-_header_includes_search_path.png)
- Locate "Library Search Paths" in the same section, and edit its value.
- Click the "+" button and enter "../lib" in the new entry.
![11.5](./images/11_5_-_add_library_path.png)
- Return to "Build Phases" and expand the section "Link Binary with Libraries"
- Click the "+" button
![12](./images/12_-_add_library_part_1.png)
- Click "Add Other..."
![13](./images/13_-_add_library_part_2.png)
- Browse to the original SDK folder which contains our Xcode folder.
- Open the "lib" folder
- Select "libAnalyzer.dylib"
- Click Open.
![14](./images/14_-_add_library_part_3.png)
- At this point, you should build the project, so that the resulting library will be created.
- It's worth mentioning that new Xcode versions do not save build outputs in the project directory. Instead, the default output directory looks like this:
~/Library/Developer/Xcode/DerivedData
- You may want to change it. **The following steps are optional**
**Optional: change build output folder**
- Optional step 1: From the file menu, select "Project Settings..."
![optional 1](./images/optional_-_project_settings_-_edit_products_folder_menu.png)
- Optional step 2: in the "Derived Data" dropdown, select "Project-relative Location"
- Click "Done"
![optional 2](./images/optional_-_Project_Settings.png)
- That's it for the optional steps.
### Running and Debugging your Analyzer
- Next we will setup debugging for the project. Be sure to have the latest Saleae Logic Software installed.
- On the Product menu at the top of the screen, select "Scheme" -> "Edit Scheme..."
![15](./images/15_-_edit_scheme.png)
- Make sure "Run" is selected on the left.
- Under "Executable" select "Other..."
![16](./images/16_-_debug_launch_app_menu.png)
- Browse to the "Applications" folder (or wherever Logic is installed) and select "Logic.app"
- Click Choose.
![17](./images/17_-_select_debug_program.png)
- Set a breakpoint in the software so that we can test debugging.
- Open "XcodeAnalyzer.cpp" on the left. The name will reflect what you selected as the class prefix in a previous step. In this example, the class prefix was "Xcode".
- In the source file, add a break point to the first line of code in the WorkerThread method. This code runs when the analyzer starts processing data.
![18](./images/18_-_breakpoint_set.png)
- Before proceeding, see this article with instructions to configure the software to load your new analyzer: https://support.saleae.com/faq/technical-faq/setting-up-developer-directory
- Be sure to select the folder where the debug version of the custom analyzer is is saved.
- Once the Saleae logic software has been configured, and has been closed, click run from Xcode.
- The Saleae software should launch a few seconds later. Click the "+" button on the analyzers panel, and then select your analyzer. In this case, the user facing name of the analyzer was set by the Python script to "Xcode Analyzer". Yours may be different.
- If your analyzer is missing, it could indicate that the dylib was not created, or that the developer path was not set properly. Please review the previous steps for any possible errors.
- The settings dialog for your custom analyzer will appear. Click "Save".
![19](./images/19_-_logic_software_add_analyzer_menu.png)
- Here is your fresh new analyzer, now added to the software. Note that our breakpoint hasn't fired yet. If you had captured data previously, it might fire now, since analyzers will automatically start processing if they are added to an existing analyzer.
![20](./images/20_-_analyzer_in_Logic.png)
- Press start to start a simulation.
- Since your analyzer has already been added, the simulator will call your simulation data generator code. The analyzer also starts processing the moment data has been captured, so your breakpoint should fire immediately.
![21](./images/21_-_logic_software_start_button.png)
- Here you can see that the debugger was attached and your break point has been hit. You can examine variables, set new break points, or press continue from the debug menu at the bottom.
![22](./images/22_-_breakpoint_hit.png)
- Congratulations! You now have an Xcode project for which you can use to develop a custom analyzer for the Saleae software.
If you have any questions, please contact support.

1401
docs/Analyzer_API.md Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

280
readme.md
View File

@@ -1,16 +1,29 @@
# Saleae Analyzer SDK Sample Analyzer
The Saleae Analyzer SDK is used to create custom plugins for the Saleae Logic software. These plugins are used to decode protocol data from captured waveforms.
The libraries required to build a custom analyzer are stored in another git repository, located here:
[https://github.com/saleae/AnalyzerSDK](https://github.com/saleae/AnalyzerSDK)
- [Saleae Analyzer SDK Sample Analyzer](#saleae-analyzer-sdk-sample-analyzer)
- [Renaming your Analyzer](#renaming-your-analyzer)
- [Cloud Building & Publishing](#cloud-building---publishing)
- [Prerequisites](#prerequisites)
- [Windows](#windows)
- [MacOS](#macos)
- [Linux](#linux)
- [Building your Analyzer](#building-your-analyzer)
- [Windows](#windows-1)
- [MacOS](#macos-1)
- [Linux](#linux-1)
- [Debugging](#debugging)
- [Windows](#windows-2)
- [MacOS](#macos-2)
- [Linux](#linux-2)
- [Updating an Existing Analyzer to use CMake & GitHub Actions](#updating-an-existing-analyzer-to-use-cmake---github-actions)
This repository should be used to create new analyzers for the Saleae software.
The Saleae Analyzer SDK is used to create Low Level Analyzers (LLA) for the Saleae Logic software via a plugin architecture. These plugins are used to decode protocol data from captured waveforms. In many cases you can use a [High Level Analyzer Extension](https://support.saleae.com/extensions/high-level-analyzer-quickstart) to process data from an existing protocol decoder instead of building a LLA.
First, fork, clone or download this repository. Forking is recommended if you plan to use version control or share your custom analyzer publicly.
To build your own protocol decoder plugin, first fork, clone, or download this repository.
Note - This repository contains a submodule. Be sure to include submodules when cloning, for example `git clone --recursive https://github.com/saleae/SampleAnalyzer.git`. If you download the repository from Github, the submodules are not included. In that case you will also need to download the AnalyzerSDK repository linked above and place the AnalyzerSDK folder inside of the SampleAnalyzer folder.
Then, make sure you have the required software installed for development. See the [Prerequisites](#Prerequisites) section below for details.
*Note: an additional submodule is used for debugging on Windows, see section on Windows debugging for more information.*
## Renaming your Analyzer
Once downloaded, first run the script rename_analyzer.py. This script is used to rename the sample analyzer automatically. Specifically, it changes the class names in the source code, it changes the text name that will be displayed once the custom analyzer has been loaded into the Saleae Logic software, and it updates the visual studio project.
@@ -27,12 +40,255 @@ After that, the script will complete the renaming process and exit.
SPI
Mark's SPI Analyzer
To build on Windows, open the visual studio project in the Visual Studio folder, and build. The Visual Studio solution has configurations for 32 bit and 64 bit builds. You will likely need to switch the configuration to 64 bit and build that in order to get the analyzer to load in the Windows software.
Once renamed, you're ready to build your analyzer! See the [Building your Analyzer](#Building-your-Analyzer) section below.
To build on Linux or OSX, run the build_analyzer.py script. The compiled libraries can be found in the newly created debug and release folders.
API documentation can be found in [docs/Analyzer_API.md](docs/Analyzer_API.md).
python build_analyzer.py
## Cloud Building & Publishing
To debug on Windows, please first review the section titled `Debugging an Analyzer with Visual Studio` in the included `doc/Analyzer SDK Setup.md` document.
This example repository includes support for GitHub actions, which is a continuous integration service from GitHub. The file located at `.github\workflows\build.yml` contains the configuration.
Unfortunately, debugging is limited on Windows to using an older copy of the Saleae Logic software that does not support the latest hardware devices. Details are included in the above document.
When building in CI, the release version of the analyzer is built for Windows, Linux, and MacOS. The built analyzer files are available for every CI build. Additionally, GitHub releases are automatically created for any tagged commits, making it easy to share pre-built binaries with others once your analyzer is complete.
Learn how to tag a commit here: https://stackoverflow.com/questions/18216991/create-a-tag-in-a-github-repository
### Using downloaded analyzer binaries on MacOS
This section only applies to downloaded pre-built protocol analyzer binaries on MacOS. If you build the protocol analyzer locally, or acquire it in a different way, this section does not apply.
Any time you download a binary from the internet on a Mac, wether it be an application or a shared library, MacOS will flag that binary for "quarantine". MacOS then requires any quarantined binary to be signed and notarized through the MacOS developer program before it will allow that binary to be executed.
Because of this, when you download a pre-compiled protocol analyzer plugin from the internet and try to load it in the Saleae software, you will most likely see an error message like this:
> "libSimpleSerialAnalyzer.so" cannot be opened because th developer cannot be verified.
Signing and notarizing of open source software can be rare, because it requires an active paid subscription to the MacOS developer program, and the signing and notarization process frequently changes and becomes more restrictive, requiring frequent updates to the build process.
The quickest solution to this is to simply remove the quarantine flag added by MacOS using a simple command line tool.
Note - the purpose of code signing and notarization is to help end users be sure that the binary they downloaded did indeed come from the original publisher and hasn't been modified. Saleae does not create, control, or review 3rd party analyzer plugins available on the internet, and thus you must trust the original author and the website where you are downloading the plugin. (This applies to all software you've ever downloaded, essentially.)
To remove the quarantine flag on MacOS, you can simply open the terminal and navigate to the directory containing the downloaded shared library.
This will show what flags are present on the binary:
```sh
xattr libSimpleSerialAnalyzer.so
# example output:
# com.apple.macl
# com.apple.quarantine
```
This command will remove the quarantine flag:
```sh
xattr -r -d com.apple.quarantine libSimpleSerialAnalyzer.so
```
To verify the flag was removed, run the first command again and verify the quarantine flag is no longer present.
## Prerequisites
### Windows
Dependencies:
- Visual Studio 2017 (or newer) with C++
- CMake 3.13+
**Visual Studio 2017**
_Note - newer versions of Visual Studio should be fine._
Setup options:
- Programming Languages > Visual C++ > select all sub-components.
Note - if CMake has any problems with the MSVC compiler, it's likely a component is missing.
**CMake**
Download and install the latest CMake release here.
https://cmake.org/download/
### MacOS
Dependencies:
- XCode with command line tools
- CMake 3.13+
Installing command line tools after XCode is installed:
```
xcode-select --install
```
Then open XCode, open Preferences from the main menu, go to locations, and select the only option under 'Command line tools'.
Installing CMake on MacOS:
1. Download the binary distribution for MacOS, `cmake-*-Darwin-x86_64.dmg`
2. Install the usual way by dragging into applications.
3. Open a terminal and run the following:
```
/Applications/CMake.app/Contents/bin/cmake-gui --install
```
_Note: Errors may occur if older versions of CMake are installed._
### Linux
Dependencies:
- CMake 3.13+
- gcc 5+
Misc dependencies:
```
sudo apt-get install build-essential
```
## Building your Analyzer
### Windows
```bat
mkdir build
cd build
cmake .. -A x64
cmake --build .
:: built analyzer will be located at SampleAnalyzer\build\Analyzers\Debug\SimpleSerialAnalyzer.dll
```
### MacOS
```bash
mkdir build
cd build
cmake ..
cmake --build .
# built analyzer will be located at SampleAnalyzer/build/Analyzers/libSimpleSerialAnalyzer.so
```
### Linux
```bash
mkdir build
cd build
cmake ..
cmake --build .
# built analyzer will be located at SampleAnalyzer/build/Analyzers/libSimpleSerialAnalyzer.so
```
## Debugging
Although the exact debugging process varies slightly from platform to platform, part of the process is the same for all platforms.
First, build your analyzer. Then, in the Logic 2 software, load your custom analyzer, and then restart the software. Instructions can be found here: https://support.saleae.com/faq/technical-faq/setting-up-developer-directory
Once restarted, the software should show your custom analyzer in the list of available analyzers.
Next, in order to attach your debugger, you will need to find the process ID of the Logic 2 software. To make this easy, we display the process ID of the correct process in the About dialog in the software, which you can open from the main menu. It's the last item in the "Build Info" box, labeled "PID". Note that this is not the correct PID when using an ARM based M1 Mac. (Please contact support for details on debugging on M1 Macs.)
You will need that PID number for the platform specific steps below.
Note, we strongly recommend only debugging your analyzer on existing captures, and not while making new recordings. The act of pausing the application with the debugger while recording data will cause the recording to fail once the application is resumed. To make development smooth, we recommend saving the capture you wish to debug with before starting the debugging process, so you can easily re-load it later.
### Windows
when `cmake .. -A x64` was run, a Visual Studio solution file was created automatically in the build directory. To debug your analyzer, first open that solution in visual studio.
Then, open the Debug menu, and select "attach to process...".
Enter the PID number into the Filter box to find the correct instance of Logic.exe.
Click attach.
Next, place a breakpoint somewhere in your analyzer source code. For example, the start of the WorkerThread function.
Make sure you already have recorded data in the application, and then add an instance of your analyzer. The debugger should pause at the breakpoint.
### MacOS
We don't have a clear process for how to debug custom protocol analyzers on MacOS. If you attempt to attach a debugger to the Logic 2 software, you will likely see an error like this:
> error: attach failed: attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)
Checking the output in Console.app, you will likely find logs like this:
> macOSTaskPolicy: (com.apple.debugserver) may not get the task control port of (Logic2 Helper (R) (pid: 95234): (Logic2 Helper (R) is hardened, (Logic2 Helper (R) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger(com.apple.debugserver) is not a declared read-only debugger
This is likely due to our signing and notarization process on MacOS not adding the `get-task-allow` entitlement. If you're in need of MacOS debugging, please contact Saleae support to request it.
### Linux
(Note, this section needs to be tested and updated if needed)
On Linux, you can debug your custom analyzer using GDB. This can be done from the console, however we recommend using a GUI tool like Visual Studio Code, with the C++ extension installed.
To debug from the command line, once you have loaded your analyzer into the logic software and have checked the process ID, you can attach gdb like so:
```bash
gdb
attach <pid>
```
If you see a permissions error like this, you will need to temporarily change the `ptrace_scope` setting on your system.
> Could not attach to process. [...] ptrace: Operation not permitted.
You can change the `ptrace_scope` like so, which will then allow you to attach to another process without sudo. (Be sure to `quit` gdb first)
```bash
sudo sysctl -w kernel.yama.ptrace_scope=0
```
You can learn more about `ptrace_scope` here: https://www.kernel.org/doc/Documentation/security/Yama.txt
Next, test setting a breakpoint like this. Be sure to use the correct class name.
```
break MyAnalyzer::WorkerThread
```
finally, attaching to the process will have paused the Logic application execution. Resume it with the continue command:
```bash
continue
```
If your analyzer hasn't been loaded yet, GDB will notify you that it can't find this function, and ask if you want to automatically set this breakpoint if a library with a matching function is loaded in the future. Type `y <enter>`
Then return to the application and add your analyzer. This should trigger the breakpoint.
To verify that symbols for your custom analyzer are loading, check the backtrace with the `bt` command. Example output:
```
#0 0x00007f2677dc42a8 in I4CAnalyzer::WorkerThread() ()
from /home/build/Downloads/SampleAnalyzer-modernization-2022/build/Analyzers/libI4CAnalyzer.so
#1 0x00007f267046f24a in Analyzer::InitialWorkerThread() () from /tmp/.mount_Logic-0Fyxvr/resources/linux/libAnalyzer.so
#2 0x00007f267263bed9 in ?? () from /tmp/.mount_Logic-0Fyxvr/resources/linux/libgraph_server_shared.so
#3 0x00007f267264688e in ?? () from /tmp/.mount_Logic-0Fyxvr/resources/linux/libgraph_server_shared.so
#4 0x00007f26828e1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#5 0x00007f2681136293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
```
## Updating an Existing Analyzer to use CMake & GitHub Actions
If you maintain an existing C++ analyzer, or wish to fork and update someone else's analyzer, please follow these steps.
1. Delete the contents of the existing repository, except for the source directory, and the readme.
2. Copy the contents of this sample repository into the existing analyzer, except for the src and docs directories, or the rename_analyzer.py script.
3. Rename the existing source directory to src.
4. In the new CMakeLists.txt file, make the following changes:
- In the line `project(SimpleSerialAnalyzer)`, replace `SimpleSerialAnalyzer` with the name of the existing analyzer, for example `project(I2CAnalyzer)`
- In the section `set(SOURCES`, replace all of the existing source code file names with the file names of the existing source code.
5. Update the readme! Feel free to just reference the SampleAnalyzer repository, or copy over the build instructions.
6. Try the build instructions to make sure the analyzer still builds, or commit this to GitHub to have GitHub actions build it for you!
7. Once you're ready to create a release, add a tag to your last commit to trigger GitHub to publish a release.

View File

@@ -11,9 +11,9 @@ print("")
print("")
print("What would you like to call your new analyzer?")
print("")
print(">>The files under '/source' will be modified to use it.")
print(">>The files under '/src' will be modified to use it.")
print(">>Examples include Serial, MySerial, JoesSerial, Gamecube, Wiimote, 2Wire, etc.")
print(">>Do not inclide the trailing word 'Analyzer' this will be added automaticly.")
print(">>Do not inclide the trailing word 'Analyzer' this will be added automatically.")
print("")
print("(press CTRL-C to cancel)")
print("")
@@ -22,7 +22,7 @@ new_analyzer_name = input( "Your new analyzer name: " )
print("")
print("")
print("What is the analyzer's title? (as shown in the add new anlayzer drop down)")
print("What is the analyzer's title? (as shown in the add new analyzer drop down)")
print("")
print(">>Examples include Async Serial, I2C, Joe's Serial, Gamecube, Wiimote, 2Wire, etc.")
print("")
@@ -33,24 +33,20 @@ new_analyzer_title = input( "Your new analyzer's title: " )
original_name = "SimpleSerial"
#update the CMakeLists.txt project name
vs_project_path = "Visual Studio"
os.chdir( vs_project_path )
project_files = glob.glob("*.sln") + glob.glob("*.vcxproj") #returns only the file names, no paths.
cmake_file = glob.glob("CMakeLists.txt")
for file in project_files:
for file in cmake_file:
contents = open( file, 'r' ).read()
contents = contents.replace( original_name + "Analyzer", new_analyzer_name + "Analyzer" )
contents = contents.replace( original_name.upper() + "ANALYZER", new_analyzer_name.upper() + "ANALYZER" )
contents = contents.replace( original_name + "SimulationDataGenerator", new_analyzer_name + "SimulationDataGenerator" )
open( file, 'w' ).write( contents )
os.rename( glob.glob("*.sln")[0], new_analyzer_name + "Analyzer.sln" )
os.rename( glob.glob("*.vcxproj")[0], new_analyzer_name + "Analyzer.vcxproj" )
source_path = "source"
os.chdir( ".." )
source_path = "src"
os.chdir( source_path )
files = dict()