diff --git a/README.md b/README.md index df47cc3..bed8b6b 100644 --- a/README.md +++ b/README.md @@ -99,65 +99,24 @@ The RasPi will need the following things install so it can talk to your motors a - `cozmo_tts` - `google_cloud` -## Setting up your start_robot file on the Raspberry Pi +## Setting up the remotv service on the Raspberry Pi -1. Copy the `start_robot` script to your home directory. +1. Link the service file to systemctl ```sh - cp ~/remotv/scripts/start_robot ~ + sudo systemctl link /home/pi/remotv/script/remotv.service ``` -2. Add the startup script to the `crontab` +2. Enable the service to run at startup ```sh - crontab -e + sudo systemctl enable remotv.service ``` - Note: If you accidently use the wrong editor try +3. Start the service ```sh - EDITOR=nano crontab -e - ``` - -3. Insert the following text at the bottom - - ```sh - @reboot /bin/bash /home/pi/start_robot - ``` - - Example: - - ```sh - # Edit this file to introduce tasks to be run by cron. - # - # Each task to run has to be defined through a single line - # indicating with different fields when the task will be run - # and what command to run for the task - # - # To define the time you can provide concrete values for - # minute (m), hour (h), day of month (dom), month (mon), - # and day of week (dow) or use '*' in these fields (for 'any').# - # Notice that tasks will be started based on the cron's system - # daemon's notion of time and timezones. - # - # Output of the crontab jobs (including errors) is sent through - # email to the user the crontab file belongs to (unless redirected). - # - # For example, you can run a backup of all your user accounts - # at 5 a.m every week with: - # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ - # - # For more information see the manual pages of crontab(5) and cron(8) - # - # m h dom mon dow command - - @reboot /bin/bash /home/pi/start_robot - ``` - -4. Now just plug in the Camera and USB Speaker and reboot - - ```sh - sudo reboot + sudo systemctl start remotv.service ``` # Hardware Compatibility diff --git a/controller.py b/controller.py index aa66381..00ef34f 100755 --- a/controller.py +++ b/controller.py @@ -132,7 +132,7 @@ def write(self, config_file): log.setLevel(logging.DEBUG) console_handler=logging.StreamHandler() console_handler.setLevel(logging.getLevelName(robot_config.get('logging', 'console_level'))) -console_formatter=logging.Formatter('%(asctime)s - %(filename)s : %(message)s','%H:%M:%S') +console_formatter=logging.Formatter('%(asctime)s - %(filename)s[%(lineno)d]: %(message)s','%H:%M:%S') console_handler.setFormatter(console_formatter) try: file_handler=logging.handlers.RotatingFileHandler(robot_config.get('logging', 'log_file'), @@ -245,6 +245,9 @@ def handle_message(ws, message): elif event == "ROBOT_VALIDATED": networking.handleConnectChatChannel(data["host"]) + elif event == "SEND_CHAT": + pass + else: log.error("Unknown event type") diff --git a/controller.sample.conf b/controller.sample.conf index 41aaeec..53b9c00 100644 --- a/controller.sample.conf +++ b/controller.sample.conf @@ -149,7 +149,7 @@ boot_message=ok announce_ip=False # Announces when the cloned repo is out of date and by how many commits. -annouce_out_of_date=False +announce_out_of_date=False # Enable delayed TTS, this allows a window for moderators to remove messages # before they get passed to TTS. Messenger must be enabled for this to function. diff --git a/networking.py b/networking.py index 0959298..4a77c29 100644 --- a/networking.py +++ b/networking.py @@ -156,7 +156,7 @@ def setupWebSocket(robot_config, onHandleMessage): log.info("staring websocket listen process") startListenForWebSocket() - schedule.single_task(5, checkWebSocket) + schedule.single_task(10, checkWebSocket) if robot_config.getboolean('misc', 'check_internet'): #schedule a task to check internet status diff --git a/scripts/remo.service b/scripts/remo.service new file mode 100644 index 0000000..9be3bac --- /dev/null +++ b/scripts/remo.service @@ -0,0 +1,17 @@ +[Unit] +After=network.target +Description=Remo.Tv startup script +Documentation=https://docs.remo.tv + +[Install] +WantedBy=multi-user.target + +[Service] +ExecStart=/usr/bin/python2 /home/pi/remotv/controller.py +Restart=on-failure +RestartSec=1 +StartLimitBurst=5 +StartLimitInterval=60 +SyslogIdentifier=remo-controller +Type=simple +WorkingDirectory=/home/pi/remotv