Skip to content

Commit

Permalink
#251: Remove debug print and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ataffanel committed Dec 5, 2017
1 parent be8bbc5 commit 18cdacf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/deck/drivers/src/lpsTdoaTag.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,10 @@ static void setRadioInReceiveMode(dwDevice_t *dev) {
dwStartReceive(dev);
}

#include "debug.h"

static uint32_t onEvent(dwDevice_t *dev, uwbEvent_t event) {
switch(event) {
case eventPacketReceived:
if (rxcallback(dev)) {
DEBUG_PRINT("Sending LPP short packet ...");

lppPacketToSend = false;
} else {
setRadioInReceiveMode(dev);
Expand Down
55 changes: 54 additions & 1 deletion test/deck/drivers/src/TestLpsTdoaTag.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ void testMissingTimestampInhibitsClockDriftCalculationInFirstIteration() {
mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -411,6 +417,12 @@ void testMissingPacketAnchorToAnchorInhibitsDiffCalculation() {
// mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -469,6 +481,12 @@ void testMissingAnchorToAnchorDistanceInhibitsDiffCalculation() {
// mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -526,6 +544,12 @@ void testMissingPacketPacketAnchorToAnchorInhibitsDiffCalculation() {
// mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -583,6 +607,12 @@ void testMissingPacketPacketAnchorToAnchorInhibitsDiffCalculationWhenSequenceNrW
// mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -649,6 +679,13 @@ void testMissingPacketAnchorToTagInhibitsDiffCalculation() {
// Not called since previous packet from same anchor was lost
// mockKalmanEstimator(5, 0, -expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand All @@ -671,6 +708,8 @@ void testPacketReceivedEventShouldSetTheRadioInReceiveMode() {

ignoreKalmanEstimatorValidation();

lpsGetLppShort_IgnoreAndReturn(false);

// Test
uint32_t actual = uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);

Expand All @@ -682,6 +721,8 @@ void testEventTimeoutShouldSetTheRadioInReceiveMode() {
// Fixture
mockRadioSetToReceiveMode();

lpsGetLppShort_IgnoreAndReturn(false);

// Test
uint32_t actual = uwbTdoaTagAlgorithm.onEvent(&dev, eventTimeout);

Expand All @@ -693,6 +734,8 @@ void testEventReceiveTimeoutShouldSetTheRadioInReceiveMode() {
// Fixture
mockRadioSetToReceiveMode();

lpsGetLppShort_IgnoreAndReturn(false);

// Test
uint32_t actual = uwbTdoaTagAlgorithm.onEvent(&dev, eventReceiveTimeout);

Expand Down Expand Up @@ -859,6 +902,10 @@ void verifyDifferenceOfDistanceWithNoClockDriftButConfigurableClockOffset(uint64
// Only the last message will create calls to the estimator. The two first are discarded due to missing data.
mockKalmanEstimator(0, 1, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand Down Expand Up @@ -919,6 +966,12 @@ void verifyDifferenceOfDistanceWithTwoAnchors3FramesWithClockDrift(float driftTa
mockKalmanEstimator(5, 0, -expectedDiff);
mockKalmanEstimator(0, 5, expectedDiff);

lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);
lpsGetLppShort_IgnoreAndReturn(false);

// Test
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
uwbTdoaTagAlgorithm.onEvent(&dev, eventPacketReceived);
Expand All @@ -928,4 +981,4 @@ void verifyDifferenceOfDistanceWithTwoAnchors3FramesWithClockDrift(float driftTa

// Assert
// Nothing here, verification in mocks
}
}

0 comments on commit 18cdacf

Please sign in to comment.