Commit ce577ca6 authored by Marlene Böhmer's avatar Marlene Böhmer

python scripts for Python3; adapt salt drone init script.

parent cbff1d73
......@@ -10,3 +10,6 @@
[submodule "salt/video/files/gst-prrt"]
path = salt/video/files/gst-prrt
url = git@git.nt.uni-saarland.de:LARN/gst-prrt.git
[submodule "salt/drone/crazyflie-lib-python"]
path = salt/drone/crazyflie-lib-python
url = git@git.nt.uni-saarland.de:s9meboeh/crazyflie-lib-python.git
Subproject commit eb6be503ae753cdb5f3627daa89e9e7d9f23b790
include:
- drone.scripts
pigpio:
python3-serial:
pkg.installed
python-pigpio:
pkg.installed
python3-pigpio:
pkg.installed
python3-setuptools:
pkg.installed
......@@ -25,7 +19,7 @@ cf_lib_dir:
cf_lib_repro:
file.recurse:
- name: /opt/crazyflie-lib-python
- source: salt://drone/my-crazyflie-lib-python
- source: salt://drone/crazyflie-lib-python
- clean: True
- user: rna
- group: rna
......
......@@ -11,7 +11,7 @@ import cflib.crtp
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.positioning.motion_commander import MotionCommander
URI = 'i2c://'
URI = 'serial://pi'
# Only output errors from the logging framework
logging.basicConfig(level=logging.ERROR)
......
......@@ -9,7 +9,7 @@ SYSLINK_RADIO_RAW = 0x00
received_data = []
ser = serial.Serial("/dev/ttyS0", 115200)
ser = serial.Serial(port="/dev/ttyS0", baudrate=115200)
def compute_cksum(list):
cksum0, cksum1 = 0, 0
......@@ -20,18 +20,19 @@ def compute_cksum(list):
while True:
received_data = map(ord, list(ser.read_until(chr(START_BYTE1)))[-1:])
received_data += map(ord, list(ser.read(1)))
received_data = bytearray()
received_data += ser.read_until(bytes([START_BYTE1]))[-1:]
received_data += ser.read(1)
if received_data[1] != START_BYTE2:
print("ERROR START")
continue
received_data += map(ord, list(ser.read(2)))
received_data += ser.read(2)
if received_data[3] > MTU:
print("ERROR LENGTH")
continue
received_data += map(ord, list(ser.read(received_data[3]+2)))
received_data += ser.read(received_data[3]+2)
cksum = compute_cksum(received_data[2:-2])
if cksum[0] != received_data[-2] or cksum[1] != received_data[-1]:
print("ERROR CKSUM")
......@@ -47,5 +48,5 @@ while True:
out_data += pk
out_data += compute_cksum(header+pk)
written = ser.write(bytearray(out_data))
written = ser.write(bytes(out_data))
print(written)
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