diff --git a/scopeprotocols/OneWireDecoder.cpp b/scopeprotocols/OneWireDecoder.cpp index 2514bdc7..846e575f 100644 --- a/scopeprotocols/OneWireDecoder.cpp +++ b/scopeprotocols/OneWireDecoder.cpp @@ -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; im_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; } @@ -220,6 +221,7 @@ void OneWireDecoder::Refresh() bitcount = 0; current_byte = 0; + current_byte_bad_timings = false; } break; @@ -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 @@ -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; @@ -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]; @@ -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: @@ -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: diff --git a/scopeprotocols/OneWireDecoder.h b/scopeprotocols/OneWireDecoder.h index 8e721aaf..e24fbd6b 100644 --- a/scopeprotocols/OneWireDecoder.h +++ b/scopeprotocols/OneWireDecoder.h @@ -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); } };