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: ee94170451f4
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9fdc3856e17c
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Oct 28, 2020

  1. Cleaned up DSI checksum calculation. Now display checksum in an addit…

    …ional column of the protocol analyzer view.
    azonenberg committed Oct 28, 2020
    Copy the full SHA
    9fdc385 View commit details
Showing with 13 additions and 23 deletions.
  1. +7 −0 scopeprotocols/DSIFrameDecoder.cpp
  2. +6 −22 scopeprotocols/DSIPacketDecoder.cpp
  3. +0 −1 scopeprotocols/DSIPacketDecoder.h
7 changes: 7 additions & 0 deletions scopeprotocols/DSIFrameDecoder.cpp
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@ vector<string> DSIFrameDecoder::GetHeaders()
{
vector<string> ret;
ret.push_back("Width");
ret.push_back("Checksum");
return ret;
}

@@ -213,6 +214,7 @@ void DSIFrameDecoder::Refresh()
//Create packet
pack = new VideoScanlinePacket;
pack->m_offset = off * cap->m_timescale;
pack->m_headers["Checksum"] = "Not checked";

//fall through
case STATE_RGB888_RED:
@@ -222,6 +224,11 @@ void DSIFrameDecoder::Refresh()
red = s.m_data;
state = STATE_RGB888_GREEN;
}
else if(s.m_stype == DSISymbol::TYPE_CHECKSUM_OK)
pack->m_headers["Checksum"] = "OK";
else if(s.m_stype == DSISymbol::TYPE_CHECKSUM_BAD)
pack->m_headers["Checksum"] = "Error";

break;

case STATE_RGB888_GREEN:
28 changes: 6 additions & 22 deletions scopeprotocols/DSIPacketDecoder.cpp
Original file line number Diff line number Diff line change
@@ -422,7 +422,7 @@ void DSIPacketDecoder::Refresh()

//Verify checksum.
//0x0000 means "checksum not calculated" so always passes
if( (current_checksum == BitReverse(expected_checksum)) || (current_checksum == 0x0000) )
if( (current_checksum == expected_checksum) || (current_checksum == 0x0000) )
cap->m_samples.push_back(DSISymbol(DSISymbol::TYPE_CHECKSUM_OK, current_checksum));
else
cap->m_samples.push_back(DSISymbol(DSISymbol::TYPE_CHECKSUM_BAD, current_checksum));
@@ -646,34 +646,18 @@ string DSIPacketDecoder::GetText(int i)
uint16_t DSIPacketDecoder::UpdateCRC(uint16_t crc, uint8_t data)
{
//CRC16 with polynomial x^16 + x^12 + x^5 + x^0 (CRC-16-CCITT)
uint16_t poly = 0x1021;
uint16_t poly = 0x8408;
for(int i=0; i<8; i++)
{
bool b = (data >> (7-i)) & 1;
bool c = (crc & 0x8000);
crc <<= 1;
if(b ^ c)
crc ^= poly;
if( ((data >> i) ^ crc) & 1 )
crc = (crc >> 1) ^ poly;
else
crc >>= 1;
}

return crc;
}

/**
@brief MIPI seems to send the CRC bit-reversed from the normal order. Flip it
*/
uint16_t DSIPacketDecoder::BitReverse(uint16_t crc)
{
uint16_t crc_flipped = 0;
for(int i=0; i<16; i++)
{
if(crc & (1 << i))
crc_flipped |= (1 << (15-i));
}

return crc_flipped;
}

vector<string> DSIPacketDecoder::GetHeaders()
{
vector<string> ret;
1 change: 0 additions & 1 deletion scopeprotocols/DSIPacketDecoder.h
Original file line number Diff line number Diff line change
@@ -133,7 +133,6 @@ class DSIPacketDecoder : public PacketDecoder

protected:
uint16_t UpdateCRC(uint16_t crc, uint8_t data);
uint16_t BitReverse(uint16_t crc);

public:
PROTOCOL_DECODER_INITPROC(DSIPacketDecoder)