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
d436895f
Commit
d436895f
authored
Jul 13, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 3rd test case, static payload
parent
c408c5ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
tests/pingpair_test/pingpair_test.pde
tests/pingpair_test/pingpair_test.pde
+23
-7
tests/pingpair_test/runtests.sh
tests/pingpair_test/runtests.sh
+3
-0
No files found.
tests/pingpair_test/pingpair_test.pde
View file @
d436895f
...
...
@@ -70,7 +70,7 @@ void check_radio(void);
const
int
min_payload_size
=
4
;
const
int
max_payload_size
=
32
;
const
int
payload_size_increments_by
=
2
;
int
payload_size_increments_by
=
2
;
int
next_payload_size
=
min_payload_size
;
char
receive_payload
[
max_payload_size
+
1
];
// +1 to allow room for a terminating NULL char
...
...
@@ -169,9 +169,9 @@ void setup(void)
// We will be using the Ack Payload feature, so please enable it
radio
.
enableAckPayload
();
// Config 2 is special radio config
if
(
configuration
==
'2'
)
{
// Config 2 is special radio config
radio
.
setCRCLength
(
RF24_CRC_8
);
radio
.
setDataRate
(
RF24_2MBPS
);
radio
.
setChannel
(
10
);
...
...
@@ -189,9 +189,19 @@ void setup(void)
// Optional: Pick a high channel
radio
.
setChannel
(
90
);
}
// enable dynamic payloads
radio
.
enableDynamicPayloads
();
// Config 3 is static payloads only
if
(
configuration
==
'3'
)
{
next_payload_size
=
max_payload_size
;
payload_size_increments_by
=
0
;
radio
.
setPayloadSize
(
16
);
}
else
{
// enable dynamic payloads
radio
.
enableDynamicPayloads
();
}
//
// Open pipes to other nodes for communication
...
...
@@ -331,7 +341,7 @@ void check_radio(void)
// is this ack what we were expecting? to account
// for failures, we simply want to make sure we get a
// DIFFERENT ack every time.
if
(
message_count
!=
last_message_count
)
if
(
(
message_count
!=
last_message_count
)
||
(
configuration
==
'3'
&&
message_count
==
16
)
)
{
printf
(
"OK "
);
one_ok
();
...
...
@@ -347,13 +357,19 @@ void check_radio(void)
if
(
role
==
role_receiver
)
{
// Get this payload and dump it
size_t
len
=
radio
.
getDynamicPayloadSize
();
size_t
len
=
max_payload_size
;
memset
(
receive_payload
,
0
,
max_payload_size
);
if
(
configuration
!=
'3'
)
len
=
radio
.
getDynamicPayloadSize
();
radio
.
read
(
receive_payload
,
len
);
// Put a zero at the end for easy printing
receive_payload
[
len
]
=
0
;
// Spew it
len
=
strlen
(
receive_payload
);
// How much did we REALLY get?
printf
(
"Got payload size=%i value=%s
\n\r
"
,
len
,
receive_payload
);
// Add an ack packet for the next time around.
...
...
tests/pingpair_test/runtests.sh
View file @
d436895f
...
...
@@ -3,6 +3,9 @@
# Connect p6 to receiver, p4 to sender
jam p4 p6
||
exit
1
./runtest.py /dev/tty.usbserial-A600eHIs 3 &
./runtest.py /dev/tty.usbserial-A40081RP 3
||
exit
1
kill
`
jobs
-p
`
./runtest.py /dev/tty.usbserial-A600eHIs 1 &
./runtest.py /dev/tty.usbserial-A40081RP 1
||
exit
1
kill
`
jobs
-p
`
...
...
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