Skip to content

Commit 96a3997

Browse files
committed
added rasberry pi 3 example
1 parent c16efa6 commit 96a3997

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

raspi_example_main.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from pjon_python.base_client import PjonBaseSerialClient
2+
import time
3+
4+
# load serial2pjon_proxy_v5_1 to arduino
5+
# adjust serial port below to match your arduino's port
6+
# run this example; expected output:
7+
#
8+
# pakets in outgoing queue: 0
9+
# received from 35 payload: [66, 49, 50, 51, 52, 53, 54, 55, 56, 57]
10+
# pakets in outgoing queue: 0
11+
# pakets in outgoing queue: 0
12+
# received from 35 payload: [66, 49, 50, 51, 52, 53, 54, 55, 56, 57]
13+
# pakets in outgoing queue: 0
14+
#
15+
16+
cli = PjonBaseSerialClient(1, '/dev/ttyUSB1', write_timeout=0.005, timeout=0.005)
17+
18+
19+
def error_handler(self, error_code=0, parameter=0):
20+
error_text = "code: %s, parameter: %s" % (error_code, parameter)
21+
if error_code == 101:
22+
error_text = "connection lost to node: %s" % parameter
23+
elif error_code == 101:
24+
error_text = "outgoing buffer full"
25+
26+
if error_code > 0:
27+
print(error_text)
28+
29+
def receive_handler(payload, packet_length, packet_info):
30+
print "received from %s payload: %s" % (packet_info.sender_id, payload)
31+
32+
cli.set_receive(receive_handler)
33+
cli.set_error(error_handler)
34+
cli.start_client()
35+
36+
while True:
37+
print "pakets in outgoing queue: %s" % cli.send(35, "C123")
38+
time.sleep(.1)

0 commit comments

Comments
 (0)