Commit 848852f4 authored by Marlene Böhmer's avatar Marlene Böhmer

Uart tests.

parent 32f243a1
......@@ -3,3 +3,4 @@ rna.img.xz
__pycache__/
*.pyc
*.log
*.idea
Subproject commit 3fa5b30c21eb52b5d6bf88a63b4955d5977fbb60
Subproject commit f90654e7b29d4e7116907a22452b692dae6a930f
include:
- drone.scripts
pigpio:
pkg.installed
python-pigpio:
pkg.installed
python3-pigpio:
pkg.installed
python3-setuptools:
pkg.installed
......@@ -30,12 +39,3 @@ cf_lib_build:
- file: cf_lib_repro
- require:
- file: cf_lib_repro
flightscripts:
file.managed:
- name: /home/rna/flightscript.py
- source: salt://drone/flightscript.py
- user: rna
- group: rna
- mode: 777
- template: jinja
Subproject commit 88b67a1e5bda00e6c35015fdf845a84f34308f95
Subproject commit 31b6b3d7abce34da197542b97db567447ade281d
scripts_folder:
file.recurse:
- name: /home/rna/drone_scripts
- source: salt://drone/scripts
- clean: True
- user: rna
- group: rna
- file_mode: keep
#!/usr/bin/python
import time
import pigpio
I2C_ADDR=0x22 # 34
def i2c(id, tick):
global pi
s, b, d = pi.bsc_i2c(I2C_ADDR)
print("status={:021b} received={} {}".format(s, b, list(d)))
pi = pigpio.pi()
if not pi.connected:
exit()
# Respond to BSC slave activity
e = pi.event_callback(pigpio.EVENT_BSC, i2c)
pi.bsc_i2c(I2C_ADDR) # Configure BSC as I2C slave
time.sleep(3600)
e.cancel()
pi.bsc_i2c(0) # Disable BSC peripheral
pi.stop()
#!/usr/bin/python
import serial
from time import sleep
ser = serial.Serial("/dev/ttyS0", 115200) # Open port with baud rate
while True:
# received_data = ser.read() # read serial port
# sleep(0.03)
# data_left = ser.inWaiting() # check for remaining byte
# received_data += ser.read(data_left)
# print(list(received_data)) # print received data
# ser.write(received_data) # transmit data serially
data_left = 1
received_data = ""
while data_left:
received_data += ser.read()
sleep(0.003)
data_left = ser.inWaiting()
print(list(received_data))
I2C:
sudo apt-get install pigpio python-pigpio python3-pigpio
sudo systemctl enable pigpiod.service
Change priority:
Add
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=
to [Service] in /lib/systemd/system/pigpiod.service
sudo systemctl daemon-reload
sudo systemctl restart pigpiod.service
UART:
sudo apt-get install minicom
/boot/config.txt: enable_uart=1
raspi-config: Serial->disable Login Shell
sudo usermod -a -G dialout rna
minicom -b 9600 -H -o -D /dev/ttyS0
sudo apt-get install python-serial
Subproject commit 21cf5e5fa0eea429f79ad2603291cc894842563f
Subproject commit 2b56799041960c0c770ed8627e02ff25389bd941
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment