From 8c33e57d63389ed53f8c41c3d5a82272027a64a1 Mon Sep 17 00:00:00 2001 From: Mathias Weyland Date: Fri, 22 Apr 2016 15:30:38 +0200 Subject: [PATCH] Bugfix in V/D 2 vote counting. Cast READ_BIT1() to bool. I was under the erroneous impression that READ_BIT1() would return 0 and 1. It turns out this is not the case -- it simply masks out the desired bit without shifting to the right. Casting to bool yields 0 and 1 which we then can use to compute the sum. --- YSFPayload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFPayload.cpp b/YSFPayload.cpp index fd2b9a4..5f04e5d 100644 --- a/YSFPayload.cpp +++ b/YSFPayload.cpp @@ -395,7 +395,7 @@ void CYSFPayload::decodeVDMode2(unsigned char fn) // errors += READ_BIT1(vch, 103); // Padding bit must be zero but apparently it is not... for(unsigned int i = 0U; i < 81U; i += 3) { - uint8_t vote = READ_BIT1(vch, i) + READ_BIT1(vch, i+1) + READ_BIT1(vch, i+2); + uint8_t vote = bool(READ_BIT1(vch, i)) + bool(READ_BIT1(vch, i+1)) + bool(READ_BIT1(vch, i+2)); if(vote == 1 || vote == 2) { bool decision = vote / 2; // exploit integer division: 1/2 == 0, 2/2 == 1.