|
8 | 8 |
|
9 | 9 | * Adafruit_BBIO supports Linux kernels 3.8 through 4.14 |
10 | 10 |
|
11 | | -* New versions of Adafruit_BBIO may break backwards compility. Please read the [changelog](CHANGELOG.md). |
| 11 | +* New versions of Adafruit_BBIO may break backwards compatibility. Please read the [changelog](CHANGELOG.md). |
12 | 12 |
|
13 | | -## Installation on Debian** |
| 13 | +## Installation on Debian |
14 | 14 |
|
15 | 15 | Easiest: |
16 | 16 | ``` |
@@ -132,16 +132,47 @@ Detecting events: |
132 | 132 | #read_raw returns non-normalized value |
133 | 133 | value = ADC.read_raw("P9_40") |
134 | 134 |
|
| 135 | +### [UART](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart) |
| 136 | +* Use [`config-pin` to set pin mode](https://github.com/beagleboard/bb.org-overlays/tree/master/tools/beaglebone-universal-io) for [UART1 and UART2 pins](http://beagleboard.org/static/images/cape-headers-serial.png) |
| 137 | +``` |
| 138 | +config-pin P9.21 uart # UART2_TXD |
| 139 | +config-pin P9.22 uart # UART2_RXD |
| 140 | +config-pin P9.24 uart # UART1_TXD |
| 141 | +config-pin P9.26 uart # UART1_RXD |
| 142 | +``` |
| 143 | +* [Install pyserial](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart#using-uart-with-python) |
| 144 | +``` |
| 145 | +sudo pip install pyserial |
| 146 | +``` |
| 147 | +* [Test UART1](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart#using-uart-with-python) |
| 148 | +``` |
| 149 | +import Adafruit_BBIO.UART as UART |
| 150 | +import serial |
| 151 | +
|
| 152 | +UART.setup("UART1") |
| 153 | +
|
| 154 | +ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600) |
| 155 | +ser.close() |
| 156 | +ser.open() |
| 157 | +if ser.isOpen(): |
| 158 | + print "Serial is open!" |
| 159 | + ser.write("Hello World!") |
| 160 | +ser.close() |
| 161 | +``` |
| 162 | +* [Loopback test with UART1 and UART2](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart#testing-and-using-the-uart) |
| 163 | + |
135 | 164 | ## Running tests |
136 | 165 |
|
137 | 166 | Install py.test to run the tests. You'll also need the python compiler package for pytest: |
138 | | - |
139 | | - pip install -U pytest |
140 | | - |
| 167 | +``` |
| 168 | +sudo pip install pytest |
| 169 | +``` |
141 | 170 | Execute the following in the root of the project: |
| 171 | +``` |
| 172 | +sudo pytest |
| 173 | +``` |
| 174 | +NOTE: `sudo` should not be required when running [Debian 9.2 "Stretch" iot (2017-10-29)](https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#microSD.2FStandalone:_.28stretch-iot.29_.28All_BeagleBone_Variants_.26_PocketBeagle.29) with [Linux kernel](https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Kernel_Options) [4.14.x](https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Mainline_.284.14.x_lts.29) as udev configures group ownership and permission for [GPIO](https://github.com/rcn-ee/repos/blob/master/bb-customizations/suite/stretch/debian/80-gpio-noroot.rules) and [PWM](https://github.com/rcn-ee/repos/blob/master/bb-customizations/suite/stretch/debian/81-pwm-noroot.rules) |
142 | 175 |
|
143 | | - pytest |
144 | | - |
145 | 176 | ## Credits |
146 | 177 |
|
147 | 178 | The BeagleBone IO Python library was originally forked from the excellent MIT Licensed [RPi.GPIO](https://code.google.com/p/raspberry-gpio-python) library written by Ben Croston. |
|
0 commit comments