Commit 0066eece authored by TMRh20's avatar TMRh20

Fix bugs in transfer example

Inadequate testing appeared to indicate the CRC checking was at fault,
this was incorrect.

Seemed to be 2 separate bugs in transfer example:
Symptoms: Arduino would start reading 150+ KB/s and about 5000
payloads/second received after a period of time with transfers ongoing
continuously.
Fixes:
1. Remove the printf of Payload Count (same issue with %lu )
2. Prevent division into 0
parent 18e67756
...@@ -43,7 +43,7 @@ void setup(void) { ...@@ -43,7 +43,7 @@ void setup(void) {
radio.setAutoAck(1); // Ensure autoACK is enabled radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(2,15); // Optionally, increase the delay between retries & # of retries radio.setRetries(2,15); // Optionally, increase the delay between retries & # of retries
//radio.setCRCLength(RF24_CRC_8); Note: The original Transfer.ino example used 8-bit CRC which was found to result in data corruption over time. radio.setCRCLength(RF24_CRC_8); // Use 8-bit CRC for performance
radio.openWritingPipe(pipes[0]); radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]); radio.openReadingPipe(1,pipes[1]);
...@@ -114,10 +114,12 @@ if(role == RX){ ...@@ -114,10 +114,12 @@ if(role == RX){
} }
if(millis() - rxTimer > 1000){ if(millis() - rxTimer > 1000){
rxTimer = millis(); rxTimer = millis();
float numBytes = (counter*32)/1000.0; unsigned long numBytes = counter*32;
Serial.print("Rate: "); Serial.print("Rate: ");
Serial.print(numBytes); //Prevent dividing into 0, which will cause issues over a period of time
printf("KB/s \n Payload Count: %d \n\r", counter); Serial.println(numBytes > 0 ? numBytes/1000.0:0);
Serial.print("Payload Count: ");
Serial.println(counter);
counter = 0; counter = 0;
} }
} }
......
...@@ -62,7 +62,7 @@ int main(int argc, char** argv){ ...@@ -62,7 +62,7 @@ int main(int argc, char** argv){
radio.setDataRate(RF24_1MBPS); radio.setDataRate(RF24_1MBPS);
radio.setAutoAck(1); // Ensure autoACK is enabled radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(2,15); // Optionally, increase the delay between retries & # of retries radio.setRetries(2,15); // Optionally, increase the delay between retries & # of retries
radio.setCRCLength(RF24_CRC_16); //Note: The original Transfer.ino example used 8-bit CRC which was found to result in data corruption over time. radio.setCRCLength(RF24_CRC_8); // Use 8-bit CRC for performance
radio.printDetails(); radio.printDetails();
/********* Role chooser ***********/ /********* Role chooser ***********/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment