mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-24 14:19:39 -04:00
Manchester decoder bounds checking.
Return error symbol if reading past source data.
This commit is contained in:
parent
8461b0c94e
commit
32319ddf9f
1 changed files with 8 additions and 3 deletions
|
@ -562,9 +562,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodedSymbol operator[](const size_t index) const {
|
DecodedSymbol operator[](const size_t index) const {
|
||||||
const auto value = encoded[index * 2 + sense];
|
const size_t encoded_index = index * 2;
|
||||||
const auto error = encoded[index * 2 + 0] == encoded[index * 2 + 1];
|
if( (encoded_index + 1) < count ) {
|
||||||
return { value, error };
|
const auto value = encoded[encoded_index + sense];
|
||||||
|
const auto error = encoded[encoded_index + 0] == encoded[encoded_index + 1];
|
||||||
|
return { value, error };
|
||||||
|
} else {
|
||||||
|
return { 0, 1 };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t symbols_count() const {
|
size_t symbols_count() const {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue