Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions scopeprotocols/OneWireDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void OneWireDecoder::Refresh()
len = starts.size();
int bitcount = 0;
uint8_t current_byte = 0;
bool current_byte_bad_timings = false;
for(size_t i=0; i<len; i++)
{
//Get the length of this pulse in us
Expand All @@ -163,7 +164,7 @@ void OneWireDecoder::Refresh()
{
cap->m_offsets.push_back(starts[i]);
cap->m_durations.push_back(lens[i]);
cap->m_samples.push_back(OneWireSymbol(OneWireSymbol::TYPE_RESET, 1));
cap->m_samples.push_back(OneWireSymbol(OneWireSymbol::TYPE_RESET, 0, true));

state = STATE_DETECT;
}
Expand Down Expand Up @@ -220,6 +221,7 @@ void OneWireDecoder::Refresh()

bitcount = 0;
current_byte = 0;
current_byte_bad_timings = false;
}

break;
Expand All @@ -244,8 +246,11 @@ void OneWireDecoder::Refresh()
current_byte >>= 1;
current_byte |= 0x80;
}
else if(pulselen > 60)
else if(pulselen > 25)
{
current_byte >>= 1;
current_byte_bad_timings |= pulselen <= 60;
}

//Invalid pulse length
else
Expand All @@ -264,10 +269,11 @@ void OneWireDecoder::Refresh()
{
cap->m_offsets.push_back(tstart);
cap->m_durations.push_back(tend - tstart);
cap->m_samples.push_back(OneWireSymbol(OneWireSymbol::TYPE_DATA, current_byte));
cap->m_samples.push_back(OneWireSymbol(OneWireSymbol::TYPE_DATA, current_byte, current_byte_bad_timings));

bitcount = 0;
current_byte = 0;
current_byte_bad_timings = false;
}

break;
Expand All @@ -288,7 +294,7 @@ Gdk::Color OneWireDecoder::GetColor(int i)
switch(s.m_stype)
{
case OneWireSymbol::TYPE_RESET:
if(s.m_data == 1)
if(s.m_tooShort == 1)
return m_standardColors[COLOR_ERROR];
else
return m_standardColors[COLOR_CONTROL];
Expand All @@ -297,7 +303,10 @@ Gdk::Color OneWireDecoder::GetColor(int i)
return m_standardColors[COLOR_CONTROL];

case OneWireSymbol::TYPE_DATA:
return m_standardColors[COLOR_DATA];
if(s.m_tooShort == 1)
return m_standardColors[COLOR_ERROR];
else
return m_standardColors[COLOR_DATA];

case OneWireSymbol::TYPE_ERROR:
default:
Expand All @@ -320,13 +329,13 @@ string OneWireDecoder::GetText(int i)
switch(s.m_stype)
{
case OneWireSymbol::TYPE_RESET:
if(s.m_data == 1)
if(s.m_tooShort == 1)
return "RESET (too short)";
else
return "RESET";

case OneWireSymbol::TYPE_DATA:
snprintf(tmp, sizeof(tmp), "%02x", s.m_data);
snprintf(tmp, sizeof(tmp), "%02x%s", s.m_data, s.m_tooShort?" (?)":"");
return string(tmp);

case OneWireSymbol::TYPE_PRESENCE:
Expand Down
6 changes: 4 additions & 2 deletions scopeprotocols/OneWireDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ class OneWireSymbol
OneWireSymbol()
{}

OneWireSymbol(stype t,uint8_t d)
OneWireSymbol(stype t, uint8_t d, bool s = false)
: m_stype(t)
, m_data(d)
, m_tooShort(s)
{}

stype m_stype;
uint8_t m_data;
bool m_tooShort;

bool operator== (const OneWireSymbol& s) const
{
return (m_stype == s.m_stype) && (m_data == s.m_data);
return (m_stype == s.m_stype) && (m_data == s.m_data) && (m_tooShort == s.m_tooShort);
}
};

Expand Down