Skip to content

Commit

Permalink
+ temp.py for testing; adjust read/peek overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jul 24, 2021
1 parent bd01c62 commit 1195151
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
54 changes: 54 additions & 0 deletions RPi/pyRF24Network/examples/temp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import time, struct
import RF24 as pyRF24
import RF24Network as pyRF24Network

this_node = [
int(
input("What is this node's logical address? ") or 0,
8
)
]

other_node = [
int(
input("What is the target node's logical address? ") or 1,
8
)
]

radio = pyRF24.RF24(22, 0)
if not radio.begin():
print("radio mot respoding")

network = pyRF24Network.RF24Network(radio)
network.begin(90, this_node[0])

head_out = pyRF24Network.RF24NetworkHeader(other_node[0], 0)
head_in = pyRF24Network.RF24NetworkHeader()

def master(count=1, interval=1):
for _ in range(count):
msg = bytes(range(count)) # using dynamic payload sizes
count -= 1
print("message", msg, end=" ")
if network.write(head_out, msg):
print("sent successfully")
else:
print("failed to transmit")

def slave(timeout=10):
end_timer = time.monotonic() + timeout
while time.monotonic() <= end_timer:
# let SERIAL_DEBUG output do the printing to stdout
network.update()
# let dev do post-reception work in REPL (using `head_in`)

def print_details():
radio.printPrettyDetails()
print("node address\t:", oct(this_node[0]))

print("""\n
testing script for RF24Network python wrapper\n\n
run `master(<msg_count>)` to transmit\n
run `slave(<timeout_seconds>)` to receive"""
)
4 changes: 2 additions & 2 deletions RPi/pyRF24Network/pyRF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ BOOST_PYTHON_MODULE(RF24Network)
RF24Network_exposer.def("peek", peek_frame(&peek_read_wrap), (bp::arg("maxlen")));
}
{ //::RF24Network::peek (using optional maxlen param's default value)
typedef bp::tuple (*peek_frame)(::RF24Network &);
typedef bp::tuple (*peek_frame)(::RF24Network &, size_t);
RF24Network_exposer.def("peek", peek_frame(&peek_read_wrap));
}
{ //::RF24Network::read (using optional maxlen param's default value)
typedef bp::tuple (*read_function_type)(::RF24Network &);
typedef bp::tuple (*read_function_type)(::RF24Network &, size_t);
RF24Network_exposer.def("read", read_function_type(&read_wrap));
}
{ //::RF24Network::read
Expand Down

0 comments on commit 1195151

Please sign in to comment.