Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
bf06db96
Commit
bf06db96
authored
Dec 19, 2015
by
TMRh20
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RPi call_response_int2 example
- Fix blank response detect & remove wait
parent
2c4d1991
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
examples_RPi/interrupts/gettingstarted_call_response_int2.cpp
...ples_RPi/interrupts/gettingstarted_call_response_int2.cpp
+6
-14
No files found.
examples_RPi/interrupts/gettingstarted_call_response_int2.cpp
View file @
bf06db96
...
...
@@ -43,7 +43,6 @@ const uint8_t addresses[][6] = {"1Node","2Node"};
bool
role_ping_out
=
1
,
role_pong_back
=
0
,
role
=
0
;
uint8_t
counter
=
1
;
// A single byte to keep track of the data being sent back and forth
uint32_t
timer
=
0
;
volatile
bool
gotAck
=
false
;
void
intHandler
(){
...
...
@@ -55,10 +54,12 @@ void intHandler(){
}
if
(
role
==
role_ping_out
&&
tx_ok
){
gotAck
=
true
;
if
(
!
radio
.
available
()){
printf
(
"Got blank response. round-trip delay: %u ms
\n\r
"
,
millis
()
-
timer
);
}
}
if
(
role
==
role_ping_out
&&
rx
){
if
(
role
==
role_ping_out
){
while
(
radio
.
available
()
){
uint8_t
gotByte
;
radio
.
read
(
&
gotByte
,
1
);
...
...
@@ -134,22 +135,13 @@ while (1){
if
(
role
==
role_ping_out
){
// Radio is in ping mode
//uint8_t gotByte;
// Initialize a variable for the incoming response
//uint8_t gotByte; // Initialize a variable for the incoming response
radio
.
stopListening
();
// First, stop listening so we can talk.
printf
(
"Now sending %d as payload. "
,
counter
);
// Use a simple byte counter as payload
timer
=
millis
();
// Record the current microsecond count
timer
=
millis
();
// Record the current microsecond count
gotAck
=
false
;
radio
.
startWrite
(
&
counter
,
1
,
false
);
// Send the counter variable to the other radio
while
(
!
gotAck
){
if
(
millis
()
-
timer
>
100
){
break
;}
}
if
(
!
gotAck
){
// If nothing in the buffer, we got an ack but it is blank
printf
(
"Got blank response. round-trip delay: %u ms
\n\r
"
,
millis
()
-
timer
);
}
sleep
(
1
);
// Try again later
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment