diff --git a/Drone/client.py b/Drone/client.py index b129aea..f939ac5 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -1,4 +1,5 @@ from __future__ import print_function +import os import sys import socket import struct @@ -277,6 +278,8 @@ try: print("Command from server:", command, args) if command == "writefile": recive_file(args['filename']) + if bool(args['clever_restart']): + os.system("systemctl restart clever") elif command == 'config_write': write_to_config(args['section'], args['option'], args['value']) elif command == 'config_reload': diff --git a/Drone/client_setup.sh b/Drone/client_setup.sh index 9906478..e188f57 100755 --- a/Drone/client_setup.sh +++ b/Drone/client_setup.sh @@ -4,6 +4,11 @@ # $3 - hostname of rpi # $4 - server ip +if [ $(whoami) != "root" ]; then + echo -e "\nThis should be run as root!\n" + exit 1 +fi + # check if enough arguments if [[ $# -ne 4 ]] ; then echo -e "\nPlease, enter arguments: router ssid, wifi password, copter id and server ip" @@ -82,14 +87,14 @@ if ! [ -f "/home/pi/catkin_ws/src/clever/aruco_pose/map/animation_map.txt" ] ; t fi # install samba and winbind (for hostname resolving) -apt-get -y install samba -apt-get -y install winbind +# apt-get -y install samba +# apt-get -y install winbind # set /etc/nsswitch.conf sed -i '/hosts:/c hosts: files dns wins' /etc/nsswitch.conf # install chrony (for time syncing) -apt-get -y install chrony +# apt-get -y install chrony # configure chrony as client cat << EOF | tee /etc/chrony/chrony.conf diff --git a/Server/server.py b/Server/server.py index feb3422..6d22cec 100644 --- a/Server/server.py +++ b/Server/server.py @@ -344,10 +344,10 @@ class Client: return self._request_queue.pop(requested_value) @requires_connect - def send_file(self, filepath, dest_filename): + def send_file(self, filepath, dest_filename, clever_restart = False): print("Sending file ", dest_filename) chunk_count = math.ceil(os.path.getsize(filepath) / Server.BUFFER_SIZE) - self.send(Client.form_message("writefile", {"filesize": chunk_count, "filename": dest_filename})) + self.send(Client.form_message("writefile", {"filesize": chunk_count, "filename": dest_filename, "clever_restart": clever_restart})) with open(filepath, 'rb') as file: chunk = file.read(Server.BUFFER_SIZE) while chunk: diff --git a/Server/server_qt.py b/Server/server_qt.py index a9f5dbd..161a34b 100644 --- a/Server/server_qt.py +++ b/Server/server_qt.py @@ -181,7 +181,7 @@ class MainWindow(QtWidgets.QMainWindow): item = model.item(row_num, 0) if item.isCheckable() and item.checkState() == Qt.Checked: copter = Client.get_by_id(item.text()) - copter.send_file(path, "/home/pi/catkin_ws/src/clever/aruco_pose/map/animation_map.txt") + copter.send_file(path, "/home/pi/catkin_ws/src/clever/aruco_pose/map/animation_map.txt", clever_restart=True) model = QStandardItemModel() @@ -198,7 +198,7 @@ def client_connected(self: Client): model.appendRow((copter_id_item, )) -Client.on_connect = client_connected +Client.on_first_connect = client_connected if __name__ == "__main__": diff --git a/builder/image-software.sh b/builder/image-software.sh index 26b442d..a6cb98a 100755 --- a/builder/image-software.sh +++ b/builder/image-software.sh @@ -53,6 +53,9 @@ my_travis_retry() { return $result } +echo_stamp "Change repo owner to pi" +chown -Rf pi:pi /home/pi/CleverSwarm/ + echo_stamp "Update apt cache" apt-get update -qq