Skip to content

Commit

Permalink
Add command to restart openpilot without rebooting (#51)
Browse files Browse the repository at this point in the history
* Start emu debug reload command

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* add reload alias

* changelog

* debug
  • Loading branch information
sshane authored Apr 18, 2021
1 parent 922422f commit c2eb5b0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 0.1.16 (2021-04-15)
=====

* Add `emu debug reload` (or simply `reload`) command to restart openpilot without needing to reboot your device.


Release 0.1.15 (2021-04-11)
=====

Expand Down
1 change: 1 addition & 0 deletions aliases.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
alias ll="ls -lAh"
alias pf="emu panda flash"
alias controlsd="emu debug controlsd"
alias reload="emu debug reload"
alias battery="emu device battery"
alias shutdown="emu device shutdown"
alias settings="emu device settings"
Expand Down
32 changes: 28 additions & 4 deletions commands/debug/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from commands.base import CommandBase, Command, Flag
from py_utils.emu_utils import run, kill, warning, error
from py_utils.colors import COLORS
from py_utils.emu_utils import run, kill, warning, check_output, is_affirmative, error, info, success
from py_utils.emu_utils import OPENPILOT_PATH


Expand All @@ -12,12 +13,35 @@ def __init__(self):
self.description = 'de-🐛-ing tools'

self.commands = {'controlsd': Command(description='🔬 logs controlsd to /data/output.log by default',
flags=[Flag(['-o', '--output'], 'Name of file to save log to', dtype='str')])}
self.default_path = '/data/output.log'
flags=[Flag(['-o', '--output'], 'Name of file to save log to', dtype='str')]),
'reload': Command(description='🔄 kills the current openpilot session and restarts it (all without rebooting)')}

@staticmethod
def _reload():
info('This will kill the current openpilot tmux session, set up a new one, and relaunch openpilot.')
info('Confirm you would like to continue')
if not is_affirmative():
error('Aborting!')
return

r = check_output('tmux kill-session -t comma')
if r.success:
info('Killed the current openpilot session')
else:
warning('Error killing current openpilot session, continuing...')

# Command below thanks to mlp
r = check_output(['tmux', 'new', '-s', 'comma', '-d',
"echo $$ > /dev/cpuset/app/tasks;" # add pid of current shell to app cpuset
"echo $PPID > /dev/cpuset/app/tasks;" # (our parent, tmux, also gets all the cores)
"/data/openpilot/launch_openpilot.sh"])
if r.success:
success('Succesfully started a new tmux session for openpilot!')
success('Type {}tmux a{} to attach to it'.format(COLORS.FAIL, COLORS.SUCCESS))

def _controlsd(self):
out_file = '/data/output.log'
flags = self.get_flags('controlsd')
out_file = self.default_path
if flags.output is not None:
out_file = flags.output
# r = run('pkill -f controlsd') # terminates file for some reason # todo: remove me if not needed
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ COMMUNITY_BASHRC_PATH=/data/community/.bashrc
OH_MY_COMMA_PATH=/data/community/.oh-my-comma
GIT_BRANCH_NAME=master
GIT_REMOTE_URL=https://github.com/emu-sh/.oh-my-comma.git
OMC_VERSION=0.1.14
OMC_VERSION=0.1.16

install_echo() { # only prints if not updating
if [ "$update" != true ]; then
Expand Down

0 comments on commit c2eb5b0

Please sign in to comment.