Skip to content

Commit

Permalink
Merge pull request #1 from saleae/temp/alpha-wip
Browse files Browse the repository at this point in the history
Add FrameV2 support
  • Loading branch information
Marcus10110 authored Jun 17, 2020
2 parents e71cb6e + ec4bec4 commit 825458b
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion src/OneWireAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "OneWireAnalyzer.h"
#include "OneWireAnalyzerSettings.h"
#include <AnalyzerChannelData.h>

#include <unordered_map>

OneWireAnalyzer::OneWireAnalyzer() : mSettings( new OneWireAnalyzerSettings() ), Analyzer2(), mSimulationInitilized( false )
{
Expand Down Expand Up @@ -693,6 +693,84 @@ void OneWireAnalyzer::RecordFrame( U64 starting_sample, U64 ending_sample, OneWi

mResults->AddFrame( frame );

FrameV2 frame_v2;
std::string frame_v2_type;
bool ignore_frame_v2 = false;

switch( type )
{
case RestartPulse:
frame_v2_type = "reset";
break;
case PresencePulse:
frame_v2_type = "presence";
break;
case ReadRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "read" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case SkipRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "skip" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case SearchRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "search" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case MatchRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "match" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case OverdriveSkipRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "skip" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
// TODO: handle over drive - add boolean to all overdrive frames.
break;
case OverdriveMatchRomFrame:
frame_v2_type = "rom_command";
frame_v2.AddString( "description", "match" );
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case CRC:
frame_v2_type = "crc";
frame_v2.AddByte( "crc", static_cast<uint8_t>( frame.mData1 ) );
break;
case FamilyCode:
frame_v2_type = "family_code";
frame_v2.AddByte( "family", static_cast<uint8_t>( frame.mData1 ) );
break;
case Rom:
frame_v2_type = "id";
frame_v2.AddInteger( "id", frame.mData1 );
break;
case Byte:
frame_v2_type = "data";
frame_v2.AddByte( "data", static_cast<uint8_t>( frame.mData1 ) );
break;
case Bit:
// the Bit enum value is never used.
ignore_frame_v2 = true;
break;
case InvalidRomCommandFrame:
frame_v2_type = "invalid_rom_command";
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
case AlarmSearchFrame:
frame_v2_type = "alarm";
frame_v2.AddByte( "rom_command", static_cast<uint8_t>( frame.mData1 ) );
break;
}

if( !ignore_frame_v2 )
{
mResults->AddFrameV2( frame_v2, frame_v2_type.c_str(), frame.mStartingSampleInclusive, frame.mEndingSampleInclusive );
}

mResults->CommitResults();
}

Expand Down

0 comments on commit 825458b

Please sign in to comment.