├── .gitignore ├── AnalyzerSDK ├── include │ ├── Analyzer.h │ ├── AnalyzerChannelData.h │ ├── AnalyzerHelpers.h │ ├── AnalyzerResults.h │ ├── AnalyzerSettingInterface.h │ ├── AnalyzerSettings.h │ ├── AnalyzerTypes.h │ ├── LogicPublicTypes.h │ └── SimulationChannelDescriptor.h └── lib │ ├── Analyzer.dll │ ├── Analyzer.lib │ ├── Analyzer64.dll │ ├── Analyzer64.lib │ ├── libAnalyzer.dylib │ ├── libAnalyzer.so │ └── readme.txt ├── LICENSE ├── LegacyAnalyzerSDK ├── include │ ├── Analyzer.h │ ├── AnalyzerChannelData.h │ ├── AnalyzerHelpers.h │ ├── AnalyzerResults.h │ ├── AnalyzerSettingInterface.h │ ├── AnalyzerSettings.h │ ├── AnalyzerTypes.h │ ├── LogicPublicTypes.h │ └── SimulationChannelDescriptor.h └── lib │ ├── Analyzer.dll │ ├── Analyzer.lib │ ├── libAnalyzer.dylib │ ├── libAnalyzer.so │ ├── libAnalyzer64.so │ └── readme.txt ├── README.md ├── build_analyzer.py ├── docs ├── Analyzer SDK Setup.md ├── Saleae Analyzer SDK (older).pdf └── images │ ├── 10_-_build_settings_page.png │ ├── 11_-_header_includes_search_path.png │ ├── 11_5_-_add_library_path.png │ ├── 12_-_add_library_part_1.png │ ├── 13_-_add_library_part_2.png │ ├── 14_-_add_library_part_3.png │ ├── 15_-_edit_scheme.png │ ├── 16_-_debug_launch_app_menu.png │ ├── 17_-_select_debug_program.png │ ├── 18_-_breakpoint_set.png │ ├── 19_-_logic_software_add_analyzer_menu.png │ ├── 1_-_new_project.png │ ├── 20_-_analyzer_in_Logic.png │ ├── 21_-_logic_software_start_button.png │ ├── 22_-_breakpoint_hit.png │ ├── 2_-_empty_project.png │ ├── 2_5_analyzer_name.png │ ├── 2_75_-_project_location.png │ ├── 3_-_copy_files.png │ ├── 4_-_rename_analyzer_script.png │ ├── 5_-_add_target_button.png │ ├── 6_-_add_target_menu.png │ ├── 7_-_library_target.png │ ├── 8_-_library_settings.png │ ├── 8_5_-_add_files_menu.png │ ├── 9_-_add_files.png │ ├── 9_5_-_verify_sources_added.png │ ├── optional_-_Project_Settings.png │ └── optional_-_project_settings_-_edit_products_folder_menu.png ├── rename_analyzer.py ├── requirements.txt ├── source ├── FlexRayAnalyzer.cpp ├── FlexRayAnalyzer.h ├── FlexRayAnalyzerResults.cpp ├── FlexRayAnalyzerResults.h ├── FlexRayAnalyzerSettings.cpp ├── FlexRayAnalyzerSettings.h ├── FlexRayFrame.cpp ├── FlexRayFrame.h ├── FlexRayParameters.h ├── FlexRaySimulationDataGenerator.cpp ├── FlexRaySimulationDataGenerator.h ├── Helpers.cpp └── Helpers.h └── test_analyser.py /.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | __pycache__/ 3 | 4 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/Analyzer.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER 2 | #define ANALYZER 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "AnalyzerSettings.h" 9 | 10 | class AnalyzerChannelData; 11 | class DeviceCollection; 12 | class ConditionManager; 13 | class ProgressManager; 14 | struct AnalyzerData; 15 | class AnalyzerResults; 16 | class ValuePutterInner; 17 | 18 | class LOGICAPI Analyzer 19 | { 20 | public: 21 | Analyzer(); 22 | virtual ~Analyzer() = 0; 23 | virtual void WorkerThread() = 0; 24 | 25 | //sample_rate: if there are multiple devices attached, and one is faster than the other, 26 | //we can sample at the speed of the faster one; and pretend the slower one is the same speed. 27 | virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels ) = 0; 28 | virtual U32 GetMinimumSampleRateHz() = 0; //provide the sample rate required to generate good simulation data 29 | virtual const char* GetAnalyzerName() const = 0; 30 | virtual bool NeedsRerun() = 0; 31 | 32 | //use, but don't override: 33 | void SetAnalyzerSettings( AnalyzerSettings* settings ); 34 | void KillThread(); 35 | AnalyzerChannelData* GetAnalyzerChannelData( Channel& channel ); //don't delete this pointer 36 | void ReportProgress( U64 sample_number ); 37 | void SetAnalyzerResults( AnalyzerResults* results ); 38 | U32 GetSimulationSampleRate(); 39 | U32 GetSampleRate(); 40 | U64 GetTriggerSample(); 41 | //added 5-17-2012 for analog 42 | //void AddValue( float value, U64 sample_number, U32 analog_channel ); 43 | 44 | //don't override, don't use: 45 | void Init( DeviceCollection* device_collection, ConditionManager* condition_manager, ProgressManager* progress_manager/*, ValuePutterInner* value_putter_inner */); 46 | void StartProcessing(); 47 | void StopWorkerThread(); 48 | AnalyzerSettings* GetAnalyzerSettings(); 49 | bool DoesAnalyzerUseDevice( U64 device_id ); 50 | bool IsValid( Channel* channel_array, U32 count ); 51 | void InitialWorkerThread(); 52 | bool GetAnalyzerResults( AnalyzerResults** analyzer_results ); 53 | 54 | //functions added after initial release -- added at the bottom for binary compatibilty 55 | void CheckIfThreadShouldExit(); 56 | double GetAnalyzerProgress(); 57 | void SetThreadMustExit(); 58 | 59 | void StartProcessing( U64 starting_sample ); 60 | 61 | 62 | protected: 63 | struct AnalyzerData* mData; 64 | }; 65 | 66 | class LOGICAPI Analyzer2 : public Analyzer 67 | { 68 | public: 69 | Analyzer2(); 70 | virtual void SetupResults(); 71 | }; 72 | 73 | #endif //ANALYZER 74 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerChannelData.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZERCHANNELDATA 2 | #define ANALYZERCHANNELDATA 3 | 4 | #include 5 | 6 | struct AnalyzerChannelDataData; 7 | class ChannelData; 8 | class LOGICAPI AnalyzerChannelData 9 | { 10 | public: 11 | AnalyzerChannelData( ChannelData* channel_data ); 12 | ~AnalyzerChannelData(); 13 | 14 | //State 15 | U64 GetSampleNumber(); 16 | BitState GetBitState(); 17 | 18 | //Basic: 19 | U32 Advance( U32 num_samples ); //move forward the specified number of samples. Returns the number of times the bit changed state during the move. 20 | U32 AdvanceToAbsPosition( U64 sample_number ); //move forward to the specified sample number. Returns the number of times the bit changed state during the move. 21 | void AdvanceToNextEdge(); //move forward until the bit state changes from what it is now. 22 | 23 | //Fancier 24 | U64 GetSampleOfNextEdge(); //without moving, get the sample of the next transition. 25 | bool WouldAdvancingCauseTransition( U32 num_samples ); //if we advanced, would we encounter any transitions? 26 | bool WouldAdvancingToAbsPositionCauseTransition( U64 sample_number ); //if we advanced, would we encounter any transitions? 27 | 28 | //minimum pulse tracking. The serial analyzer uses this for auto-baud 29 | void TrackMinimumPulseWidth(); //normally this is not enabled. 30 | U64 GetMinimumPulseWidthSoFar(); 31 | 32 | //Fancier, part II 33 | bool DoMoreTransitionsExistInCurrentData(); //use this when you have a situation where you have multiple lines, and you need to handle the case where one or the other of them may never change again, and you don't know which. 34 | 35 | 36 | protected: 37 | AnalyzerChannelDataData* mData; 38 | }; 39 | 40 | 41 | #endif //ANALYZERCHANNELDATA 42 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_HELPERS_H 2 | #define ANALYZER_HELPERS_H 3 | 4 | #include "Analyzer.h" 5 | #include 6 | #include 7 | 8 | class LOGICAPI AnalyzerHelpers 9 | { 10 | public: 11 | static bool IsEven( U64 value ); 12 | static bool IsOdd( U64 value ); 13 | static U32 GetOnesCount( U64 value ); 14 | static U32 Diff32( U32 a, U32 b ); 15 | 16 | //static void GetNumberString( U64 number, DisplayBase display_base, U32 num_data_bits, char* result_string, U32 result_string_max_length, bool csv_safe = false ); 17 | static void GetNumberString( U64 number, DisplayBase display_base, U32 num_data_bits, char* result_string, U32 result_string_max_length ); 18 | static void GetTimeString( U64 sample, U64 trigger_sample, U32 sample_rate_hz, char* result_string, U32 result_string_max_length ); 19 | 20 | static void Assert( const char* message ); 21 | static U64 AdjustSimulationTargetSample( U64 target_sample, U32 sample_rate, U32 simulation_sample_rate ); 22 | 23 | static bool DoChannelsOverlap( const Channel* channel_array, U32 num_channels ); 24 | static void SaveFile( const char* file_name, const U8* data, U32 data_length, bool is_binary = false ); 25 | 26 | static S64 ConvertToSignedNumber( U64 number, U32 num_bits ); 27 | 28 | //These save functions should not be used with SaveFile, above. They are a better way to export data (don't waste memory), and should be used from now on. 29 | static void* StartFile( const char* file_name, bool is_binary = false ); 30 | static void AppendToFile( const U8* data, U32 data_length, void* file ); 31 | static void EndFile( void* file ); 32 | }; 33 | 34 | 35 | 36 | 37 | struct ClockGeneratorData; 38 | class LOGICAPI ClockGenerator 39 | { 40 | public: 41 | ClockGenerator(); 42 | ~ClockGenerator(); 43 | void Init( double target_frequency, U32 sample_rate_hz ); 44 | U32 AdvanceByHalfPeriod( double multiple = 1.0 ); 45 | U32 AdvanceByTimeS( double time_s ); 46 | 47 | protected: 48 | struct ClockGeneratorData* mData; 49 | }; 50 | 51 | 52 | 53 | struct BitExtractorData; 54 | class LOGICAPI BitExtractor 55 | { 56 | public: 57 | BitExtractor( U64 data, AnalyzerEnums::ShiftOrder shift_order, U32 num_bits ); 58 | ~BitExtractor(); 59 | 60 | BitState GetNextBit(); 61 | 62 | protected: 63 | struct BitExtractorData* mData; 64 | }; 65 | 66 | 67 | struct DataBuilderData; 68 | class LOGICAPI DataBuilder 69 | { 70 | public: 71 | DataBuilder(); 72 | ~DataBuilder(); 73 | 74 | void Reset( U64* data, AnalyzerEnums::ShiftOrder shift_order, U32 num_bits ); 75 | void AddBit( BitState bit ); 76 | 77 | protected: 78 | struct DataBuilderData* mData; 79 | }; 80 | 81 | 82 | 83 | 84 | struct SimpleArchiveData; 85 | class LOGICAPI SimpleArchive 86 | { 87 | public: 88 | SimpleArchive(); 89 | ~SimpleArchive(); 90 | 91 | void SetString( const char* archive_string ); 92 | const char* GetString(); 93 | 94 | bool operator<<( U64 data ); 95 | bool operator<<( U32 data ); 96 | bool operator<<( S64 data ); 97 | bool operator<<( S32 data ); 98 | bool operator<<( double data ); 99 | bool operator<<( bool data ); 100 | bool operator<<( const char* data ); 101 | bool operator<<( Channel& data ); 102 | 103 | bool operator>>( U64& data ); 104 | bool operator>>( U32& data ); 105 | bool operator>>( S64& data ); 106 | bool operator>>( S32& data ); 107 | bool operator>>( double& data ); 108 | bool operator>>( bool& data ); 109 | bool operator>>( char const ** data ); 110 | bool operator>>( Channel& data ); 111 | 112 | protected: 113 | struct SimpleArchiveData* mData; 114 | }; 115 | 116 | #endif //ANALYZER_HELPERS_H 117 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerResults.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_RESULTS 2 | #define ANALYZER_RESULTS 3 | 4 | #include 5 | #include 6 | 7 | #define DISPLAY_AS_ERROR_FLAG ( 1 << 7 ) 8 | #define DISPLAY_AS_WARNING_FLAG ( 1 << 6 ) 9 | 10 | #define SUPPORTS_PROTOCOL_SEARCH 11 | 12 | class LOGICAPI Frame 13 | { 14 | public: 15 | Frame(); 16 | Frame( const Frame& frame ); 17 | ~Frame(); 18 | 19 | S64 mStartingSampleInclusive; 20 | S64 mEndingSampleInclusive; 21 | U64 mData1; 22 | U64 mData2; 23 | U8 mType; 24 | U8 mFlags; 25 | 26 | bool HasFlag( U8 flag ); 27 | }; 28 | 29 | #define INVALID_RESULT_INDEX 0xFFFFFFFFFFFFFFFFull 30 | 31 | 32 | struct AnalyzerResultsData; 33 | 34 | 35 | 36 | class LOGICAPI AnalyzerResults 37 | { 38 | public: 39 | enum MarkerType { Dot, ErrorDot, Square, ErrorSquare, UpArrow, DownArrow, X, ErrorX, Start, Stop, One, Zero }; 40 | AnalyzerResults(); //you must call the base class contructor in your constructor 41 | virtual ~AnalyzerResults(); 42 | 43 | //override: 44 | virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base ) = 0; 45 | virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id ) = 0; 46 | virtual void GenerateFrameTabularText( U64 frame_index, DisplayBase display_base ) = 0; 47 | virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base ) = 0; 48 | virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base ) = 0; 49 | 50 | public: //adding/setting data 51 | void AddMarker( U64 sample_number, MarkerType marker_type, Channel& channel ); 52 | 53 | U64 AddFrame(const Frame &frame ); 54 | U64 CommitPacketAndStartNewPacket(); 55 | void CancelPacketAndStartNewPacket(); 56 | void AddPacketToTransaction( U64 transaction_id, U64 packet_id ); 57 | void AddChannelBubblesWillAppearOn( const Channel& channel ); 58 | 59 | void CommitResults(); 60 | 61 | public: //data access 62 | U64 GetNumFrames(); 63 | U64 GetNumPackets(); 64 | Frame GetFrame( U64 frame_id ); 65 | 66 | U64 GetPacketContainingFrame( U64 frame_id ); 67 | U64 GetPacketContainingFrameSequential( U64 frame_id ); 68 | void GetFramesContainedInPacket( U64 packet_id, U64* first_frame_id, U64* last_frame_id ); 69 | 70 | U64 GetTransactionContainingPacket( U64 packet_id ); 71 | void GetPacketsContainedInTransaction( U64 transaction_id, U64** packet_id_array, U64* packet_id_count ); 72 | 73 | 74 | 75 | public: //text results setting and access: 76 | void ClearResultStrings(); 77 | void AddResultString( const char* str1, const char* str2 = NULL, const char* str3 = NULL, const char* str4 = NULL, const char* str5 = NULL, const char* str6 = NULL ); //multiple strings will be concatinated 78 | 79 | void GetResultStrings( char const*** result_string_array, U32* num_strings ); 80 | 81 | protected: //use these when exporting data. 82 | bool UpdateExportProgressAndCheckForCancel( U64 completed_frames, U64 total_frames ); 83 | 84 | public: //don't use 85 | 86 | bool DoBubblesAppearOnChannel( Channel& channel ); 87 | bool DoMarkersAppearOnChannel( Channel& channel ); 88 | bool GetFramesInRange( S64 starting_sample_inclusive, S64 ending_sample_inclusive, U64* first_frame_index, U64* last_frame_index ); 89 | bool GetMarkersInRange( Channel& channel, S64 starting_sample_inclusive, S64 ending_sample_inclusive, U64* first_marker_index, U64* last_marker_index ); 90 | void GetMarker( Channel& channel, U64 marker_index, MarkerType* marker_type, U64* marker_sample ); 91 | U64 GetNumMarkers( Channel& channel ); 92 | 93 | 94 | void CancelExport(); 95 | double GetProgress(); 96 | void StartExportThread( const char* file, DisplayBase display_base, U32 export_type_user_id ); 97 | 98 | protected: 99 | struct AnalyzerResultsData* mData; 100 | 101 | public: 102 | 103 | 104 | void AddTabularText(const char* str1, const char* str2 = NULL, const char* str3 = NULL, const char* str4 = NULL, const char* str5 = NULL, const char* str6 = NULL); 105 | void GetSearchData(const char ***result_string_array, U32 *num_strings); 106 | void ClearTabularText(); 107 | }; 108 | 109 | 110 | #endif //ANALYZER_RESULTS 111 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerSettingInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_SETTING_INTERFACE 2 | #define ANALYZER_SETTING_INTERFACE 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum AnalyzerInterfaceTypeId { INTERFACE_BASE, INTERFACE_CHANNEL, INTERFACE_NUMBER_LIST, INTERFACE_INTEGER, INTERFACE_TEXT, INTERFACE_BOOL }; 9 | 10 | // Saleae note: we don't need to have virtual functions to prevent code copies becuase they is only one copy of the code now -- in the DLL. 11 | // we need one virtual function, to return the class type; we're not using rtti 12 | 13 | //Saleae: using PIMPL; struct can change, non-virtual functions can be added to the end; 14 | //Saleae: Can not add/remove virtual functions 15 | 16 | 17 | struct AnalyzerSettingInterfaceData; 18 | class LOGICAPI AnalyzerSettingInterface 19 | { 20 | public: 21 | AnalyzerSettingInterface(); 22 | virtual ~AnalyzerSettingInterface(); 23 | 24 | static void operator delete ( void* p ); 25 | static void* operator new( size_t size ); 26 | virtual AnalyzerInterfaceTypeId GetType(); 27 | 28 | const char* GetToolTip(); 29 | const char* GetTitle(); 30 | bool IsDisabled(); 31 | void SetTitleAndTooltip( const char* title, const char* tooltip ); 32 | 33 | //todo: position, group, spacers, visual attributes 34 | 35 | protected: 36 | struct AnalyzerSettingInterfaceData* mData; 37 | 38 | }; 39 | 40 | struct AnalyzerSettingInterfaceChannelData; 41 | class LOGICAPI AnalyzerSettingInterfaceChannel : public AnalyzerSettingInterface 42 | { 43 | public: 44 | AnalyzerSettingInterfaceChannel(); 45 | virtual ~AnalyzerSettingInterfaceChannel(); 46 | virtual AnalyzerInterfaceTypeId GetType(); 47 | 48 | Channel GetChannel(); 49 | void SetChannel( const Channel& channel ); 50 | bool GetSelectionOfNoneIsAllowed(); 51 | void SetSelectionOfNoneIsAllowed( bool is_allowed ); 52 | 53 | protected: 54 | struct AnalyzerSettingInterfaceChannelData* mChannelData; 55 | }; 56 | 57 | 58 | struct AnalyzerSettingInterfaceNumberListData; 59 | class LOGICAPI AnalyzerSettingInterfaceNumberList : public AnalyzerSettingInterface 60 | { 61 | public: 62 | AnalyzerSettingInterfaceNumberList(); 63 | virtual ~AnalyzerSettingInterfaceNumberList(); 64 | virtual AnalyzerInterfaceTypeId GetType(); 65 | 66 | double GetNumber(); 67 | void SetNumber( double number ); 68 | 69 | U32 GetListboxNumbersCount(); 70 | double GetListboxNumber( U32 index ); 71 | 72 | U32 GetListboxStringsCount(); 73 | const char* GetListboxString( U32 index ); 74 | 75 | U32 GetListboxTooltipsCount(); 76 | const char* GetListboxTooltip( U32 index ); 77 | 78 | void AddNumber( double number, const char* str, const char* tooltip ); 79 | void ClearNumbers(); 80 | 81 | protected: 82 | struct AnalyzerSettingInterfaceNumberListData* mNumberListData; 83 | 84 | }; 85 | 86 | 87 | struct AnalyzerSettingInterfaceIntegerData; 88 | class LOGICAPI AnalyzerSettingInterfaceInteger : public AnalyzerSettingInterface 89 | { 90 | public: 91 | AnalyzerSettingInterfaceInteger(); 92 | virtual ~AnalyzerSettingInterfaceInteger(); 93 | virtual AnalyzerInterfaceTypeId GetType(); 94 | 95 | int GetInteger(); 96 | void SetInteger( int integer ); 97 | 98 | int GetMax(); 99 | int GetMin(); 100 | 101 | void SetMax( int max ); 102 | void SetMin( int min ); 103 | 104 | protected: 105 | struct AnalyzerSettingInterfaceIntegerData* mIntegerData; 106 | 107 | }; 108 | 109 | 110 | struct AnalyzerSettingInterfaceTextData; 111 | class LOGICAPI AnalyzerSettingInterfaceText : public AnalyzerSettingInterface 112 | { 113 | public: 114 | AnalyzerSettingInterfaceText(); 115 | virtual ~AnalyzerSettingInterfaceText(); 116 | 117 | AnalyzerInterfaceTypeId GetType(); 118 | const char* GetText(); 119 | void SetText( const char* text ); 120 | 121 | enum TextType { NormalText, FilePath, FolderPath }; 122 | TextType GetTextType(); 123 | void SetTextType( TextType text_type ); 124 | 125 | 126 | protected: 127 | struct AnalyzerSettingInterfaceTextData* mTextData; 128 | 129 | }; 130 | 131 | 132 | struct AnalyzerSettingInterfaceBoolData; 133 | class LOGICAPI AnalyzerSettingInterfaceBool : public AnalyzerSettingInterface 134 | { 135 | public: 136 | AnalyzerSettingInterfaceBool(); 137 | virtual ~AnalyzerSettingInterfaceBool(); 138 | virtual AnalyzerInterfaceTypeId GetType(); 139 | 140 | bool GetValue(); 141 | void SetValue( bool value ); 142 | const char* GetCheckBoxText(); 143 | void SetCheckBoxText( const char* text ); 144 | 145 | protected: 146 | struct AnalyzerSettingInterfaceBoolData* mBoolData; 147 | 148 | }; 149 | 150 | #endif //ANALYZER_SETTING_INTERFACE 151 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerSettings.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_SETTINGS 2 | #define ANALYZER_SETTINGS 3 | 4 | #include 5 | #include "AnalyzerSettingInterface.h" 6 | 7 | 8 | struct AnalyzerSettingsData; 9 | struct AnalyzerValueDescription; 10 | 11 | class LOGICAPI AnalyzerSettings 12 | { 13 | public: 14 | AnalyzerSettings(); 15 | virtual ~AnalyzerSettings(); 16 | 17 | //Implement 18 | virtual bool SetSettingsFromInterfaces() = 0;//Get the settings out of the interfaces, validate them, and save them to your local settings vars. 19 | virtual void LoadSettings( const char* settings ) = 0; //Load your settings from the provided string 20 | virtual const char* SaveSettings() = 0; //Save your settings to a string and return it. (use SetSettingsString, return GetSettingsString) 21 | 22 | protected: 23 | //Use, but don't override/implement 24 | void ClearChannels(); //clear all the reported channels before adding them, if you need to change them. 25 | void AddChannel( Channel& channel, const char* channel_label, bool is_used ); //used to report the channels we're working with to the outside world. 26 | 27 | void SetErrorText( const char* error_text ); //if settings are invalid, set the text to display to the user (used in SetSettingsFromInterfaces) 28 | void AddInterface( AnalyzerSettingInterface* analyzer_setting_interface ); //add your interfaces so the outside world can access. You'll need to keep copies of all the pointers you provide. 29 | 30 | void AddExportOption( U32 user_id, const char* menu_text ); 31 | void AddExportExtension( U32 user_id, const char * extension_description, const char * extension ); 32 | 33 | const char* SetReturnString( const char* str ); 34 | 35 | //void ClearValueOutputs(); 36 | //void AddValueOutput( const char* name ); 37 | public: 38 | //Do not use, do not override 39 | U32 GetSettingsInterfacesCount(); 40 | AnalyzerSettingInterface* GetSettingsInterface( U32 index ); 41 | 42 | U32 GetFileExtensionCount( U32 index_id ); 43 | void GetFileExtension( U32 index_id, U32 extension_id, char const ** extension_description, char const ** extension ); 44 | 45 | 46 | 47 | U32 GetChannelsCount(); 48 | Channel GetChannel( U32 index, char const ** channel_label, bool* channel_is_used ); 49 | 50 | U32 GetExportOptionsCount(); 51 | void GetExportOption( U32 index, U32* user_id, char const ** menu_text ); 52 | 53 | const char* GetSaveErrorMessage(); 54 | 55 | bool GetUseSystemDisplayBase(); 56 | void SetUseSystemDisplayBase( bool use_system_display_base ); 57 | DisplayBase GetAnalyzerDisplayBase(); 58 | void SetAnalyzerDisplayBase( DisplayBase analyzer_display_base ); 59 | //added 5-15-2012 60 | //U32 GetValueDescriptionCount(); 61 | //AnalyzerValueDescription GetValueDescription( U32 index ); 62 | 63 | protected: 64 | struct AnalyzerSettingsData* mData; 65 | 66 | }; 67 | 68 | #endif //ANALYZER_SETTINGS 69 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/AnalyzerTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZERPUBLICTYPES 2 | #define ANALYZERPUBLICTYPES 3 | 4 | #include 5 | 6 | namespace AnalyzerEnums 7 | { 8 | enum ShiftOrder { MsbFirst, LsbFirst }; 9 | enum EdgeDirection { PosEdge, NegEdge }; 10 | enum Edge { LeadingEdge, TrailingEdge }; 11 | enum Parity { None, Even, Odd }; 12 | enum Acknowledge { Ack, Nak }; 13 | enum Sign { UnsignedInteger, SignedInteger }; 14 | }; 15 | 16 | #endif //ANALYZERPUBLICTYPES 17 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/LogicPublicTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICPUBLICTYPES 2 | #define LOGICPUBLICTYPES 3 | 4 | #include 5 | 6 | #ifndef WIN32 7 | #define __cdecl 8 | #endif 9 | 10 | //If we discover that Analyzer needs to be compiled statically, and that __declspec(dllexport) causes an error with that build, 11 | //then we need to add a define to turn this on or off for that project. i.e. Device SDK build. Not tested yet. 12 | #ifdef WIN32 13 | #define LOGICAPI __declspec(dllexport) 14 | #else 15 | #define LOGICAPI __attribute__ ((visibility("default"))) 16 | #endif 17 | 18 | #ifdef WIN32 19 | #define ANALYZER_EXPORT __declspec(dllexport) 20 | #else 21 | #define ANALYZER_EXPORT __attribute__ ((visibility("default"))) 22 | #endif 23 | 24 | typedef char S8; 25 | typedef short S16; 26 | typedef int S32; 27 | typedef long long int S64; 28 | 29 | typedef unsigned char U8; 30 | typedef unsigned short U16; 31 | typedef unsigned int U32; 32 | typedef unsigned long long int U64; 33 | //typedef signed long long int S64; 34 | 35 | #ifndef NULL 36 | #define NULL 0 37 | #endif 38 | 39 | enum DisplayBase { Binary, Decimal, Hexadecimal, ASCII, AsciiHex }; 40 | enum BitState { BIT_LOW, BIT_HIGH }; 41 | 42 | enum ChannelDataType { 43 | ANALOG_CHANNEL = 0, 44 | DIGITAL_CHANNEL = 1}; 45 | 46 | #define Toggle(x) ( x == BIT_LOW ? BIT_HIGH : BIT_LOW ) 47 | #define Invert(x) ( x == BIT_LOW ? BIT_HIGH : BIT_LOW ) 48 | 49 | #define UNDEFINED_CHANNEL Channel( 0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFF, DIGITAL_CHANNEL ) 50 | 51 | //Saleae: Note this class can not add, remove or reorder member variables without breaking binary compatibilty 52 | //Saleae: This function can add non-virtual functions as long as they are listed after existing functions. 53 | class LOGICAPI Channel 54 | { 55 | public: 56 | Channel(); 57 | Channel( const Channel& channel ); 58 | Channel( U64 device_id, U32 channel_index, ChannelDataType data_type ); 59 | ~Channel(); 60 | 61 | Channel& operator=( const Channel& channel ); 62 | bool operator==( const Channel& channel ) const; 63 | bool operator!=( const Channel& channel ) const; 64 | bool operator>( const Channel& channel ) const; 65 | bool operator<( const Channel& channel ) const; 66 | 67 | U64 mDeviceId; 68 | U32 mChannelIndex; 69 | ChannelDataType mDataType; 70 | //static std::vector mFilteredChannels; // TODO: Messy idea, need a better way to fix Debug Assertion Failed error (_pfirstblock == phead ) 71 | static std::vectorFilterChannelType( std::vector all_channels, ChannelDataType data_type ); 72 | static std::vector GetChannelIndexes( std::vector channels ); 73 | 74 | }; 75 | 76 | 77 | #include //required by some compilers for std::auto_ptr 78 | 79 | #ifdef _MSC_VER 80 | #define snprintf _snprintf_s 81 | #define vsnprintf vsprintf_s 82 | #endif 83 | 84 | #endif //LOGICPUBLICTYPES 85 | -------------------------------------------------------------------------------- /AnalyzerSDK/include/SimulationChannelDescriptor.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_CHANNEL_DESCRIPTOR 2 | #define SIMULATION_CHANNEL_DESCRIPTOR 3 | 4 | #include 5 | 6 | //Saleae: PIMPL implementation can be changed, non-virtual functions can be added at the end, no vars can be added/removed/reordered/changed. 7 | struct SimulationChannelDescriptorData; 8 | class LOGICAPI SimulationChannelDescriptor 9 | { 10 | public: 11 | void Transition(); 12 | void TransitionIfNeeded( BitState bit_state ); 13 | void Advance( U32 num_samples_to_advance ); 14 | 15 | BitState GetCurrentBitState(); 16 | U64 GetCurrentSampleNumber(); 17 | 18 | public: //don't use 19 | SimulationChannelDescriptor(); 20 | SimulationChannelDescriptor( const SimulationChannelDescriptor& other ); 21 | ~SimulationChannelDescriptor(); 22 | SimulationChannelDescriptor& operator=( const SimulationChannelDescriptor& other ); 23 | 24 | void SetChannel( Channel& channel ); 25 | void SetSampleRate( U32 sample_rate_hz ); 26 | void SetInitialBitState( BitState intial_bit_state ); 27 | 28 | Channel GetChannel(); 29 | U32 GetSampleRate(); 30 | BitState GetInitialBitState(); 31 | void* GetData(); 32 | 33 | protected: 34 | struct SimulationChannelDescriptorData* mData; 35 | 36 | 37 | }; 38 | 39 | 40 | struct SimulationChannelDescriptorGroupData; 41 | class LOGICAPI SimulationChannelDescriptorGroup 42 | { 43 | public: 44 | SimulationChannelDescriptorGroup(); 45 | ~SimulationChannelDescriptorGroup(); 46 | 47 | SimulationChannelDescriptor* Add( Channel& channel, U32 sample_rate, BitState intial_bit_state ); //do not delete this pointer 48 | 49 | void AdvanceAll( U32 num_samples_to_advance ); 50 | 51 | public: 52 | SimulationChannelDescriptor* GetArray(); 53 | U32 GetCount(); 54 | 55 | protected: 56 | struct SimulationChannelDescriptorGroupData* mData; 57 | }; 58 | 59 | 60 | 61 | #endif //SIMULATION_CHANNEL_DESCRIPTOR 62 | -------------------------------------------------------------------------------- /AnalyzerSDK/lib/Analyzer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/Analyzer.dll -------------------------------------------------------------------------------- /AnalyzerSDK/lib/Analyzer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/Analyzer.lib -------------------------------------------------------------------------------- /AnalyzerSDK/lib/Analyzer64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/Analyzer64.dll -------------------------------------------------------------------------------- /AnalyzerSDK/lib/Analyzer64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/Analyzer64.lib -------------------------------------------------------------------------------- /AnalyzerSDK/lib/libAnalyzer.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/libAnalyzer.dylib -------------------------------------------------------------------------------- /AnalyzerSDK/lib/libAnalyzer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/AnalyzerSDK/lib/libAnalyzer.so -------------------------------------------------------------------------------- /AnalyzerSDK/lib/readme.txt: -------------------------------------------------------------------------------- 1 | Windows: 2 | Analyzer.dll 3 | Analyzer.lib 4 | 5 | Mac: 6 | libAnalyzer.dylib 7 | 8 | Linux: 9 | libAnalyzer.so 10 | 11 | Linux 64-bit: 12 | libAnalyzer64.so 13 | 14 | 15 | If you're on Linux 64-bit, remove libAnalyzer.so, and then rename libAnalyzer64.so to libAnalyzer.so 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 robbederks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/Analyzer.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER 2 | #define ANALYZER 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "AnalyzerSettings.h" 9 | 10 | class AnalyzerChannelData; 11 | class DeviceCollection; 12 | class ConditionManager; 13 | class ProgressManager; 14 | struct AnalyzerData; 15 | class AnalyzerResults; 16 | 17 | class LOGICAPI Analyzer 18 | { 19 | public: 20 | Analyzer(); 21 | virtual ~Analyzer() = 0; 22 | virtual void WorkerThread() = 0; 23 | 24 | //sample_rate: if there are multiple devices attached, and one is faster than the other, 25 | //we can sample at the speed of the faster one; and pretend the slower one is the same speed. 26 | virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels ) = 0; 27 | virtual U32 GetMinimumSampleRateHz() = 0; //provide the sample rate required to generate good simulation data 28 | virtual const char* GetAnalyzerName() const = 0; 29 | virtual bool NeedsRerun() = 0; 30 | 31 | //use, but don't override: 32 | void SetAnalyzerSettings( AnalyzerSettings* settings ); 33 | void KillThread(); 34 | AnalyzerChannelData* GetAnalyzerChannelData( Channel& channel ); //don't delete this pointer 35 | void ReportProgress( U64 sample_number ); 36 | void SetAnalyzerResults( AnalyzerResults* results ); 37 | U32 GetSimulationSampleRate(); 38 | U32 GetSampleRate(); 39 | U64 GetTriggerSample(); 40 | 41 | //don't override, don't use: 42 | void Init( DeviceCollection* device_collection, ConditionManager* condition_manager, ProgressManager* progress_manager ); 43 | void StartProcessing(); 44 | void StopWorkerThread(); 45 | AnalyzerSettings* GetAnalyzerSettings(); 46 | bool DoesAnalyzerUseDevice( U64 device_id ); 47 | bool IsValid( Channel* channel_array, U32 count ); 48 | void InitialWorkerThread(); 49 | bool GetAnalyzerResults( AnalyzerResults** analyzer_results ); 50 | 51 | //functions added after initial release -- added at the bottom for binary compatibilty 52 | void CheckIfThreadShouldExit(); 53 | double GetAnalyzerProgress(); 54 | void SetThreadMustExit(); 55 | 56 | void StartProcessing( U64 starting_sample ); 57 | 58 | 59 | 60 | /* 61 | bool DoesChannelHaveBubbles( Channel& channel ); 62 | bool DoesChannelHaveMarkers( Channel& channel ); 63 | bool GetBubblesInRange( Channel& channel, S64 starting_sample_inclusive, S64 ending_sample_inclusive, U32* first_bubble, U32* last_bubble ); 64 | bool GetMarkersInRange( Channel& channel, S64 starting_sample_inclusive, S64 ending_sample_inclusive, U32* first_marker, U32* last_marker ); 65 | void GetBubblePosition( Channel& channel, U32 index, U64& starting_position_inclusive, U64& ending_position_inclusive ); 66 | ResultMarker GetMarker( Channel& channel, U32 index ); 67 | U64 GetNumBubbles( Channel& channel ); 68 | U64 GetNumMarkers( Channel& channel ); 69 | */ 70 | 71 | 72 | 73 | protected: 74 | struct AnalyzerData* mData; 75 | }; 76 | 77 | class LOGICAPI Analyzer2 : public Analyzer 78 | { 79 | public: 80 | Analyzer2(); 81 | virtual void SetupResults(); 82 | }; 83 | 84 | #endif //ANALYZER 85 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerChannelData.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZERCHANNELDATA 2 | #define ANALYZERCHANNELDATA 3 | 4 | #include 5 | 6 | struct AnalyzerChannelDataData; 7 | class ChannelData; 8 | class LOGICAPI AnalyzerChannelData 9 | { 10 | public: 11 | AnalyzerChannelData( ChannelData* channel_data ); 12 | ~AnalyzerChannelData(); 13 | 14 | //State 15 | U64 GetSampleNumber(); 16 | BitState GetBitState(); 17 | 18 | //Basic: 19 | U32 Advance( U32 num_samples ); //move forward the specified number of samples. Returns the number of times the bit changed state during the move. 20 | U32 AdvanceToAbsPosition( U64 sample_number ); //move forward to the specified sample number. Returns the number of times the bit changed state during the move. 21 | void AdvanceToNextEdge(); //move forward until the bit state changes from what it is now. 22 | 23 | //Fancier 24 | U64 GetSampleOfNextEdge(); //without moving, get the sample of the next transition. 25 | bool WouldAdvancingCauseTransition( U32 num_samples ); //if we advanced, would we encounter any transitions? 26 | bool WouldAdvancingToAbsPositionCauseTransition( U64 sample_number ); //if we advanced, would we encounter any transitions? 27 | 28 | //minimum pulse tracking. The serial analyzer uses this for auto-baud 29 | void TrackMinimumPulseWidth(); //normally this is not enabled. 30 | U64 GetMinimumPulseWidthSoFar(); 31 | 32 | //Fancier, part II 33 | bool DoMoreTransitionsExistInCurrentData(); //use this when you have a situation where you have multiple lines, and you need to handle the case where one or the other of them may never change again, and you don't know which. 34 | 35 | 36 | protected: 37 | AnalyzerChannelDataData* mData; 38 | }; 39 | 40 | 41 | #endif //ANALYZERCHANNELDATA -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_HELPERS_H 2 | #define ANALYZER_HELPERS_H 3 | 4 | #include "Analyzer.h" 5 | 6 | class LOGICAPI AnalyzerHelpers 7 | { 8 | public: 9 | static bool IsEven( U64 value ); 10 | static bool IsOdd( U64 value ); 11 | static U32 GetOnesCount( U64 value ); 12 | static U32 Diff32( U32 a, U32 b ); 13 | 14 | static void GetNumberString( U64 number, DisplayBase display_base, U32 num_data_bits, char* result_string, U32 result_string_max_length ); 15 | static void GetTimeString( U64 sample, U64 trigger_sample, U32 sample_rate_hz, char* result_string, U32 result_string_max_length ); 16 | 17 | static void Assert( const char* message ); 18 | static U64 AdjustSimulationTargetSample( U64 target_sample, U32 sample_rate, U32 simulation_sample_rate ); 19 | 20 | static bool DoChannelsOverlap( const Channel* channel_array, U32 num_channels ); 21 | static void SaveFile( const char* file_name, const U8* data, U32 data_length, bool is_binary = false ); 22 | 23 | static S64 ConvertToSignedNumber( U64 number, U32 num_bits ); 24 | 25 | //These save functions should not be used with SaveFile, above. They are a better way to export data (don't waste memory), and should be used from now on. 26 | static void* StartFile( const char* file_name, bool is_binary = false ); 27 | static void AppendToFile( const U8* data, U32 data_length, void* file ); 28 | static void EndFile( void* file ); 29 | }; 30 | 31 | 32 | 33 | 34 | struct ClockGeneratorData; 35 | class LOGICAPI ClockGenerator 36 | { 37 | public: 38 | ClockGenerator(); 39 | ~ClockGenerator(); 40 | void Init( double target_frequency, U32 sample_rate_hz ); 41 | U32 AdvanceByHalfPeriod( double multiple = 1.0 ); 42 | U32 AdvanceByTimeS( double time_s ); 43 | 44 | protected: 45 | struct ClockGeneratorData* mData; 46 | }; 47 | 48 | 49 | 50 | struct BitExtractorData; 51 | class LOGICAPI BitExtractor 52 | { 53 | public: 54 | BitExtractor( U64 data, AnalyzerEnums::ShiftOrder shift_order, U32 num_bits ); 55 | ~BitExtractor(); 56 | 57 | BitState GetNextBit(); 58 | 59 | protected: 60 | struct BitExtractorData* mData; 61 | }; 62 | 63 | 64 | struct DataBuilderData; 65 | class LOGICAPI DataBuilder 66 | { 67 | public: 68 | DataBuilder(); 69 | ~DataBuilder(); 70 | 71 | void Reset( U64* data, AnalyzerEnums::ShiftOrder shift_order, U32 num_bits ); 72 | void AddBit( BitState bit ); 73 | 74 | protected: 75 | struct DataBuilderData* mData; 76 | }; 77 | 78 | 79 | 80 | 81 | struct SimpleArchiveData; 82 | class LOGICAPI SimpleArchive 83 | { 84 | public: 85 | SimpleArchive(); 86 | ~SimpleArchive(); 87 | 88 | void SetString( const char* archive_string ); 89 | const char* GetString(); 90 | 91 | bool operator<<( U64 data ); 92 | bool operator<<( U32 data ); 93 | bool operator<<( S64 data ); 94 | bool operator<<( S32 data ); 95 | bool operator<<( double data ); 96 | bool operator<<( bool data ); 97 | bool operator<<( const char* data ); 98 | bool operator<<( Channel& data ); 99 | 100 | bool operator>>( U64& data ); 101 | bool operator>>( U32& data ); 102 | bool operator>>( S64& data ); 103 | bool operator>>( S32& data ); 104 | bool operator>>( double& data ); 105 | bool operator>>( bool& data ); 106 | bool operator>>( char const ** data ); 107 | bool operator>>( Channel& data ); 108 | 109 | protected: 110 | struct SimpleArchiveData* mData; 111 | }; 112 | 113 | #endif //ANALYZER_HELPERS_H 114 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerResults.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_RESULTS 2 | #define ANALYZER_RESULTS 3 | 4 | #include 5 | 6 | #define DISPLAY_AS_ERROR_FLAG ( 1 << 7 ) 7 | #define DISPLAY_AS_WARNING_FLAG ( 1 << 6 ) 8 | 9 | class LOGICAPI Frame 10 | { 11 | public: 12 | Frame(); 13 | Frame( const Frame& frame ); 14 | ~Frame(); 15 | 16 | S64 mStartingSampleInclusive; 17 | S64 mEndingSampleInclusive; 18 | U64 mData1; 19 | U64 mData2; 20 | U8 mType; 21 | U8 mFlags; 22 | 23 | bool HasFlag( U8 flag ); 24 | }; 25 | 26 | #define INVALID_RESULT_INDEX 0xFFFFFFFFFFFFFFFFull 27 | struct AnalyzerResultsData; 28 | class LOGICAPI AnalyzerResults 29 | { 30 | public: 31 | enum MarkerType { Dot, ErrorDot, Square, ErrorSquare, UpArrow, DownArrow, X, ErrorX, Start, Stop, One, Zero }; 32 | AnalyzerResults(); //you must call the base class contructor in your constructor 33 | virtual ~AnalyzerResults(); 34 | 35 | //override: 36 | virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base ) = 0; 37 | virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id ) = 0; 38 | virtual void GenerateFrameTabularText( U64 frame_index, DisplayBase display_base ) = 0; 39 | virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base ) = 0; 40 | virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base ) = 0; 41 | 42 | public: //adding/setting data 43 | void AddMarker( U64 sample_number, MarkerType marker_type, Channel& channel ); 44 | 45 | U64 AddFrame( Frame& frame ); 46 | U64 CommitPacketAndStartNewPacket(); 47 | void CancelPacketAndStartNewPacket(); 48 | void AddPacketToTransaction( U64 transaction_id, U64 packet_id ); 49 | void AddChannelBubblesWillAppearOn( const Channel& channel ); 50 | 51 | void CommitResults(); 52 | 53 | public: //data access 54 | U64 GetNumFrames(); 55 | U64 GetNumPackets(); 56 | Frame GetFrame( U64 frame_id ); 57 | 58 | U64 GetPacketContainingFrame( U64 frame_id ); 59 | U64 GetPacketContainingFrameSequential( U64 frame_id ); 60 | void GetFramesContainedInPacket( U64 packet_id, U64* first_frame_id, U64* last_frame_id ); 61 | 62 | U32 GetTransactionContainingPacket( U64 packet_id ); 63 | void GetPacketsContainedInTransaction( U64 transaction_id, U64** packet_id_array, U64* packet_id_count ); 64 | 65 | 66 | 67 | public: //text results setting and access: 68 | void ClearResultStrings(); 69 | void AddResultString( const char* str1, const char* str2 = NULL, const char* str3 = NULL, const char* str4 = NULL, const char* str5 = NULL, const char* str6 = NULL ); //multiple strings will be concatinated 70 | 71 | void GetResultStrings( char const*** result_string_array, U32* num_strings ); 72 | 73 | protected: //use these when exporting data. 74 | bool UpdateExportProgressAndCheckForCancel( U64 completed_frames, U64 total_frames ); 75 | 76 | public: //don't use 77 | 78 | bool DoBubblesAppearOnChannel( Channel& channel ); 79 | bool DoMarkersAppearOnChannel( Channel& channel ); 80 | bool GetFramesInRange( S64 starting_sample_inclusive, S64 ending_sample_inclusive, U64* first_frame_index, U64* last_frame_index ); 81 | bool GetMarkersInRange( Channel& channel, S64 starting_sample_inclusive, S64 ending_sample_inclusive, U64* first_marker_index, U64* last_marker_index ); 82 | void GetMarker( Channel& channel, U64 marker_index, MarkerType* marker_type, U64* marker_sample ); 83 | U64 GetNumMarkers( Channel& channel ); 84 | 85 | 86 | void CancelExport(); 87 | double GetProgress(); 88 | void StartExportThread( const char* file, DisplayBase display_base, U32 export_type_user_id ); 89 | 90 | 91 | protected: 92 | struct AnalyzerResultsData* mData; 93 | }; 94 | 95 | 96 | #endif //ANALYZER_RESULTS 97 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerSettingInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_SETTING_INTERFACE 2 | #define ANALYZER_SETTING_INTERFACE 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum AnalyzerInterfaceTypeId { INTERFACE_BASE, INTERFACE_CHANNEL, INTERFACE_NUMBER_LIST, INTERFACE_INTEGER, INTERFACE_TEXT, INTERFACE_BOOL }; 9 | 10 | // Saleae note: we don't need to have virtual functions to prevent code copies becuase they is only one copy of the code now -- in the DLL. 11 | // we need one virtual function, to return the class type; we're not using rtti 12 | 13 | //Saleae: using PIMPL; struct can change, non-virtual functions can be added to the end; 14 | //Saleae: Can not add/remove virtual functions 15 | 16 | 17 | struct AnalyzerSettingInterfaceData; 18 | class LOGICAPI AnalyzerSettingInterface 19 | { 20 | public: 21 | AnalyzerSettingInterface(); 22 | virtual ~AnalyzerSettingInterface(); 23 | 24 | static void operator delete ( void* p ); 25 | static void* operator new( size_t size ); 26 | virtual AnalyzerInterfaceTypeId GetType(); 27 | 28 | const char* GetToolTip(); 29 | const char* GetTitle(); 30 | bool IsDisabled(); 31 | void SetTitleAndTooltip( const char* title, const char* tooltip ); 32 | 33 | //todo: position, group, spacers, visual attributes 34 | 35 | protected: 36 | struct AnalyzerSettingInterfaceData* mData; 37 | 38 | }; 39 | 40 | struct AnalyzerSettingInterfaceChannelData; 41 | class LOGICAPI AnalyzerSettingInterfaceChannel : public AnalyzerSettingInterface 42 | { 43 | public: 44 | AnalyzerSettingInterfaceChannel(); 45 | virtual ~AnalyzerSettingInterfaceChannel(); 46 | virtual AnalyzerInterfaceTypeId GetType(); 47 | 48 | Channel GetChannel(); 49 | void SetChannel( const Channel& channel ); 50 | bool GetSelectionOfNoneIsAllowed(); 51 | void SetSelectionOfNoneIsAllowed( bool is_allowed ); 52 | 53 | protected: 54 | struct AnalyzerSettingInterfaceChannelData* mChannelData; 55 | }; 56 | 57 | 58 | struct AnalyzerSettingInterfaceNumberListData; 59 | class LOGICAPI AnalyzerSettingInterfaceNumberList : public AnalyzerSettingInterface 60 | { 61 | public: 62 | AnalyzerSettingInterfaceNumberList(); 63 | virtual ~AnalyzerSettingInterfaceNumberList(); 64 | virtual AnalyzerInterfaceTypeId GetType(); 65 | 66 | double GetNumber(); 67 | void SetNumber( double number ); 68 | 69 | U32 GetListboxNumbersCount(); 70 | double GetListboxNumber( U32 index ); 71 | 72 | U32 GetListboxStringsCount(); 73 | const char* GetListboxString( U32 index ); 74 | 75 | U32 GetListboxTooltipsCount(); 76 | const char* GetListboxTooltip( U32 index ); 77 | 78 | void AddNumber( double number, const char* str, const char* tooltip ); 79 | void ClearNumbers(); 80 | 81 | protected: 82 | struct AnalyzerSettingInterfaceNumberListData* mNumberListData; 83 | 84 | }; 85 | 86 | 87 | struct AnalyzerSettingInterfaceIntegerData; 88 | class LOGICAPI AnalyzerSettingInterfaceInteger : public AnalyzerSettingInterface 89 | { 90 | public: 91 | AnalyzerSettingInterfaceInteger(); 92 | virtual ~AnalyzerSettingInterfaceInteger(); 93 | virtual AnalyzerInterfaceTypeId GetType(); 94 | 95 | int GetInteger(); 96 | void SetInteger( int integer ); 97 | 98 | int GetMax(); 99 | int GetMin(); 100 | 101 | void SetMax( int max ); 102 | void SetMin( int min ); 103 | 104 | protected: 105 | struct AnalyzerSettingInterfaceIntegerData* mIntegerData; 106 | 107 | }; 108 | 109 | 110 | struct AnalyzerSettingInterfaceTextData; 111 | class LOGICAPI AnalyzerSettingInterfaceText : public AnalyzerSettingInterface 112 | { 113 | public: 114 | AnalyzerSettingInterfaceText(); 115 | virtual ~AnalyzerSettingInterfaceText(); 116 | 117 | AnalyzerInterfaceTypeId GetType(); 118 | const char* GetText(); 119 | void SetText( const char* text ); 120 | 121 | enum TextType { NormalText, FilePath, FolderPath }; 122 | TextType GetTextType(); 123 | void SetTextType( TextType text_type ); 124 | 125 | 126 | protected: 127 | struct AnalyzerSettingInterfaceTextData* mTextData; 128 | 129 | }; 130 | 131 | 132 | struct AnalyzerSettingInterfaceBoolData; 133 | class LOGICAPI AnalyzerSettingInterfaceBool : public AnalyzerSettingInterface 134 | { 135 | public: 136 | AnalyzerSettingInterfaceBool(); 137 | virtual ~AnalyzerSettingInterfaceBool(); 138 | virtual AnalyzerInterfaceTypeId GetType(); 139 | 140 | bool GetValue(); 141 | void SetValue( bool value ); 142 | const char* GetCheckBoxText(); 143 | void SetCheckBoxText( const char* text ); 144 | 145 | protected: 146 | struct AnalyzerSettingInterfaceBoolData* mBoolData; 147 | 148 | }; 149 | 150 | #endif //ANALYZER_SETTING_INTERFACE 151 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerSettings.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZER_SETTINGS 2 | #define ANALYZER_SETTINGS 3 | 4 | #include 5 | #include "AnalyzerSettingInterface.h" 6 | 7 | 8 | struct AnalyzerSettingsData; 9 | class LOGICAPI AnalyzerSettings 10 | { 11 | public: 12 | AnalyzerSettings(); 13 | virtual ~AnalyzerSettings(); 14 | 15 | //Implement 16 | virtual bool SetSettingsFromInterfaces() = 0;//Get the settings out of the interfaces, validate them, and save them to your local settings vars. 17 | virtual void LoadSettings( const char* settings ) = 0; //Load your settings from the provided string 18 | virtual const char* SaveSettings() = 0; //Save your settings to a string and return it. (use SetSettingsString, return GetSettingsString) 19 | 20 | protected: 21 | //Use, but don't override/implement 22 | void ClearChannels(); //clear all the reported channels before adding them, if you need to change them. 23 | void AddChannel( Channel& channel, const char* channel_label, bool is_used ); //used to report the channels we're working with to the outside world. 24 | 25 | void SetErrorText( const char* error_text ); //if settings are invalid, set the text to display to the user (used in SetSettingsFromInterfaces) 26 | void AddInterface( AnalyzerSettingInterface* analyzer_setting_interface ); //add your interfaces so the outside world can access. You'll need to keep copies of all the pointers you provide. 27 | 28 | void AddExportOption( U32 user_id, const char* menu_text ); 29 | void AddExportExtension( U32 user_id, const char * extension_description, const char * extension ); 30 | 31 | const char* SetReturnString( const char* str ); 32 | public: 33 | //Do not use, do not override 34 | U32 GetSettingsInterfacesCount(); 35 | AnalyzerSettingInterface* GetSettingsInterface( U32 index ); 36 | 37 | U32 GetFileExtensionCount( U32 index_id ); 38 | void GetFileExtension( U32 index_id, U32 extension_id, char const ** extension_description, char const ** extension ); 39 | 40 | 41 | 42 | U32 GetChannelsCount(); 43 | Channel GetChannel( U32 index, char const ** channel_label, bool* channel_is_used ); 44 | 45 | U32 GetExportOptionsCount(); 46 | void GetExportOption( U32 index, U32* user_id, char const ** menu_text ); 47 | 48 | const char* GetSaveErrorMessage(); 49 | 50 | bool GetUseSystemDisplayBase(); 51 | void SetUseSystemDisplayBase( bool use_system_display_base ); 52 | DisplayBase GetAnalyzerDisplayBase(); 53 | void SetAnalyzerDisplayBase( DisplayBase analyzer_display_base ); 54 | 55 | protected: 56 | struct AnalyzerSettingsData* mData; 57 | 58 | }; 59 | 60 | #endif //ANALYZER_SETTINGS -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/AnalyzerTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYZERPUBLICTYPES 2 | #define ANALYZERPUBLICTYPES 3 | 4 | #include 5 | 6 | namespace AnalyzerEnums 7 | { 8 | enum ShiftOrder { MsbFirst, LsbFirst }; 9 | enum EdgeDirection { PosEdge, NegEdge }; 10 | enum Edge { LeadingEdge, TrailingEdge }; 11 | enum Parity { None, Even, Odd }; 12 | enum Acknowledge { Ack, Nak }; 13 | enum Sign { UnsignedInteger, SignedInteger }; 14 | }; 15 | 16 | #endif //ANALYZERPUBLICTYPES 17 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/LogicPublicTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICPUBLICTYPES 2 | #define LOGICPUBLICTYPES 3 | 4 | #ifndef WIN32 5 | #define __cdecl 6 | #endif 7 | 8 | #ifdef ANALYZER_EXPORTS 9 | #ifdef WIN32 10 | #define LOGICAPI __declspec(dllexport) 11 | #else 12 | #define LOGICAPI __attribute__ ((visibility("default"))) 13 | #endif 14 | #else 15 | #define LOGICAPI 16 | #endif 17 | 18 | #ifdef WIN32 19 | #define ANALYZER_EXPORT __declspec(dllexport) 20 | #else 21 | #define ANALYZER_EXPORT __attribute__ ((visibility("default"))) 22 | #endif 23 | 24 | 25 | typedef char S8; 26 | typedef short S16; 27 | typedef int S32; 28 | typedef long long int S64; 29 | 30 | typedef unsigned char U8; 31 | typedef unsigned short U16; 32 | typedef unsigned int U32; 33 | typedef unsigned long long int U64; 34 | typedef signed long long int S64; 35 | 36 | #ifndef NULL 37 | #define NULL 0 38 | #endif 39 | 40 | enum DisplayBase { Binary, Decimal, Hexadecimal, ASCII, AsciiHex }; 41 | enum BitState { BIT_LOW, BIT_HIGH }; 42 | #define Toggle(x) ( x == BIT_LOW ? BIT_HIGH : BIT_LOW ) 43 | #define Invert(x) ( x == BIT_LOW ? BIT_HIGH : BIT_LOW ) 44 | 45 | #define UNDEFINED_CHANNEL Channel( 0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFF ) 46 | 47 | //Saleae: Note this class can not add, remove or reorder member variables without breaking binary compatibilty 48 | //Saleae: This function can add non-virtual functions as long as they are listed after existing functions. 49 | class LOGICAPI Channel 50 | { 51 | public: 52 | Channel(); 53 | Channel( const Channel& channel ); 54 | Channel( U64 device_id, U32 channel_index ); 55 | ~Channel(); 56 | 57 | Channel& operator=( const Channel& channel ); 58 | bool operator==( const Channel& channel ) const; 59 | bool operator!=( const Channel& channel ) const; 60 | bool operator>( const Channel& channel ) const; 61 | bool operator<( const Channel& channel ) const; 62 | 63 | U64 mDeviceId; 64 | U32 mChannelIndex; 65 | }; 66 | 67 | #include //required by some compilers for std::auto_ptr 68 | 69 | #endif //LOGICPUBLICTYPES 70 | -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/include/SimulationChannelDescriptor.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_CHANNEL_DESCRIPTOR 2 | #define SIMULATION_CHANNEL_DESCRIPTOR 3 | 4 | #include 5 | 6 | //Saleae: PIMPL implementation can be changed, non-virtual functions can be added at the end, no vars can be added/removed/reordered/changed. 7 | struct SimulationChannelDescriptorData; 8 | class LOGICAPI SimulationChannelDescriptor 9 | { 10 | public: 11 | void Transition(); 12 | void TransitionIfNeeded( BitState bit_state ); 13 | void Advance( U32 num_samples_to_advance ); 14 | 15 | BitState GetCurrentBitState(); 16 | U64 GetCurrentSampleNumber(); 17 | 18 | public: //don't use 19 | SimulationChannelDescriptor(); 20 | SimulationChannelDescriptor( const SimulationChannelDescriptor& other ); 21 | ~SimulationChannelDescriptor(); 22 | SimulationChannelDescriptor& operator=( const SimulationChannelDescriptor& other ); 23 | 24 | void SetChannel( Channel& channel ); 25 | void SetSampleRate( U32 sample_rate_hz ); 26 | void SetInitialBitState( BitState intial_bit_state ); 27 | 28 | Channel GetChannel(); 29 | U32 GetSampleRate(); 30 | BitState GetInitialBitState(); 31 | void* GetData(); 32 | 33 | protected: 34 | struct SimulationChannelDescriptorData* mData; 35 | 36 | 37 | }; 38 | 39 | 40 | struct SimulationChannelDescriptorGroupData; 41 | class LOGICAPI SimulationChannelDescriptorGroup 42 | { 43 | public: 44 | SimulationChannelDescriptorGroup(); 45 | ~SimulationChannelDescriptorGroup(); 46 | 47 | SimulationChannelDescriptor* Add( Channel& channel, U32 sample_rate, BitState intial_bit_state ); //do not delete this pointer 48 | 49 | void AdvanceAll( U32 num_samples_to_advance ); 50 | 51 | public: 52 | SimulationChannelDescriptor* GetArray(); 53 | U32 GetCount(); 54 | 55 | protected: 56 | struct SimulationChannelDescriptorGroupData* mData; 57 | }; 58 | 59 | 60 | 61 | #endif //SIMULATION_CHANNEL_DESCRIPTOR -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/Analyzer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/LegacyAnalyzerSDK/lib/Analyzer.dll -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/Analyzer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/LegacyAnalyzerSDK/lib/Analyzer.lib -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/libAnalyzer.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/LegacyAnalyzerSDK/lib/libAnalyzer.dylib -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/libAnalyzer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/LegacyAnalyzerSDK/lib/libAnalyzer.so -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/libAnalyzer64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/LegacyAnalyzerSDK/lib/libAnalyzer64.so -------------------------------------------------------------------------------- /LegacyAnalyzerSDK/lib/readme.txt: -------------------------------------------------------------------------------- 1 | Windows: 2 | Analyzer.dll 3 | Analyzer.lib 4 | 5 | Mac: 6 | libAnalyzer.dylib 7 | 8 | Linux: 9 | libAnalyzer.so 10 | 11 | Linux 64-bit: 12 | libAnalyzer64.so 13 | 14 | 15 | If you're on Linux 64-bit, remove libAnalyzer.so, and then rename libAnalyzer64.so to libAnalyzer.so 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FlexRayAnalyzer 2 | Saleae Logic plugin for decoding FlexRay packets 3 | -------------------------------------------------------------------------------- /build_analyzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Python 3 script to build the analyzer 3 | 4 | import os, glob, platform 5 | 6 | ROOT = os.path.dirname(os.path.abspath(__file__)) 7 | OUTPUT_FOLDER = ROOT + '/out' 8 | RELEASE_FOLDER = OUTPUT_FOLDER + '/release' 9 | DEBUG_FOLDER = OUTPUT_FOLDER + '/debug' 10 | 11 | def build(): 12 | #find out if we're running on mac or linux and set the dynamic library extension 13 | if platform.system().lower() == "darwin": 14 | dylib_ext = ".dylib" 15 | else: 16 | dylib_ext = ".so" 17 | 18 | print("Running on " + platform.system()) 19 | 20 | #make sure the release folder exists, and clean out any .o/.so file if there are any 21 | if not os.path.exists(RELEASE_FOLDER): 22 | os.makedirs(RELEASE_FOLDER) 23 | 24 | os.chdir(RELEASE_FOLDER) 25 | o_files = glob.glob( "*.o" ) 26 | o_files.extend( glob.glob( "*" + dylib_ext ) ) 27 | for o_file in o_files: 28 | os.remove( o_file ) 29 | os.chdir(ROOT) 30 | 31 | 32 | #make sure the debug folder exists, and clean out any .o/.so files if there are any 33 | if not os.path.exists(DEBUG_FOLDER): 34 | os.makedirs(DEBUG_FOLDER) 35 | 36 | os.chdir(DEBUG_FOLDER) 37 | o_files = glob.glob( "*.o" ); 38 | o_files.extend( glob.glob( "*" + dylib_ext ) ) 39 | for o_file in o_files: 40 | os.remove( o_file ) 41 | os.chdir(ROOT) 42 | 43 | #find all the cpp files in /source. We'll compile all of them 44 | os.chdir( "source" ) 45 | cpp_files = glob.glob( "*.cpp" ); 46 | os.chdir(ROOT) 47 | 48 | #specify the search paths/dependencies/options for gcc 49 | include_paths = [ "./AnalyzerSDK/include" ] 50 | link_paths = [ "./AnalyzerSDK/lib" ] 51 | link_dependencies = [ "-lAnalyzer" ] #refers to libAnalyzer.dylib or libAnalyzer.so 52 | 53 | debug_compile_flags = "-O0 -w -c -fpic -g" 54 | release_compile_flags = "-O3 -w -c -fpic" 55 | 56 | def run_command(cmd): 57 | "Display cmd, then run it in a subshell, raise if there's an error" 58 | print(cmd) 59 | if os.system(cmd): 60 | raise Exception("Shell execution returned nonzero status") 61 | 62 | #loop through all the cpp files, build up the gcc command line, and attempt to compile each cpp file 63 | for cpp_file in cpp_files: 64 | 65 | #g++ 66 | command = "g++ " 67 | 68 | #include paths 69 | for path in include_paths: 70 | command += "-I\"" + path + "\" " 71 | 72 | release_command = command 73 | release_command += release_compile_flags 74 | release_command += f" -o\"{RELEASE_FOLDER}/" + cpp_file.replace( ".cpp", ".o" ) + "\" " #the output file 75 | release_command += "\"" + "source/" + cpp_file + "\"" #the cpp file to compile 76 | 77 | debug_command = command 78 | debug_command += debug_compile_flags 79 | debug_command += f" -o\"{DEBUG_FOLDER}/" + cpp_file.replace( ".cpp", ".o" ) + "\" " #the output file 80 | debug_command += "\"" + "source/" + cpp_file + "\"" #the cpp file to compile 81 | 82 | #run the commands from the command line 83 | run_command(release_command) 84 | run_command(debug_command) 85 | 86 | #lastly, link 87 | #g++ 88 | command = "g++ " 89 | 90 | #add the library search paths 91 | for link_path in link_paths: 92 | command += "-L\"" + link_path + "\" " 93 | 94 | #add libraries to link against 95 | for link_dependency in link_dependencies: 96 | command += link_dependency + " " 97 | 98 | #make a dynamic (shared) library (.so/.dylib) 99 | 100 | if dylib_ext == ".dylib": 101 | command += "-dynamiclib " 102 | else: 103 | command += "-shared " 104 | 105 | #figgure out what the name of this analyzer is 106 | analyzer_name = "" 107 | for cpp_file in cpp_files: 108 | if cpp_file.endswith( "Analyzer.cpp" ): 109 | analyzer_name = cpp_file.replace( "Analyzer.cpp", "" ) 110 | break 111 | 112 | #the files to create (.so/.dylib files) 113 | if dylib_ext == ".dylib": 114 | release_command = command + f"-o {RELEASE_FOLDER}/lib" + analyzer_name + "Analyzer.dylib " 115 | debug_command = command + f"-o {DEBUG_FOLDER}/lib" + analyzer_name + "Analyzer.dylib " 116 | else: 117 | release_command = command + f"-o\"{RELEASE_FOLDER}/lib" + analyzer_name + "Analyzer.so\" " 118 | debug_command = command + f"-o\"{DEBUG_FOLDER}/lib" + analyzer_name + "Analyzer.so\" " 119 | 120 | #add all the object files to link 121 | for cpp_file in cpp_files: 122 | release_command += RELEASE_FOLDER + "/" + cpp_file.replace( ".cpp", ".o" ) + " " 123 | debug_command += DEBUG_FOLDER + "/" + cpp_file.replace( ".cpp", ".o" ) + " " 124 | 125 | #run the commands from the command line 126 | run_command(release_command) 127 | run_command(debug_command) 128 | 129 | if __name__ == "__main__": 130 | build() 131 | -------------------------------------------------------------------------------- /docs/Analyzer SDK Setup.md: -------------------------------------------------------------------------------- 1 | # Setting up an Analyzer SDK Project 2 | 3 | This document details setting up your analyzer project for development on Windows, Mac, and Linux. 4 | 5 | Documentation for the Analyzer SDK code is still in the older Saleae Analyzer SDK.pdf. 6 | 7 | ## Initial Setup (All Platforms) 8 | 9 | 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. 10 | 11 | ## Visual Studio 12 | 13 | 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. 14 | 15 | To test your analyzer, you will need to tell the Saleae Logic software where to load find your compiled analyzer dll. 16 | 17 | The four build combinations produce analyzer dll files in the following locations: 18 | ``` 19 | .\Visual Studio\Win32\Debug\Analyzer.dll 20 | .\Visual Studio\Win32\Release\Analyzer.dll 21 | .\Visual Studio\x64\Debug\Analyzer.dll 22 | .\Visual Studio\x64\Release\Analyzer.dll 23 | ``` 24 | 25 | Instructions to tell the Saleae Logic software where to find your new analyzer dll can be found here: 26 | [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) 27 | 28 | Once you have set that directory and restarted the software, your new custom analyzer should appear in the list of analyzers you can add. 29 | 30 | ## Debugging an Analyzer with Visual Studio 31 | 32 | 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. 33 | 34 | *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.* 35 | 36 | To debug your custom analyzer, you will need to download the 32-bit standalone copy of our older, 1.1.18 software. 37 | 38 | http://downloads.saleae.com/betas/1.1.18/Logic1.1.18BetaWin32Standalone.zip 39 | 40 | This is a sandalone download and does not need to be installed. Just extract the zip file and run the contained Logic.exe. 41 | 42 | 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. 43 | 44 | To build and and debug your custom analyzer using the 1.1.14 software, follow these steps: 45 | 46 | - Using Visual Studio, open the solution file in the Visual Studio Folder. 47 | - Select the solution configuration "Debug-Legacy-1.1.14" 48 | - Select the platform "Win32" 49 | - Build the solution 50 | - 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. 51 | - The analyzer should now be visible in the list of analyzers you can add. 52 | - In visual studio, open the Debug Menu, and select "Attach to process..." 53 | - Locate Logic.exe in the list, select it, and click the Attach button. 54 | - Add a break point on any line near the top of the WorkerThread() function, such as line 27, mSampleRateHz = GetSampleRate(); 55 | - In the Logic software, add your custom analyzer if you haven't already, and start a simulation. 56 | - The breakpoint should hit 57 | 58 | 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. 59 | 60 | **Common issues on Windows** 61 | - The 'Options' button is missing. 62 | 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). 63 | - The software says "Unable to 'LoadLibrary' on dll ... is not a valid Win32 application" 64 | 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. 65 | 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. 66 | - The Saleae software crashes on launch when the debugger is attached. 67 | 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. 68 | 69 | ## Linux 70 | 71 | *Note: When using git clone, please remember to use --recursive to automatically also clone the AnalyzerSDK submodule* 72 | 73 | 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. 74 | 75 | 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. 76 | 77 | ``` 78 | mv AnalyzerSDK/lib/libAnalyzer64.so AnalyzerSDK/lib/libAnalyzer.so 79 | ``` 80 | 81 | Then run build_analyzer.py 82 | 83 | ``` 84 | python build_analyzer.py 85 | ``` 86 | 87 | That's it! To debug the analyzer, you need to first tell the Saleae Logic software where to find your newly compiled *.so file. 88 | 89 | [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) 90 | 91 | The two variants of the newly compiled analyzer can be found here: 92 | 93 | ``` 94 | debug/libAnalyzer.so 95 | release/libAnalyzer.so 96 | ``` 97 | 98 | ### Debugging with GDB on Linux 99 | 100 | To debug your analyzer, you will need to attach gdb to the Logic application, something like this: 101 | ``` 102 | gdb /Home/YourUserName/Desktop/Logic 1.2.14 (64-bit)/Logic 103 | ``` 104 | And then test setting a breakpoint like this: 105 | ``` 106 | break MyAnalyzer::WorkerThread 107 | ``` 108 | 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 109 | 110 | Then type run to start the application. Add your custom analyzer and start a simulation. This will trigger the breakpoint. 111 | 112 | ## MacOS 113 | 114 | ### Build Script Based Project 115 | 116 | *Note: When using git clone, please remember to use --recursive to automatically also clone the AnalyzerSDK submodule* 117 | 118 | 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. 119 | 120 | run build_analyzer.py 121 | 122 | ``` 123 | python build_analyzer.py 124 | ``` 125 | 126 | That's it! To debug the analyzer, you need to first tell the Saleae Logic software where to find your newly compiled *.dylib file. 127 | 128 | [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) 129 | 130 | ``` 131 | debug/libAnalyzer.dylib 132 | release/libAnalyzer.dylib 133 | ``` 134 | 135 | ### Debugging with GDB on MacOS 136 | 137 | To debug your analyzer, you will need to attach gdb to the Logic application, something like this: 138 | ``` 139 | gdb /Applications/Logic.app/Contents/MacOS/Logic 140 | ``` 141 | And then test setting a breakpoint like this: 142 | ``` 143 | break MyAnalyzer::WorkerThread 144 | ``` 145 | 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 146 | 147 | Then type run to start the application. Add your custom analyzer and start a simulation. This will trigger the breakpoint. 148 | 149 | 150 | 151 | ### XCode Based Project 152 | 153 | **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.** 154 | 155 | 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. 156 | 157 | - Start Xcode 158 | - Click "Create a new Xcode project" 159 | 160 | ![1](./images/1_-_new_project.png) 161 | 162 | - select "Other" from the left column, and "Empty" from the templates list. 163 | - Click next. 164 | 165 | ![2](./images/2_-_empty_project.png) 166 | 167 | - Enter a name for your Xcode Project. 168 | 169 | ![2.5](./images/2_5_analyzer_name.png) 170 | 171 | - 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. 172 | - Click "Create" 173 | 174 | ![2.75](./images/2_75_-_project_location.png) 175 | 176 | - 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" 177 | 178 | ![3](./images/3_-_copy_files.png) 179 | 180 | - Open a terminal, and browse to the new project folder in the downloaded SDK folder. 181 | - Run the python script with: 182 | 183 | python rename_analyzer.py 184 | 185 | - 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" 186 | - 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. 187 | 188 | ![4](./images/4_-_rename_analyzer_script.png) 189 | 190 | - 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. 191 | 192 | ![5](./images/5_-_add_target_button.png) 193 | 194 | - This is the target menu. 195 | 196 | ![6](./images/6_-_add_target_menu.png) 197 | 198 | - Select "Framework & Library" under "OS X" in the left column, and select "Library" in the main area. 199 | - Click Next. 200 | 201 | ![7](./images/7_-_library_target.png) 202 | 203 | - Enter a product name, we recommend the the same name as the project, since there will only be one product. 204 | - Under framework, select "None (Plain C/C++ Library) 205 | - For Type, select "Dynamic" 206 | 207 | ![8](./images/8_-_library_settings.png) 208 | 209 | - Next, we need to add the source files. Click File -> Add Files to ""... 210 | - Note: if this is disabled, it is because you do not have the project selected in the Project Navigator. 211 | 212 | ![8.5](./images/8_5_-_add_files_menu.png) 213 | 214 | - 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. 215 | - select "Create groups" in the "added folders" section. 216 | - Click Add. 217 | 218 | ![9](./images/9_-_add_files.png) 219 | 220 | - Verify that the files were automatically added to the build phases "Compile Sources" and "Headers". 221 | - Select the project from the Project Navigator if not already selected. 222 | - Click "Build Phases". 223 | - Expand "Compile Sources" and "Headers" 224 | - Under "Headers", also expand "Project". 225 | - Verify that each has 4 files. 226 | 227 | ![9.5](./images/9_5_-_verify_sources_added.png) 228 | 229 | - Click "Build Settings" 230 | - If "Levels" is selected, switch it to "Combined" 231 | 232 | ![10](./images/10_-_build_settings_page.png) 233 | 234 | - Expand the section "Search Paths" 235 | - Locate "Header Search Paths" and edit the value. 236 | - Click the "+" button and enter "../include" in the new entry. 237 | 238 | ![11](./images/11_-_header_includes_search_path.png) 239 | 240 | - Locate "Library Search Paths" in the same section, and edit its value. 241 | - Click the "+" button and enter "../lib" in the new entry. 242 | 243 | ![11.5](./images/11_5_-_add_library_path.png) 244 | 245 | - Return to "Build Phases" and expand the section "Link Binary with Libraries" 246 | - Click the "+" button 247 | 248 | ![12](./images/12_-_add_library_part_1.png) 249 | 250 | - Click "Add Other..." 251 | 252 | ![13](./images/13_-_add_library_part_2.png) 253 | 254 | - Browse to the original SDK folder which contains our Xcode folder. 255 | - Open the "lib" folder 256 | - Select "libAnalyzer.dylib" 257 | - Click Open. 258 | 259 | ![14](./images/14_-_add_library_part_3.png) 260 | 261 | 262 | - At this point, you should build the project, so that the resulting library will be created. 263 | - 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: 264 | 265 | ~/Library/Developer/Xcode/DerivedData 266 | 267 | - You may want to change it. **The following steps are optional** 268 | 269 | **Optional: change build output folder** 270 | 271 | - Optional step 1: From the file menu, select "Project Settings..." 272 | 273 | ![optional 1](./images/optional_-_project_settings_-_edit_products_folder_menu.png) 274 | 275 | - Optional step 2: in the "Derived Data" dropdown, select "Project-relative Location" 276 | - Click "Done" 277 | 278 | ![optional 2](./images/optional_-_Project_Settings.png) 279 | 280 | - That's it for the optional steps. 281 | 282 | ### Running and Debugging your Analyzer 283 | 284 | - Next we will setup debugging for the project. Be sure to have the latest Saleae Logic Software installed. 285 | - On the Product menu at the top of the screen, select "Scheme" -> "Edit Scheme..." 286 | ![15](./images/15_-_edit_scheme.png) 287 | 288 | - Make sure "Run" is selected on the left. 289 | - Under "Executable" select "Other..." 290 | ![16](./images/16_-_debug_launch_app_menu.png) 291 | 292 | - Browse to the "Applications" folder (or wherever Logic is installed) and select "Logic.app" 293 | - Click Choose. 294 | 295 | ![17](./images/17_-_select_debug_program.png) 296 | 297 | 298 | - Set a breakpoint in the software so that we can test debugging. 299 | - 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". 300 | - 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. 301 | 302 | 303 | 304 | ![18](./images/18_-_breakpoint_set.png) 305 | 306 | - 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 307 | - Be sure to select the folder where the debug version of the custom analyzer is is saved. 308 | 309 | - Once the Saleae logic software has been configured, and has been closed, click run from Xcode. 310 | - 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. 311 | - 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. 312 | - The settings dialog for your custom analyzer will appear. Click "Save". 313 | 314 | ![19](./images/19_-_logic_software_add_analyzer_menu.png) 315 | 316 | - 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. 317 | 318 | ![20](./images/20_-_analyzer_in_Logic.png) 319 | 320 | - Press start to start a simulation. 321 | - 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. 322 | 323 | ![21](./images/21_-_logic_software_start_button.png) 324 | 325 | - 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. 326 | 327 | ![22](./images/22_-_breakpoint_hit.png) 328 | 329 | - Congratulations! You now have an Xcode project for which you can use to develop a custom analyzer for the Saleae software. 330 | 331 | If you have any questions, please contact support. 332 | -------------------------------------------------------------------------------- /docs/Saleae Analyzer SDK (older).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/Saleae Analyzer SDK (older).pdf -------------------------------------------------------------------------------- /docs/images/10_-_build_settings_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/10_-_build_settings_page.png -------------------------------------------------------------------------------- /docs/images/11_-_header_includes_search_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/11_-_header_includes_search_path.png -------------------------------------------------------------------------------- /docs/images/11_5_-_add_library_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/11_5_-_add_library_path.png -------------------------------------------------------------------------------- /docs/images/12_-_add_library_part_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/12_-_add_library_part_1.png -------------------------------------------------------------------------------- /docs/images/13_-_add_library_part_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/13_-_add_library_part_2.png -------------------------------------------------------------------------------- /docs/images/14_-_add_library_part_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/14_-_add_library_part_3.png -------------------------------------------------------------------------------- /docs/images/15_-_edit_scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/15_-_edit_scheme.png -------------------------------------------------------------------------------- /docs/images/16_-_debug_launch_app_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/16_-_debug_launch_app_menu.png -------------------------------------------------------------------------------- /docs/images/17_-_select_debug_program.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/17_-_select_debug_program.png -------------------------------------------------------------------------------- /docs/images/18_-_breakpoint_set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/18_-_breakpoint_set.png -------------------------------------------------------------------------------- /docs/images/19_-_logic_software_add_analyzer_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/19_-_logic_software_add_analyzer_menu.png -------------------------------------------------------------------------------- /docs/images/1_-_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/1_-_new_project.png -------------------------------------------------------------------------------- /docs/images/20_-_analyzer_in_Logic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/20_-_analyzer_in_Logic.png -------------------------------------------------------------------------------- /docs/images/21_-_logic_software_start_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/21_-_logic_software_start_button.png -------------------------------------------------------------------------------- /docs/images/22_-_breakpoint_hit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/22_-_breakpoint_hit.png -------------------------------------------------------------------------------- /docs/images/2_-_empty_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/2_-_empty_project.png -------------------------------------------------------------------------------- /docs/images/2_5_analyzer_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/2_5_analyzer_name.png -------------------------------------------------------------------------------- /docs/images/2_75_-_project_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/2_75_-_project_location.png -------------------------------------------------------------------------------- /docs/images/3_-_copy_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/3_-_copy_files.png -------------------------------------------------------------------------------- /docs/images/4_-_rename_analyzer_script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/4_-_rename_analyzer_script.png -------------------------------------------------------------------------------- /docs/images/5_-_add_target_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/5_-_add_target_button.png -------------------------------------------------------------------------------- /docs/images/6_-_add_target_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/6_-_add_target_menu.png -------------------------------------------------------------------------------- /docs/images/7_-_library_target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/7_-_library_target.png -------------------------------------------------------------------------------- /docs/images/8_-_library_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/8_-_library_settings.png -------------------------------------------------------------------------------- /docs/images/8_5_-_add_files_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/8_5_-_add_files_menu.png -------------------------------------------------------------------------------- /docs/images/9_-_add_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/9_-_add_files.png -------------------------------------------------------------------------------- /docs/images/9_5_-_verify_sources_added.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/9_5_-_verify_sources_added.png -------------------------------------------------------------------------------- /docs/images/optional_-_Project_Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/optional_-_Project_Settings.png -------------------------------------------------------------------------------- /docs/images/optional_-_project_settings_-_edit_products_folder_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robbederks/FlexRayAnalyzer/75b66d7e6ae6906ed879d23add79a3d68422758f/docs/images/optional_-_project_settings_-_edit_products_folder_menu.png -------------------------------------------------------------------------------- /rename_analyzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import glob 4 | import sys 5 | 6 | # Fix Python 2.x. 7 | try: 8 | input = raw_input 9 | except NameError: pass 10 | 11 | print("") 12 | print("") 13 | print("What would you like to call your new analyzer?") 14 | print("") 15 | print(">>The files under '/source' will be modified to use it.") 16 | print(">>Examples include Serial, MySerial, JoesSerial, Gamecube, Wiimote, 2Wire, etc.") 17 | print(">>Do not inclide the trailing word 'Analyzer' this will be added automaticly.") 18 | print("") 19 | print("(press CTRL-C to cancel)") 20 | print("") 21 | 22 | new_analyzer_name = input( "Your new analyzer name: " ) 23 | 24 | print("") 25 | print("") 26 | print("What is the analyzer's title? (as shown in the add new anlayzer drop down)") 27 | print("") 28 | print(">>Examples include Async Serial, I2C, Joe's Serial, Gamecube, Wiimote, 2Wire, etc.") 29 | print("") 30 | print("(press CTRL-C to cancel)") 31 | print("") 32 | 33 | new_analyzer_title = input( "Your new analyzer's title: " ) 34 | 35 | original_name = "SimpleSerial" 36 | 37 | 38 | vs_project_path = "Visual Studio" 39 | os.chdir( vs_project_path ) 40 | 41 | project_files = glob.glob("*.sln") + glob.glob("*.vcxproj") #returns only the file names, no paths. 42 | 43 | for file in project_files: 44 | contents = open( file, 'r' ).read() 45 | contents = contents.replace( original_name + "Analyzer", new_analyzer_name + "Analyzer" ) 46 | contents = contents.replace( original_name.upper() + "ANALYZER", new_analyzer_name.upper() + "ANALYZER" ) 47 | contents = contents.replace( original_name + "SimulationDataGenerator", new_analyzer_name + "SimulationDataGenerator" ) 48 | open( file, 'w' ).write( contents ) 49 | 50 | os.rename( glob.glob("*.sln")[0], new_analyzer_name + "Analyzer.sln" ) 51 | os.rename( glob.glob("*.vcxproj")[0], new_analyzer_name + "Analyzer.vcxproj" ) 52 | 53 | source_path = "source" 54 | os.chdir( ".." ) 55 | os.chdir( source_path ) 56 | 57 | files = dict() 58 | 59 | cpp_files = glob.glob( "*.cpp" ); 60 | h_files = glob.glob( "*.h" ); 61 | 62 | for file in cpp_files: 63 | files[file] = ".cpp" 64 | 65 | for file in h_files: 66 | files[ file ] = ".h" 67 | 68 | new_files = [] 69 | 70 | for file, extension in files.items(): 71 | name_root = file.replace( original_name, "" ) 72 | new_name = new_analyzer_name + name_root 73 | #print "renaming file " + file + " to " + new_name 74 | os.rename( file, new_name ) 75 | new_files.append( new_name ) 76 | 77 | for file in new_files: 78 | contents = open( file, 'r' ).read() 79 | contents = contents.replace( original_name + "Analyzer", new_analyzer_name + "Analyzer" ) 80 | contents = contents.replace( original_name.upper() + "_ANALYZER_", new_analyzer_name.upper() + "_ANALYZER_" ) 81 | contents = contents.replace( original_name.upper() + "_SIMULATION_DATA_GENERATOR", new_analyzer_name.upper() + "_SIMULATION_DATA_GENERATOR" ) 82 | contents = contents.replace( original_name + "SimulationDataGenerator", new_analyzer_name + "SimulationDataGenerator" ) 83 | contents = contents.replace( "Simple Serial", new_analyzer_title ) 84 | open( file, 'w' ).write( contents ) 85 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | saleae -------------------------------------------------------------------------------- /source/FlexRayAnalyzer.cpp: -------------------------------------------------------------------------------- 1 | #include "FlexRayAnalyzer.h" 2 | 3 | FlexRayAnalyzer::FlexRayAnalyzer() : Analyzer2() { 4 | mSettings = std::auto_ptr(new FlexRayAnalyzerSettings()); 5 | mSimulationInitialized = false; 6 | mFrameBuffer = std::vector(); 7 | SetAnalyzerSettings(mSettings.get()); 8 | } 9 | 10 | FlexRayAnalyzer::~FlexRayAnalyzer() { 11 | KillThread(); 12 | } 13 | 14 | void FlexRayAnalyzer::SetupResults() { 15 | mResults.reset(new FlexRayAnalyzerResults(this, mSettings.get())); 16 | SetAnalyzerResults(mResults.get()); 17 | mResults->AddChannelBubblesWillAppearOn(mSettings->mInputChannel); 18 | } 19 | 20 | void FlexRayAnalyzer::WorkerThread() { 21 | InitAnalyzer(); 22 | 23 | // Keep analysing as long as we are not killed 24 | U64 starting_sample = mFlexRay->GetSampleNumber(); 25 | std::vector bits = std::vector(); 26 | while(true){ 27 | // Remove all bits 28 | bits.clear(); 29 | 30 | // Jump to next frame start 31 | WaitForNextFrame(); 32 | 33 | // Shift half a bit to sample mid-bit 34 | U64 mSamplesPerHalfBit = mSamplesPerBit / 2; 35 | mFlexRay->Advance(mSamplesPerHalfBit); 36 | 37 | // Skip the TSS 38 | //starting_sample = mFlexRay->GetSampleNumber(); 39 | //while(SampleBit() == false){} 40 | //AddResultFrame(TSSField, starting_sample - mSamplesPerHalfBit, mFlexRay->GetSampleNumber() - mSamplesPerBit - mSamplesPerHalfBit); 41 | 42 | // Skip the FSS 43 | SampleBit(); 44 | starting_sample = mFlexRay->GetSampleNumber() - mSamplesPerBit; 45 | AddResultFrame(FSSField, starting_sample - mSamplesPerHalfBit, mFlexRay->GetSampleNumber() - mSamplesPerHalfBit); 46 | 47 | // Start sampling the bits until we reach the end of the frame 48 | while(true){ 49 | // Read BSS 50 | starting_sample = mFlexRay->GetSampleNumber(); 51 | if(SampleBit(true) != true || SampleBit(true) != false){ 52 | // This byte is wrong! 53 | break; 54 | } 55 | // Don't add the BSS as frame anymore, since this interferes with overlapping data :/ 56 | // AddResultFrame(BSSField, starting_sample - mSamplesPerHalfBit, mFlexRay->GetSampleNumber() - mSamplesPerHalfBit); 57 | 58 | // Read 8 bits to byte 59 | for(int i=7; i>=0; i--){ 60 | DecoderBit bit; 61 | bit.start_sample = mFlexRay->GetSampleNumber() - mSamplesPerHalfBit; 62 | bit.bit = SampleBit(); 63 | bit.end_sample = mFlexRay->GetSampleNumber() - mSamplesPerHalfBit; 64 | bits.push_back(bit); 65 | } 66 | } 67 | // Decode frame 68 | FlexRayFrame f = FlexRayFrame(); 69 | f.Decode(bits, &mFrameBuffer); 70 | 71 | // Commit sorted frames to screen 72 | CommitFrames(); 73 | 74 | // Commit packet 75 | mResults->CommitPacketAndStartNewPacket(); 76 | 77 | // Report decoding progress 78 | ReportProgress(mFlexRay->GetSampleNumber()); 79 | } 80 | } 81 | 82 | void FlexRayAnalyzer::AddResultFrame(FlexRayFrameType type, S64 start_sample, S64 end_sample, U64 data1, U64 data2){ 83 | Frame frame; 84 | frame.mType = type; 85 | frame.mData1 = data1; 86 | frame.mData2 = data2; 87 | frame.mFlags = 0; 88 | frame.mStartingSampleInclusive = start_sample; 89 | frame.mEndingSampleInclusive = end_sample; 90 | 91 | FrameSortingWrapper fsw; 92 | fsw.f = frame; 93 | 94 | mFrameBuffer.push_back(fsw); 95 | } 96 | 97 | void FlexRayAnalyzer::CommitFrames(){ 98 | std::sort(mFrameBuffer.begin(), mFrameBuffer.end()); 99 | for(int i=0; iAddFrame(mFrameBuffer.at(i).f); 101 | mFrameBuffer.clear(); 102 | mResults->CommitResults(); 103 | } 104 | 105 | void FlexRayAnalyzer::InitAnalyzer(){ 106 | mSampleRateHz = GetSampleRate(); 107 | mSamplesPerBit = mSampleRateHz / mSettings->mBitRate; 108 | printf("Samples per bit: %d\n", mSamplesPerBit); 109 | mFlexRay = GetAnalyzerChannelData(mSettings->mInputChannel); 110 | } 111 | 112 | bool FlexRayAnalyzer::SampleBit(bool useless){ 113 | // Get bit 114 | bool result = (mFlexRay->GetBitState() == mSettings->Recessive()); 115 | 116 | // Put dot where sampled 117 | mResults->AddMarker(mFlexRay->GetSampleNumber(), useless ? AnalyzerResults::ErrorX : AnalyzerResults::Dot, mSettings->mInputChannel); 118 | 119 | // Advance to next bit 120 | mFlexRay->Advance(mSamplesPerBit); 121 | return result; 122 | } 123 | 124 | void FlexRayAnalyzer::WaitForNextFrame() { 125 | // Go to a recessive bit 126 | if(mFlexRay->GetBitState() == mSettings->Dominant()) 127 | mFlexRay->AdvanceToNextEdge(); 128 | 129 | // Find a TSS and sync off the last edge (e.g. the FSS) 130 | while(mFlexRay->WouldAdvancingCauseTransition(MIN_IDLE_LEN * mSamplesPerBit)){ 131 | // Skip that bit 132 | mFlexRay->AdvanceToNextEdge(); 133 | mFlexRay->AdvanceToNextEdge(); 134 | //printf("Advancing to %d\n", mFlexRay->GetSampleNumber()); 135 | } 136 | mFlexRay->AdvanceToNextEdge(); 137 | mFlexRay->AdvanceToNextEdge(); 138 | } 139 | 140 | bool FlexRayAnalyzer::NeedsRerun() { 141 | return false; 142 | } 143 | 144 | U32 FlexRayAnalyzer::GenerateSimulationData(U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels) { 145 | if (mSimulationInitialized == false) { 146 | mSimulationDataGenerator.Initialize(GetSimulationSampleRate(), mSettings.get()); 147 | mSimulationInitialized = true; 148 | } 149 | 150 | return mSimulationDataGenerator.GenerateSimulationData(minimum_sample_index, device_sample_rate, simulation_channels); 151 | } 152 | 153 | U32 FlexRayAnalyzer::GetMinimumSampleRateHz() { 154 | return mSettings->mBitRate * 4; 155 | } 156 | 157 | const char* FlexRayAnalyzer::GetAnalyzerName() const { 158 | return "FlexRay"; 159 | } 160 | 161 | const char* GetAnalyzerName() { 162 | return "FlexRay"; 163 | } 164 | 165 | Analyzer* CreateAnalyzer() { 166 | return new FlexRayAnalyzer(); 167 | } 168 | 169 | void DestroyAnalyzer(Analyzer* analyzer) { 170 | delete analyzer; 171 | } -------------------------------------------------------------------------------- /source/FlexRayAnalyzer.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_ANALYZER_H 2 | #define FLEXRAY_ANALYZER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "FlexRayAnalyzerResults.h" 9 | #include "FlexRaySimulationDataGenerator.h" 10 | #include "Helpers.h" 11 | #include "FlexRayFrame.h" 12 | #include "FlexRayParameters.h" 13 | 14 | class FlexRayAnalyzerResults; 15 | class FlexRayAnalyzerSettings; 16 | class ANALYZER_EXPORT FlexRayAnalyzer : public Analyzer2 { 17 | public: 18 | FlexRayAnalyzer(); 19 | virtual ~FlexRayAnalyzer(); 20 | 21 | virtual void SetupResults(); 22 | virtual void WorkerThread(); 23 | 24 | virtual U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels); 25 | virtual U32 GetMinimumSampleRateHz(); 26 | 27 | virtual const char* GetAnalyzerName() const; 28 | virtual bool NeedsRerun(); 29 | 30 | void AddResultFrame(FlexRayFrameType type, S64 start_sample, S64 end_sample, U64 data1=0, U64 data2=0); 31 | 32 | protected: // Variables 33 | std::auto_ptr mSettings; 34 | std::auto_ptr mResults; 35 | AnalyzerChannelData* mFlexRay; 36 | 37 | FlexRaySimulationDataGenerator mSimulationDataGenerator; 38 | bool mSimulationInitialized; 39 | 40 | protected: // Analysis functions 41 | void WaitForNextFrame(); 42 | void InitAnalyzer(); 43 | bool SampleBit(bool useless = false); 44 | void CommitFrames(); 45 | 46 | protected: // Analysis variables 47 | U32 mSampleRateHz; 48 | U32 mSamplesPerBit; 49 | std::vector mFrameBuffer; 50 | }; 51 | 52 | extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName(); 53 | extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer(); 54 | extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer(Analyzer* analyzer); 55 | 56 | #endif //FLEXRAY_ANALYZER_H 57 | -------------------------------------------------------------------------------- /source/FlexRayAnalyzerResults.cpp: -------------------------------------------------------------------------------- 1 | #include "FlexRayAnalyzerResults.h" 2 | 3 | FlexRayAnalyzerResults::FlexRayAnalyzerResults(FlexRayAnalyzer* analyzer, FlexRayAnalyzerSettings* settings) : AnalyzerResults() { 4 | mSettings = settings; 5 | mAnalyzer = analyzer; 6 | } 7 | 8 | FlexRayAnalyzerResults::~FlexRayAnalyzerResults() { 9 | } 10 | 11 | void FlexRayAnalyzerResults::GenerateBubbleText(U64 frame_index, Channel& channel, DisplayBase display_base) { 12 | ClearResultStrings(); 13 | Frame frame = GetFrame(frame_index); 14 | char tmp_str[128]; 15 | 16 | switch (frame.mType) { 17 | case TSSField: 18 | // Short 19 | AddResultString("TSS"); 20 | 21 | // Long 22 | AddResultString("Transmission Start Sequence"); 23 | break; 24 | 25 | case BSSField: 26 | // Short 27 | AddResultString("BSS"); 28 | 29 | // Long 30 | AddResultString("Byte Start Sequence"); 31 | break; 32 | 33 | case FSSField: 34 | // Short 35 | AddResultString("FSS"); 36 | 37 | // Long 38 | AddResultString("Frame Start Sequence"); 39 | break; 40 | 41 | case FESField: 42 | // Short 43 | AddResultString("FES"); 44 | 45 | // Long 46 | AddResultString("Frame End Sequence"); 47 | break; 48 | 49 | case FlagsField: 50 | // Short 51 | AddResultString("Fl"); 52 | 53 | // Medium 54 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 5, tmp_str, 128); 55 | AddResultString("Fl.: ", tmp_str); 56 | 57 | // Long 58 | AddResultString("Flags: ", tmp_str); 59 | 60 | // Extra long 61 | sprintf( 62 | tmp_str, 63 | "Reserved: %d Payload Preamble: %d Null frame: %d Sync frame: %d Startup frame: %d", 64 | (frame.mData1 & (1 << 4) != 0), 65 | (frame.mData1 & (1 << 3) != 0), 66 | (frame.mData1 & (1 << 2) != 0), 67 | (frame.mData1 & (1 << 1) != 0), 68 | (frame.mData1 & (1 << 0) != 0)); 69 | AddResultString(tmp_str); 70 | break; 71 | 72 | case FrameIdField: 73 | // Short 74 | AddResultString("FID"); 75 | 76 | // Medium 77 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 11, tmp_str, 128); 78 | AddResultString("FID.: ", tmp_str); 79 | 80 | // Long 81 | AddResultString("Frame ID: ", tmp_str); 82 | break; 83 | 84 | case PayloadLengthField: 85 | // Short 86 | AddResultString("PL"); 87 | 88 | // Medium 89 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 7, tmp_str, 128); 90 | AddResultString("P.L.: ", tmp_str); 91 | 92 | // Long 93 | AddResultString("Payload Length: ", tmp_str); 94 | break; 95 | 96 | case HeaderCRCField: 97 | // Short 98 | AddResultString("H.CRC"); 99 | 100 | // Medium 101 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 11, tmp_str, 128); 102 | AddResultString("H.CRC: ", tmp_str); 103 | 104 | // Long 105 | AddResultString("Header CRC: ", tmp_str); 106 | break; 107 | 108 | case CycleCountField: 109 | // Short 110 | AddResultString("C.CNT"); 111 | 112 | // Medium 113 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 6, tmp_str, 128); 114 | AddResultString("C.CNT: ", tmp_str); 115 | 116 | // Long 117 | AddResultString("Cycle Count: ", tmp_str); 118 | break; 119 | 120 | case DataField: 121 | // Short 122 | AddResultString("D"); 123 | 124 | // Medium Short 125 | char index_str[10]; 126 | sprintf(index_str, "%d", frame.mData2); 127 | AddResultString("D", index_str); 128 | 129 | // Medium 130 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 6, tmp_str, 128); 131 | AddResultString("D", index_str, ": ", tmp_str); 132 | 133 | // Long 134 | AddResultString("Data ", index_str, ": ", tmp_str); 135 | break; 136 | 137 | case CRCField: 138 | // Short 139 | AddResultString("CRC"); 140 | 141 | // Medium 142 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 24, tmp_str, 128); 143 | AddResultString("CRC: ", tmp_str); 144 | 145 | // Long 146 | AddResultString("Frame CRC: ", tmp_str); 147 | break; 148 | 149 | default: 150 | break; 151 | } 152 | 153 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 8, tmp_str, 128); 154 | AddResultString(tmp_str); 155 | } 156 | 157 | void FlexRayAnalyzerResults::GenerateExportFile(const char* file, DisplayBase display_base, U32 export_type_user_id) { 158 | std::stringstream ss; 159 | void* result_file = AnalyzerHelpers::StartFile(file); 160 | 161 | U64 trigger_sample = mAnalyzer->GetTriggerSample(); 162 | U32 sample_rate = mAnalyzer->GetSampleRate(); 163 | 164 | // CSV header 165 | ss << "Time [s],Flags,FrameId,PayloadLength,HeaderCRC,CycleCount,Data,CRC" << std::endl; 166 | 167 | U64 num_frames = GetNumFrames(); 168 | U64 num_packets = GetNumPackets(); 169 | for (U32 i = 0; i < num_packets; i++) { 170 | U64 first_frame_id; 171 | U64 last_frame_id; 172 | GetFramesContainedInPacket(i, &first_frame_id, &last_frame_id); 173 | 174 | // Loop over frames to extract data. Sigh... 175 | FlexRayFrame f; 176 | f.data = std::vector(256, 0); 177 | 178 | U8 flags; 179 | U8 payload_length; 180 | for (U64 frame_id = first_frame_id; frame_id <= last_frame_id; frame_id++) { 181 | Frame frame = GetFrame(frame_id); 182 | switch (frame.mType) { 183 | case TSSField: 184 | break; 185 | case BSSField: 186 | break; 187 | case FSSField: 188 | break; 189 | case FESField: 190 | break; 191 | case FlagsField: 192 | // Useless to split this up and combine it again 193 | flags = frame.mData1; 194 | break; 195 | case FrameIdField: 196 | f.frame_id = frame.mData1; 197 | break; 198 | case PayloadLengthField: 199 | payload_length = frame.mData1; 200 | break; 201 | case HeaderCRCField: 202 | f.header_crc = frame.mData1; 203 | break; 204 | case CycleCountField: 205 | f.cycle_count = frame.mData1; 206 | break; 207 | case DataField: 208 | f.data.at(frame.mData2) = frame.mData1; 209 | break; 210 | case CRCField: 211 | f.crc = frame.mData1; 212 | break; 213 | default: 214 | break; 215 | } 216 | } 217 | 218 | char temp_str[128]; 219 | 220 | // Time 221 | AnalyzerHelpers::GetTimeString(GetFrame(first_frame_id).mStartingSampleInclusive, trigger_sample, sample_rate, temp_str, 128); 222 | ss << temp_str << ','; 223 | 224 | // Flags 225 | AnalyzerHelpers::GetNumberString(flags, Decimal, 0, temp_str, 128); 226 | ss << temp_str << ','; 227 | 228 | // FrameId 229 | AnalyzerHelpers::GetNumberString(f.frame_id, Decimal, 0, temp_str, 128); 230 | ss << temp_str << ','; 231 | 232 | // PayloadLength 233 | AnalyzerHelpers::GetNumberString(payload_length, Decimal, 0, temp_str, 128); 234 | ss << temp_str << ','; 235 | 236 | // HeaderCRC 237 | AnalyzerHelpers::GetNumberString(f.header_crc, Decimal, 0, temp_str, 128); 238 | ss << temp_str << ','; 239 | 240 | // CycleCount 241 | AnalyzerHelpers::GetNumberString(f.cycle_count, Decimal, 0, temp_str, 128); 242 | ss << temp_str << ','; 243 | 244 | // Data 245 | for (int j = 0; j < (payload_length * 2); j++) { 246 | AnalyzerHelpers::GetNumberString(f.data.at(j), Decimal, 0, temp_str, 128); 247 | ss << temp_str; 248 | if (j != ((payload_length * 2) - 1)) 249 | ss << '|'; 250 | } 251 | ss << ","; 252 | 253 | // CRC 254 | AnalyzerHelpers::GetNumberString(f.crc, Decimal, 0, temp_str, 128); 255 | ss << temp_str << std::endl; 256 | 257 | // Append string to file 258 | AnalyzerHelpers::AppendToFile((U8*)ss.str().c_str(), ss.str().length(), result_file); 259 | ss.str(std::string()); 260 | 261 | // Check if we want to cancel 262 | if (UpdateExportProgressAndCheckForCancel(i, num_packets) == true) { 263 | AnalyzerHelpers::EndFile(result_file); 264 | return; 265 | } 266 | } 267 | 268 | UpdateExportProgressAndCheckForCancel(num_frames, num_frames); 269 | AnalyzerHelpers::EndFile(result_file); 270 | } 271 | 272 | void FlexRayAnalyzerResults::GenerateFrameTabularText(U64 frame_index, DisplayBase display_base) { 273 | #ifdef SUPPORTS_PROTOCOL_SEARCH 274 | Frame frame = GetFrame(frame_index); 275 | ClearTabularText(); 276 | 277 | char tmp_str[128]; 278 | AnalyzerHelpers::GetNumberString(frame.mData1, display_base, 8, tmp_str, 128); 279 | AddTabularText(tmp_str); 280 | #endif 281 | } 282 | 283 | void FlexRayAnalyzerResults::GeneratePacketTabularText(U64 packet_id, DisplayBase display_base) { 284 | //not supported 285 | } 286 | 287 | void FlexRayAnalyzerResults::GenerateTransactionTabularText(U64 transaction_id, DisplayBase display_base) { 288 | //not supported 289 | } -------------------------------------------------------------------------------- /source/FlexRayAnalyzerResults.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_ANALYZER_RESULTS 2 | #define FLEXRAY_ANALYZER_RESULTS 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum FlexRayFrameType { TSSField, 9 | BSSField, 10 | FSSField, 11 | FESField, 12 | FlagsField, 13 | FrameIdField, 14 | PayloadLengthField, 15 | HeaderCRCField, 16 | CycleCountField, 17 | DataField, 18 | CRCField }; 19 | 20 | #include 21 | #include "FlexRayAnalyzer.h" 22 | #include "FlexRayAnalyzerSettings.h" 23 | 24 | class FlexRayAnalyzer; 25 | 26 | class FlexRayAnalyzerResults : public AnalyzerResults { 27 | public: 28 | FlexRayAnalyzerResults(FlexRayAnalyzer* analyzer, FlexRayAnalyzerSettings* settings); 29 | virtual ~FlexRayAnalyzerResults(); 30 | 31 | virtual void GenerateBubbleText(U64 frame_index, Channel& channel, DisplayBase display_base); 32 | virtual void GenerateExportFile(const char* file, DisplayBase display_base, U32 export_type_user_id); 33 | 34 | virtual void GenerateFrameTabularText(U64 frame_index, DisplayBase display_base); 35 | virtual void GeneratePacketTabularText(U64 packet_id, DisplayBase display_base); 36 | virtual void GenerateTransactionTabularText(U64 transaction_id, DisplayBase display_base); 37 | 38 | protected: //functions 39 | protected: //vars 40 | FlexRayAnalyzerSettings* mSettings; 41 | FlexRayAnalyzer* mAnalyzer; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /source/FlexRayAnalyzerSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "FlexRayAnalyzerSettings.h" 2 | 3 | FlexRayAnalyzerSettings::FlexRayAnalyzerSettings() { 4 | mInputChannel = UNDEFINED_CHANNEL; 5 | mBitRate = 10000000; 6 | mInverted = false; 7 | 8 | mInputChannelInterface.reset(new AnalyzerSettingInterfaceChannel()); 9 | mInputChannelInterface->SetTitleAndTooltip("RX", "RX channel on FlexRay transciever"); 10 | mInputChannelInterface->SetChannel(mInputChannel); 11 | 12 | mBitRateInterface.reset(new AnalyzerSettingInterfaceInteger()); 13 | mBitRateInterface->SetTitleAndTooltip("Bit Rate (Bits/S)", "Specify the bit rate in bits per second."); 14 | mBitRateInterface->SetMax(10000000); 15 | mBitRateInterface->SetMin(1); 16 | mBitRateInterface->SetInteger(mBitRate); 17 | 18 | mInvertedInterface.reset(new AnalyzerSettingInterfaceBool()); 19 | mInvertedInterface->SetTitleAndTooltip("", "Invert the captured bits"); 20 | mInvertedInterface->SetCheckBoxText("Inverted"); 21 | mInvertedInterface->SetValue(mInverted); 22 | 23 | AddInterface(mInputChannelInterface.get()); 24 | AddInterface(mBitRateInterface.get()); 25 | AddInterface(mInvertedInterface.get()); 26 | 27 | AddExportOption(0, "Export as text/csv file"); 28 | AddExportExtension(0, "text", "txt"); 29 | AddExportExtension(0, "csv", "csv"); 30 | 31 | ClearChannels(); 32 | AddChannel(mInputChannel, "RX", false); 33 | } 34 | 35 | FlexRayAnalyzerSettings::~FlexRayAnalyzerSettings() { 36 | } 37 | 38 | bool FlexRayAnalyzerSettings::SetSettingsFromInterfaces() { 39 | mInputChannel = mInputChannelInterface->GetChannel(); 40 | mBitRate = mBitRateInterface->GetInteger(); 41 | mInverted = mInvertedInterface->GetValue(); 42 | 43 | ClearChannels(); 44 | AddChannel(mInputChannel, "FlexRay", true); 45 | 46 | return true; 47 | } 48 | 49 | void FlexRayAnalyzerSettings::UpdateInterfacesFromSettings() { 50 | mInputChannelInterface->SetChannel(mInputChannel); 51 | mBitRateInterface->SetInteger(mBitRate); 52 | mInvertedInterface->SetValue(mInverted); 53 | } 54 | 55 | void FlexRayAnalyzerSettings::LoadSettings(const char* settings) { 56 | SimpleArchive text_archive; 57 | text_archive.SetString(settings); 58 | 59 | text_archive >> mInputChannel; 60 | text_archive >> mBitRate; 61 | text_archive >> mInverted; 62 | 63 | ClearChannels(); 64 | AddChannel(mInputChannel, "FlexRay", true); 65 | 66 | UpdateInterfacesFromSettings(); 67 | } 68 | 69 | const char* FlexRayAnalyzerSettings::SaveSettings() { 70 | SimpleArchive text_archive; 71 | 72 | text_archive << mInputChannel; 73 | text_archive << mBitRate; 74 | text_archive << mInverted; 75 | 76 | return SetReturnString(text_archive.GetString()); 77 | } 78 | 79 | BitState FlexRayAnalyzerSettings::Recessive() { 80 | if (mInverted) 81 | return BIT_LOW; 82 | return BIT_HIGH; 83 | } 84 | 85 | BitState FlexRayAnalyzerSettings::Dominant() { 86 | if (mInverted) 87 | return BIT_HIGH; 88 | return BIT_LOW; 89 | } 90 | -------------------------------------------------------------------------------- /source/FlexRayAnalyzerSettings.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_ANALYZER_SETTINGS 2 | #define FLEXRAY_ANALYZER_SETTINGS 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class FlexRayAnalyzerSettings : public AnalyzerSettings { 9 | public: 10 | FlexRayAnalyzerSettings(); 11 | virtual ~FlexRayAnalyzerSettings(); 12 | 13 | virtual bool SetSettingsFromInterfaces(); 14 | void UpdateInterfacesFromSettings(); 15 | virtual void LoadSettings(const char* settings); 16 | virtual const char* SaveSettings(); 17 | 18 | Channel mInputChannel; 19 | U32 mBitRate; 20 | bool mInverted; 21 | 22 | BitState Recessive(); 23 | BitState Dominant(); 24 | 25 | protected: 26 | std::auto_ptr mInputChannelInterface; 27 | std::auto_ptr mBitRateInterface; 28 | std::auto_ptr mInvertedInterface; 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /source/FlexRayFrame.cpp: -------------------------------------------------------------------------------- 1 | #include "FlexRayFrame.h" 2 | 3 | // Constructor 4 | FlexRayFrame::FlexRayFrame() {} 5 | 6 | // Deconstructor 7 | FlexRayFrame::~FlexRayFrame() {} 8 | 9 | // Generates a stream of bools at the normal bitrate 10 | std::vector FlexRayFrame::GenerateStream(bool in_dynamic_section) { 11 | std::vector result = std::vector(); 12 | std::vector tmp_vector; 13 | 14 | // Add Transmission Start Sequence 15 | tmp_vector = std::vector(TSS_LEN, false); 16 | result.insert(result.end(), tmp_vector.begin(), tmp_vector.end()); 17 | 18 | // Add Frame Start Sequence 19 | result.push_back(true); 20 | 21 | // Start raw data frame 22 | std::vector raw_frame_data = std::vector(); 23 | 24 | // Header 25 | raw_frame_data.push_back(false); // Reserved bit 26 | raw_frame_data.push_back(payload_preamble); // Payload preamble indicator 27 | raw_frame_data.push_back(null_frame); // Null frame indicator 28 | raw_frame_data.push_back(sync_frame); // Sync frame indicator 29 | raw_frame_data.push_back(startup_frame); // Startup frame indicator 30 | 31 | // 0 is not a valid frame_id! 32 | tmp_vector = ToBoolVector(frame_id, 11); 33 | raw_frame_data.insert(raw_frame_data.end(), tmp_vector.begin(), tmp_vector.end()); 34 | 35 | // Payload length is the number of bytes / 2, and is constant and uniform for all frames in the static segment. 36 | // We calculate it on the fly here because we're lazy 37 | tmp_vector = ToBoolVector((data.size() / 2), 7); 38 | raw_frame_data.insert(raw_frame_data.end(), tmp_vector.begin(), tmp_vector.end()); 39 | 40 | // Header CRC, range = [sync_frame_indicator : payload length], so from bit 3 until bit 22 41 | tmp_vector = ToBoolVector(DumbCRC(std::vector(raw_frame_data.begin(), raw_frame_data.end()),CRC11_INIT, CRC11_POLYNOMIAL, 11), 11); 42 | raw_frame_data.insert(raw_frame_data.end(), tmp_vector.begin(), tmp_vector.end()); 43 | 44 | // Cycle count 45 | tmp_vector = ToBoolVector(cycle_count, 6); 46 | raw_frame_data.insert(raw_frame_data.end(), tmp_vector.begin(), tmp_vector.end()); 47 | 48 | // Actual data 49 | for (U8 i = 0; i < data.size(); i++) { 50 | tmp_vector = ToBoolVector(data[i], 8); 51 | raw_frame_data.insert(raw_frame_data.end(), tmp_vector.begin(), tmp_vector.end()); 52 | } 53 | 54 | // Add BSS and append to result 55 | tmp_vector = ExtendByteSequence(raw_frame_data); 56 | result.insert(result.end(), tmp_vector.begin(), tmp_vector.end()); 57 | 58 | // Frame CRC, range = full message before adding BSS? 59 | // Also add BSS to this before adding to result 60 | // TODO: Check that this is actually correct 61 | tmp_vector = ExtendByteSequence(ToBoolVector(DumbCRC(raw_frame_data, CRC24_INIT, CRC24_POLYNOMIAL, 24), 24)); 62 | result.insert(result.end(), tmp_vector.begin(), tmp_vector.end()); 63 | 64 | // Add Frame End Sequence 65 | result.push_back(false); 66 | result.push_back(true); 67 | 68 | // Add DTS if applicable 69 | if(in_dynamic_section){ 70 | // TODO: Implement 71 | } 72 | 73 | return result; 74 | } 75 | 76 | // TODO: Make this fill in the actual parameters 77 | void FlexRayFrame::Decode(const std::vector &bitstream, std::vector* frames){ 78 | int i = 0; 79 | 80 | // Flags 81 | if(bitstream.size() - i < 5) 82 | return; 83 | 84 | U64 start_sample = bitstream.at(i).start_sample; 85 | i++; // Reserved bit 86 | payload_preamble = bitstream.at(i++).bit; 87 | null_frame = bitstream.at(i++).bit; 88 | sync_frame = bitstream.at(i++).bit; 89 | startup_frame = bitstream.at(i++).bit; 90 | U64 flags = ((int) payload_preamble << 3) | ((int) null_frame << 2) | ((int) sync_frame << 1) | ((int) startup_frame << 0); 91 | AddResultFrame(frames, FlagsField, start_sample, bitstream.at(i-1).end_sample, flags); 92 | 93 | // Frame ID 94 | if(bitstream.size() - i < 11) 95 | return; 96 | 97 | start_sample = bitstream.at(i).start_sample; 98 | U16 frame_id = 0; 99 | for(int j=10; j>=0; j--) 100 | frame_id |= (bitstream.at(i++).bit << j); 101 | AddResultFrame(frames, FrameIdField, start_sample+1, bitstream.at(i-1).end_sample, frame_id); 102 | 103 | // Payload length 104 | // This is half the length!!! 105 | if(bitstream.size() - i < 7) 106 | return; 107 | 108 | start_sample = bitstream.at(i).start_sample; 109 | U16 payload_length = 0; 110 | for(int j=6; j>=0; j--) 111 | payload_length |= (bitstream.at(i++).bit << j); 112 | AddResultFrame(frames, PayloadLengthField, start_sample+1, bitstream.at(i-1).end_sample, payload_length); 113 | 114 | // Header CRC 115 | if(bitstream.size() - i < 11) 116 | return; 117 | 118 | start_sample = bitstream.at(i).start_sample; 119 | U16 header_crc = 0; 120 | for(int j=10; j>=0; j--) 121 | header_crc |= (bitstream.at(i++).bit << j); 122 | AddResultFrame(frames, HeaderCRCField, start_sample+1, bitstream.at(i-1).end_sample, header_crc); 123 | 124 | // Cycle count 125 | if(bitstream.size() - i < 6) 126 | return; 127 | 128 | start_sample = bitstream.at(i).start_sample; 129 | U16 cycle_count = 0; 130 | for(int j=5; j>=0; j--) 131 | cycle_count |= (bitstream.at(i++).bit << j); 132 | AddResultFrame(frames, CycleCountField, start_sample+1, bitstream.at(i-1).end_sample, cycle_count); 133 | 134 | // Data 135 | std::vector data = std::vector(); 136 | for(int k=0; k<(payload_length*2); k++){ 137 | if(bitstream.size() - i < 8) 138 | return; 139 | 140 | start_sample = bitstream.at(i).start_sample; 141 | U8 data_byte = 0; 142 | for(int j=7; j>=0; j--) 143 | data_byte |= (bitstream.at(i++).bit << j); 144 | data.push_back(data_byte); 145 | AddResultFrame(frames, DataField, start_sample+1, bitstream.at(i-1).end_sample, data_byte, k); 146 | } 147 | 148 | // CRC 149 | if(bitstream.size() - i < 24) 150 | return; 151 | 152 | start_sample = bitstream.at(i).start_sample; 153 | U32 crc = 0; 154 | for(int j=23; j>=0; j--) 155 | crc |= (bitstream.at(i++).bit << j); 156 | AddResultFrame(frames, CRCField, start_sample+1, bitstream.at(i-1).end_sample, crc); 157 | } 158 | 159 | void FlexRayFrame::AddResultFrame(std::vector* frames, FlexRayFrameType type, S64 start_sample, S64 end_sample, U64 data1, U64 data2){ 160 | Frame frame; 161 | frame.mType = type; 162 | frame.mData1 = data1; 163 | frame.mData2 = data2; 164 | frame.mFlags = 0; 165 | frame.mStartingSampleInclusive = start_sample; 166 | frame.mEndingSampleInclusive = end_sample; 167 | 168 | FrameSortingWrapper fsw; 169 | fsw.f = frame; 170 | 171 | frames->push_back(fsw); 172 | } -------------------------------------------------------------------------------- /source/FlexRayFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_FRAME_H 2 | #define FLEXRAY_FRAME_H 3 | 4 | #include 5 | 6 | #include 7 | #include "Helpers.h" 8 | #include "FlexRayAnalyzerResults.h" 9 | 10 | typedef struct { 11 | bool bit; 12 | S64 start_sample; 13 | S64 end_sample; 14 | } DecoderBit; 15 | 16 | class FlexRayFrame { 17 | public: 18 | FlexRayFrame(); 19 | ~FlexRayFrame(); 20 | 21 | std::vector GenerateStream(bool in_dynamic_section = false); 22 | void Decode(const std::vector &bitstream, std::vector* frames); 23 | void AddResultFrame(std::vector* frames, FlexRayFrameType type, S64 start_sample, S64 end_sample, U64 data1=0, U64 data2=0); 24 | 25 | public: 26 | bool payload_preamble; 27 | bool null_frame; 28 | bool sync_frame; 29 | bool startup_frame; 30 | U16 header_crc; 31 | U16 frame_id; 32 | U8 cycle_count; 33 | std::vector data; 34 | U32 crc; 35 | }; 36 | 37 | #endif -------------------------------------------------------------------------------- /source/FlexRayParameters.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_PARAMETERS_H 2 | #define FLEXRAY_PARAMETERS_H 3 | 4 | // Sim parameters 5 | #define IDLE_PERIOD_LEN 100 6 | 7 | // Analyser parameters 8 | #define MIN_IDLE_LEN 9 // One more than 1 byte, so doesn't happen normally 9 | 10 | // Cycles 11 | #define NUM_CYCLES 64 12 | 13 | // Special sequences 14 | #define TSS_LEN 5 15 | 16 | // CRC11 17 | #define CRC11_POLYNOMIAL 0xB85 18 | #define CRC11_INIT 0x01A 19 | 20 | // CRC24 21 | #define CRC24_POLYNOMIAL 0x5D6DCB 22 | #define CRC24_INIT 0xFEDCBA 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /source/FlexRaySimulationDataGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include "FlexRaySimulationDataGenerator.h" 2 | 3 | #include "FlexRayFrame.h" 4 | 5 | FlexRaySimulationDataGenerator::FlexRaySimulationDataGenerator() { 6 | } 7 | 8 | FlexRaySimulationDataGenerator::~FlexRaySimulationDataGenerator() {} 9 | 10 | void FlexRaySimulationDataGenerator::Initialize(U32 simulation_sample_rate, FlexRayAnalyzerSettings *settings) { 11 | mSimulationSampleRateHz = simulation_sample_rate; 12 | mSettings = settings; 13 | 14 | mSerialSimulationData.SetChannel(mSettings->mInputChannel); 15 | mSerialSimulationData.SetSampleRate(simulation_sample_rate); 16 | mSerialSimulationData.SetInitialBitState(BIT_HIGH); 17 | } 18 | 19 | U32 FlexRaySimulationDataGenerator::GenerateSimulationData(U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor **simulation_channel) { 20 | U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample(largest_sample_requested, sample_rate, mSimulationSampleRateHz); 21 | U32 samples_per_bit = mSimulationSampleRateHz / mSettings->mBitRate; 22 | 23 | FlexRayFrame test_frame; 24 | test_frame.payload_preamble = false; 25 | test_frame.null_frame = false; 26 | test_frame.sync_frame = false; 27 | test_frame.startup_frame = false; 28 | test_frame.frame_id = 0x12; 29 | test_frame.cycle_count = 10; 30 | 31 | U8 data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 32 | test_frame.data = std::vector(data, data + (sizeof(data) / sizeof(U8))); 33 | 34 | std::vector bitstream; 35 | while (mSerialSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested) { 36 | // Generate frame 37 | test_frame.cycle_count++; 38 | test_frame.cycle_count %= 64; 39 | bitstream = test_frame.GenerateStream(); 40 | 41 | // Idle for IDLE_PERIOD_LEN bits 42 | mSerialSimulationData.Advance(samples_per_bit * IDLE_PERIOD_LEN); 43 | 44 | // Send frame 45 | for (int i = 0; i < bitstream.size(); i++) { 46 | bool bit = bitstream.at(i); 47 | BitState bit_s = bit ? BIT_HIGH : BIT_LOW; 48 | mSerialSimulationData.TransitionIfNeeded(bit_s); 49 | mSerialSimulationData.Advance(samples_per_bit); 50 | } 51 | mSerialSimulationData.TransitionIfNeeded(BIT_HIGH); 52 | } 53 | 54 | // Idle for IDLE_PERIOD_LEN bits 55 | mSerialSimulationData.Advance(samples_per_bit * IDLE_PERIOD_LEN); 56 | 57 | *simulation_channel = &mSerialSimulationData; 58 | return 1; 59 | } -------------------------------------------------------------------------------- /source/FlexRaySimulationDataGenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef FLEXRAY_SIMULATION_DATA_GENERATOR 2 | #define FLEXRAY_SIMULATION_DATA_GENERATOR 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "FlexRayAnalyzerSettings.h" 9 | 10 | class FlexRayAnalyzerSettings; 11 | class FlexRaySimulationDataGenerator { 12 | public: 13 | FlexRaySimulationDataGenerator(); 14 | ~FlexRaySimulationDataGenerator(); 15 | 16 | void Initialize(U32 simulation_sample_rate, FlexRayAnalyzerSettings* settings); 17 | U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel); 18 | 19 | protected: 20 | FlexRayAnalyzerSettings* mSettings; 21 | U32 mSimulationSampleRateHz; 22 | 23 | protected: 24 | void CreateSerialByte(); 25 | 26 | SimulationChannelDescriptor mSerialSimulationData; 27 | }; 28 | #endif -------------------------------------------------------------------------------- /source/Helpers.cpp: -------------------------------------------------------------------------------- 1 | #include "Helpers.h" 2 | 3 | std::vector ToBoolVector(U64 input, U8 num_bits) { 4 | std::vector result; 5 | for (U8 i = 0; i < num_bits; i++) 6 | result.push_back(input & (1 << i)); 7 | reverse(result.begin(), result.end()); 8 | return result; 9 | } 10 | 11 | U64 BoolVectorToInt(const std::vector &input, U64 start_index, U8 num_bits) { 12 | U64 result = 0; 13 | for(U64 i = 0; i ExtendByteSequence(const std::vector &vec) { 21 | std::vector result = std::vector(); 22 | for(int i=0; i input, U32 init, U32 polynomial, U8 num_bits) { 38 | U32 result = init; 39 | U64 mask = (1 << num_bits) - 1; 40 | 41 | for(U64 i = 0; i 5 | #include 6 | #include 7 | #include 8 | 9 | typedef struct FrameSortingWrapper { 10 | Frame f; 11 | bool operator < (const FrameSortingWrapper& f1) const { 12 | return f.mStartingSampleInclusive < f1.f.mStartingSampleInclusive; 13 | } 14 | } FrameSortingWrapper; 15 | 16 | std::vector ToBoolVector(U64 input, U8 num_bits); 17 | U64 BoolVectorToInt(const std::vector &input, U64 start_index, U8 num_bits); 18 | std::vector ExtendByteSequence(const std::vector &vec); 19 | U16 DumbCRC(std::vector input, U32 init, U32 polynomial, U8 num_bits); 20 | 21 | #endif -------------------------------------------------------------------------------- /test_analyser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Python 3 script to quickly build the analyser, re-open Logic and start a simulation 4 | import os 5 | import time 6 | import saleae 7 | import psutil 8 | from build_analyzer import build 9 | 10 | LOGIC_PATH = "/home/batman/Desktop/Logic/" 11 | 12 | def close_logic(): 13 | for p in psutil.process_iter(): 14 | if p.name() == 'Main': 15 | p.kill() 16 | 17 | def clear_crash_log(): 18 | if os.path.exists('core'): 19 | os.remove('core') 20 | 21 | if os.path.exists(LOGIC_PATH + 'core'): 22 | os.remove(LOGIC_PATH + 'core') 23 | 24 | def test(): 25 | close_logic() 26 | clear_crash_log() 27 | build() 28 | saleae.Saleae.launch_logic(logic_path=LOGIC_PATH + 'Logic', quiet=False) 29 | time.sleep(1) 30 | s = saleae.Saleae() 31 | s.capture_start() 32 | 33 | if __name__ == "__main__": 34 | test() 35 | --------------------------------------------------------------------------------