Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ab823c457478
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d48bf4495fc7
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on May 7, 2019

  1. Copy the full SHA
    d48bf44 View commit details
1 change: 1 addition & 0 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ set(SCOPEPROTOCOLS_SOURCES
ThresholdDecoder.cpp
UARTDecoder.cpp
UartClockRecoveryDecoder.cpp
USB2ActivityDecoder.cpp
USB2PacketDecoder.cpp
USB2PacketRenderer.cpp
USB2PCSDecoder.cpp
134 changes: 134 additions & 0 deletions scopeprotocols/USB2ActivityDecoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

#include "../scopehal/scopehal.h"
#include "USB2ActivityDecoder.h"
#include "USB2PCSDecoder.h"
#include "../scopehal/DigitalRenderer.h"

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

USB2ActivityDecoder::USB2ActivityDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_DIGITAL, color, CAT_SERIAL)
{
//Set up channels
m_signalNames.push_back("din");
m_channels.push_back(NULL);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods

ChannelRenderer* USB2ActivityDecoder::CreateRenderer()
{
return new DigitalRenderer(this);
}

bool USB2ActivityDecoder::ValidateChannel(size_t i, OscilloscopeChannel* channel)
{
if( (i == 0) && (dynamic_cast<USB2PCSDecoder*>(channel) != NULL) )
return true;
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

string USB2ActivityDecoder::GetProtocolName()
{
return "USB 1.x/2.0 Activity";
}

void USB2ActivityDecoder::SetDefaultName()
{
char hwname[256];
snprintf(hwname, sizeof(hwname), "USB2Activity(%s)", m_channels[0]->m_displayname.c_str());
m_hwname = hwname;
m_displayname = m_hwname;
}

bool USB2ActivityDecoder::NeedsConfig()
{
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual decoder logic

void USB2ActivityDecoder::Refresh()
{
//Get the input data
if(m_channels[0] == NULL)
{
SetData(NULL);
return;
}
USB2PCSCapture* din = dynamic_cast<USB2PCSCapture*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
return;
}

//Can't do much if we have no samples to work with
if(din->GetDepth() == 0)
{
SetData(NULL);
return;
}

DigitalCapture* cap = new DigitalCapture;

//Start low, go high when we see a SYNC, low at EOP
int64_t last = 0;
for(size_t i=0; i<din->m_samples.size(); i++)
{
USB2PCSSample sin = din->m_samples[i];
if(sin.m_sample.m_type == USB2PCSSymbol::TYPE_SYNC)
{
cap->m_samples.push_back(DigitalSample(last, sin.m_offset - last, false));
last = sin.m_offset;
}

if(sin.m_sample.m_type == USB2PCSSymbol::TYPE_EOP)
{
cap->m_samples.push_back(DigitalSample(last, sin.m_offset - last, true));
last = sin.m_offset;
}
}

//Done, copy our time scales from the input
SetData(cap);
cap->m_timescale = din->m_timescale;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
}
58 changes: 58 additions & 0 deletions scopeprotocols/USB2ActivityDecoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of USB2ActivityDecoder
*/
#ifndef USB2ActivityDecoder_h
#define USB2ActivityDecoder_h

#include "../scopehal/ProtocolDecoder.h"

class USB2ActivityDecoder : public ProtocolDecoder
{
public:
USB2ActivityDecoder(std::string color);

virtual void Refresh();
virtual ChannelRenderer* CreateRenderer();

virtual bool NeedsConfig();

static std::string GetProtocolName();
virtual void SetDefaultName();

virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

PROTOCOL_DECODER_INITPROC(USB2ActivityDecoder)
};

#endif
2 changes: 1 addition & 1 deletion scopeprotocols/USB2PMADecoder.cpp
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ void USB2PMADecoder::SetDefaultName()

string USB2PMADecoder::GetProtocolName()
{
return "USB 1.x/2.x PMA";
return "USB 1.x/2.0 PMA";
}

bool USB2PMADecoder::IsOverlay()
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.cpp
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ void ScopeProtocolStaticInit()
AddDecoderClass(ThresholdDecoder);
AddDecoderClass(UARTDecoder);
AddDecoderClass(UartClockRecoveryDecoder);
AddDecoderClass(USB2ActivityDecoder);
AddDecoderClass(USB2PacketDecoder);
AddDecoderClass(USB2PCSDecoder);
AddDecoderClass(USB2PMADecoder);
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.h
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@
#include "ThresholdDecoder.h"
#include "UARTDecoder.h"
#include "UartClockRecoveryDecoder.h"
#include "USB2ActivityDecoder.h"
#include "USB2PacketDecoder.h"
#include "USB2PCSDecoder.h"
#include "USB2PMADecoder.h"