From c13db8f42db76a78ba79fa244271d6beba1c425c Mon Sep 17 00:00:00 2001 From: maniacbug Date: Wed, 13 Jul 2011 19:13:57 -0700 Subject: [PATCH] Added a second test configuration --- RF24.cpp | 1 + tests/pingpair_test/pingpair_test.pde | 45 ++++++++++++++++++++------- tests/pingpair_test/runtest.py | 2 +- tests/pingpair_test/runtests.sh | 7 +++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index c16e034..91bec36 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -293,6 +293,7 @@ void RF24::printDetails(void) print_byte_register(PSTR("EN_RXADDR"),EN_RXADDR); print_byte_register(PSTR("RF_CH"),RF_CH); print_byte_register(PSTR("RF_SETUP"),RF_SETUP); + print_byte_register(PSTR("CONFIG"),CONFIG); print_byte_register(PSTR("DYNPD/FEATURE"),DYNPD,2); } diff --git a/tests/pingpair_test/pingpair_test.pde b/tests/pingpair_test/pingpair_test.pde index 39ae648..72048e3 100644 --- a/tests/pingpair_test/pingpair_test.pde +++ b/tests/pingpair_test/pingpair_test.pde @@ -87,6 +87,8 @@ int receives_remaining = num_needed; //*< How many ack packets until we declare int failures_remaining = num_needed; //*< How many more failed sends until we declare failure? */ const int interval = 100; //*< ms to wait between sends */ +char configuration = ' '; //*< Configuration key, one char sent in by the test framework to tell us how to configure, ' ' is default */ + void one_ok(void) { // Have we received enough yet? @@ -134,7 +136,7 @@ void setup(void) printf("ROLE: %s\n\r",role_friendly_name[role]); // - // TODO: Read configuration from serial + // Read configuration from serial // // It would be a much better test if this program could accept configuration // from the serial port. Then it would be possible to run the same test under @@ -151,7 +153,8 @@ void setup(void) printf("+READY press any key to start\n\r\n\r"); while (! Serial.available() ) {} - Serial.read(); + configuration = Serial.read(); + printf("Configuration\t = %c\n\r",configuration); // // Setup and configure rf radio @@ -161,19 +164,37 @@ void setup(void) // We will be using the Ack Payload feature, so please enable it radio.enableAckPayload(); - + + switch(configuration) + { + case ' ': + case '1': + // Optional: Increase CRC length for improved reliability + radio.setCRCLength(RF24_CRC_16); + + // Optional: Decrease data rate for improved reliability + radio.setDataRate(RF24_1MBPS); + + // Optional: Pick a high channel + radio.setChannel(90); + + break; + case '2': + // Optional: Increase CRC length for improved reliability + radio.setCRCLength(RF24_CRC_8); + radio.setDataRate(RF24_2MBPS); + radio.setChannel(10); + break; + default: + printf("ERROR Unknown configuration %c\n\r",configuration); + done = true; + passed = false; + break; + } + // enable dynamic payloads radio.enableDynamicPayloads(); - // Optional: Increase CRC length for improved reliability - radio.setCRCLength(RF24_CRC_16); - - // Optional: Decrease data rate for improved reliability - radio.setDataRate(RF24_1MBPS); - - // Optional: Pick a high channel - radio.setChannel(90); - // // Open pipes to other nodes for communication // diff --git a/tests/pingpair_test/runtest.py b/tests/pingpair_test/runtest.py index 3b9e0c3..45fb65c 100755 --- a/tests/pingpair_test/runtest.py +++ b/tests/pingpair_test/runtest.py @@ -15,7 +15,7 @@ def read_until(token): ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False) read_until("+READY") -ser.write(" ") +ser.write(sys.argv[2]) line = read_until("+OK") ser.close() diff --git a/tests/pingpair_test/runtests.sh b/tests/pingpair_test/runtests.sh index 61ed042..028faa8 100755 --- a/tests/pingpair_test/runtests.sh +++ b/tests/pingpair_test/runtests.sh @@ -3,7 +3,10 @@ # Connect p6 to receiver, p4 to sender jam p4 p6 || exit 1 -./runtest.py /dev/tty.usbserial-A600eHIs & -./runtest.py /dev/tty.usbserial-A40081RP || exit 1 +./runtest.py /dev/tty.usbserial-A600eHIs 1 & +./runtest.py /dev/tty.usbserial-A40081RP 1 || exit 1 +kill `jobs -p` +./runtest.py /dev/tty.usbserial-A600eHIs 2 & +./runtest.py /dev/tty.usbserial-A40081RP 2 || exit 1 kill `jobs -p` exit 0