From 2c9718632983e4ca563f559558cdede2358ccb35 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Sun, 26 Feb 2012 19:53:08 -0800 Subject: [PATCH] Fix bug introduced in the move to PROGMEM. Props to @basilrx for finding this. Also added a test case to demonstrate the bug, and guard against more like it in the future. --- RF24.cpp | 2 +- tests/pingpair_test/pingpair_test.pde | 22 +++++++++++++++++++--- tests/pingpair_test/runtests.sh | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index cee374f..9471583 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -649,7 +649,7 @@ void RF24::openReadingPipe(uint8_t child, uint64_t address) // Note it would be more efficient to set all of the bits for all open // pipes at once. However, I thought it would make the calling code // more simple to do it this way. - write_register(EN_RXADDR,read_register(EN_RXADDR) | _BV(child_pipe_enable[child])); + write_register(EN_RXADDR,read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[child]))); } } diff --git a/tests/pingpair_test/pingpair_test.pde b/tests/pingpair_test/pingpair_test.pde index 61ad29b..6acbf51 100644 --- a/tests/pingpair_test/pingpair_test.pde +++ b/tests/pingpair_test/pingpair_test.pde @@ -89,6 +89,8 @@ const int interval = 100; //*< ms to wait between sends */ char configuration = '1'; //*< Configuration key, one char sent in by the test framework to tell us how to configure, this is the default */ +uint8_t pipe_number = 1; // Which pipe to send on. + void one_ok(void) { // Have we received enough yet? @@ -203,6 +205,20 @@ void setup(void) radio.enableDynamicPayloads(); } + // Config 4 tests out a higher pipe ## + if (configuration == '4' && role == role_sender) + { + // Set top 4 bytes of the address in pipe 1 + radio.openReadingPipe(1,pipe & 0xFFFFFFFF00ULL); + + // indicate the pipe to use + pipe_number = 5; + } + else if ( role == role_sender ) + { + radio.openReadingPipe(5,0); + } + // // Open pipes to other nodes for communication // @@ -216,7 +232,7 @@ void setup(void) } else { - radio.openReadingPipe(1,pipe); + radio.openReadingPipe(pipe_number,pipe); } // @@ -230,7 +246,7 @@ void setup(void) // Dump the configuration of the rf unit for debugging // - //radio.printDetails(); + radio.printDetails(); // // Attach interrupt handler to interrupt #0 (using pin 2) @@ -410,7 +426,7 @@ void check_radio(void) // Add an ack packet for the next time around. // Here we will report back how many bytes we got this time. - radio.writeAckPayload( 1, &len, sizeof(len) ); + radio.writeAckPayload( pipe_number, &len, sizeof(len) ); ++message_count; } } diff --git a/tests/pingpair_test/runtests.sh b/tests/pingpair_test/runtests.sh index 9f1a73f..4d02310 100755 --- a/tests/pingpair_test/runtests.sh +++ b/tests/pingpair_test/runtests.sh @@ -14,3 +14,8 @@ stty 57600 raw ignbrk hup < /dev/ttyUSB0 sleep 1 stty 57600 raw ignbrk hup < /dev/ttyUSB1 expect test.ex 3 +sleep 1 +stty 57600 raw ignbrk hup < /dev/ttyUSB0 +sleep 1 +stty 57600 raw ignbrk hup < /dev/ttyUSB1 +expect test.ex 4