-
Notifications
You must be signed in to change notification settings - Fork 1
/
listen.py
34 lines (25 loc) · 844 Bytes
/
listen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
"""
listen.py
By Mike Furlotti, Damien Clark, Noah Zaitlen, and Benajmin Zaitlen
This example reads the Serial Port (UART 1) on BeagleBone connected to an XBee. The Raw RF Packet is the printed to
the screen.
"""
import serial, os
import sys
PORT = '/dev/ttyO1' #set tty port NOTE: ON BEAGLE BONE O1 is the Letter O
BAUD_RATE = 9600 #set baud rate
uart1_pin_mux = [
('uart1_rxd', ( 0 | (1<<5) )), # Bit 5 sets the receiver to enabled for RX Pin
('uart1_txd', ( 0 )), #no bits to be set for TX Pin
]
for (fname, mode) in uart1_pin_mux:
with open(os.path.join('/sys/kernel/debug/omap_mux', \
fname), 'wb') as f:
f.write("%X" % mode)
ser = serial.Serial(PORT, BAUD_RATE) #open serial port
count = 0
while True:
a = ser.read() #read byte
print count, a #print byte and count
count += 1