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

python scripts for Python3; adapt salt drone init script.

parent cbff1d73
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
Subproject commit eb6be503ae753cdb5f3627daa89e9e7d9f23b790
+2 −8
Original line number Diff line number Diff line
include:
    - drone.scripts

pigpio:
    pkg.installed

python-pigpio:
    pkg.installed

python3-pigpio:
python3-serial:
    pkg.installed

python3-setuptools:
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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)
+7 −6
Original line number Diff line number Diff line
@@ -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)