athena: detect no prime (#21718)

* detect no prime

* show in sidebar

* revert timeout

* clear ping param

* fix typo

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 7b94cf0ca7
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent 79eb9d9b9f
commit e8161a42ee
  1. 16
      selfdrive/athena/athenad.py
  2. 3
      selfdrive/common/params.cc
  3. 13
      selfdrive/ui/qt/sidebar.cc
  4. 2
      selfdrive/ui/qt/sidebar.h

@ -29,7 +29,7 @@ from selfdrive.hardware import HARDWARE, PC, TICI
from selfdrive.loggerd.config import ROOT from selfdrive.loggerd.config import ROOT
from selfdrive.loggerd.xattr_cache import getxattr, setxattr from selfdrive.loggerd.xattr_cache import getxattr, setxattr
from selfdrive.swaglog import cloudlog, SWAGLOG_DIR from selfdrive.swaglog import cloudlog, SWAGLOG_DIR
from selfdrive.version import get_version, get_git_remote, get_git_branch, get_git_commit from selfdrive.version import version, get_version, get_git_remote, get_git_branch, get_git_commit
ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai') ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai')
HANDLER_THREADS = int(os.getenv('HANDLER_THREADS', "4")) HANDLER_THREADS = int(os.getenv('HANDLER_THREADS', "4"))
@ -493,6 +493,7 @@ def main():
enable_multithread=True, enable_multithread=True,
timeout=30.0) timeout=30.0)
cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri)
params.delete("PrimeRedirected")
manage_tokens(api) manage_tokens(api)
@ -502,13 +503,22 @@ def main():
break break
except (ConnectionError, TimeoutError, WebSocketException): except (ConnectionError, TimeoutError, WebSocketException):
conn_retries += 1 conn_retries += 1
params.delete("PrimeRedirected")
params.delete("LastAthenaPingTime")
except socket.timeout:
try:
r = requests.get("http://api.commadotai.com/v1/me", allow_redirects=False,
headers={"User-Agent": f"openpilot-{version}"}, timeout=15.0)
if r.status_code == 302 and r.headers['Location'].startswith("http://u.web2go.com"):
params.put_bool("PrimeRedirected", True)
except Exception:
cloudlog.exception("athenad.socket_timeout.exception")
params.delete("LastAthenaPingTime") params.delete("LastAthenaPingTime")
if TICI:
cloudlog.exception("athenad.main.exception2")
except Exception: except Exception:
cloudlog.exception("athenad.main.exception") cloudlog.exception("athenad.main.exception")
conn_retries += 1 conn_retries += 1
params.delete("PrimeRedirected")
params.delete("LastAthenaPingTime") params.delete("LastAthenaPingTime")
time.sleep(backoff(conn_retries)) time.sleep(backoff(conn_retries))

@ -186,7 +186,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"IsTakingSnapshot", CLEAR_ON_MANAGER_START}, {"IsTakingSnapshot", CLEAR_ON_MANAGER_START},
{"IsUpdateAvailable", CLEAR_ON_MANAGER_START}, {"IsUpdateAvailable", CLEAR_ON_MANAGER_START},
{"UploadRaw", PERSISTENT}, {"UploadRaw", PERSISTENT},
{"LastAthenaPingTime", PERSISTENT}, {"LastAthenaPingTime", CLEAR_ON_MANAGER_START},
{"LastGPSPosition", PERSISTENT}, {"LastGPSPosition", PERSISTENT},
{"LastUpdateException", PERSISTENT}, {"LastUpdateException", PERSISTENT},
{"LastUpdateTime", PERSISTENT}, {"LastUpdateTime", PERSISTENT},
@ -199,6 +199,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"PandaFirmwareHex", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"PandaFirmwareHex", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
{"PandaDongleId", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"PandaDongleId", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
{"Passive", PERSISTENT}, {"Passive", PERSISTENT},
{"PrimeRedirected", PERSISTENT},
{"RecordFront", PERSISTENT}, {"RecordFront", PERSISTENT},
{"RecordFrontLock", PERSISTENT}, // for the internal fleet {"RecordFrontLock", PERSISTENT}, // for the internal fleet
{"ReleaseNotes", PERSISTENT}, {"ReleaseNotes", PERSISTENT},

@ -62,11 +62,16 @@ void Sidebar::updateState(const UIState &s) {
auto last_ping = deviceState.getLastAthenaPingTime(); auto last_ping = deviceState.getLastAthenaPingTime();
if (last_ping == 0) { if (last_ping == 0) {
setProperty("connectStr", "OFFLINE"); if (params.getBool("PrimeRedirected")) {
setProperty("connectStatus", warning_color); setProperty("connectStr", "NO\nPRIME");
setProperty("connectStatus", danger_color);
} else {
setProperty("connectStr", "CONNECT\nOFFLINE");
setProperty("connectStatus", warning_color);
}
} else { } else {
bool online = nanos_since_boot() - last_ping < 80e9; bool online = nanos_since_boot() - last_ping < 80e9;
setProperty("connectStr", online ? "ONLINE" : "ERROR"); setProperty("connectStr", (online ? "CONNECT\nONLINE" : "CONNECT\nERROR"));
setProperty("connectStatus", online ? good_color : danger_color); setProperty("connectStatus", online ? good_color : danger_color);
} }
@ -121,5 +126,5 @@ void Sidebar::paintEvent(QPaintEvent *event) {
// metrics // metrics
drawMetric(p, "TEMP", QString("%1°C").arg(temp_val), temp_status, 338); drawMetric(p, "TEMP", QString("%1°C").arg(temp_val), temp_status, 338);
drawMetric(p, panda_str, "", panda_status, 518); drawMetric(p, panda_str, "", panda_status, 518);
drawMetric(p, "CONNECT\n" + connect_str, "", connect_status, 676); drawMetric(p, connect_str, "", connect_status, 676);
} }

@ -3,6 +3,7 @@
#include <QFrame> #include <QFrame>
#include <QMap> #include <QMap>
#include "selfdrive/common/params.h"
#include "selfdrive/ui/ui.h" #include "selfdrive/ui/ui.h"
class Sidebar : public QFrame { class Sidebar : public QFrame {
@ -49,6 +50,7 @@ private:
const QColor warning_color = QColor(218, 202, 37); const QColor warning_color = QColor(218, 202, 37);
const QColor danger_color = QColor(201, 34, 49); const QColor danger_color = QColor(201, 34, 49);
Params params;
QString connect_str = "OFFLINE"; QString connect_str = "OFFLINE";
QColor connect_status = warning_color; QColor connect_status = warning_color;
QString panda_str = "NO\nPANDA"; QString panda_str = "NO\nPANDA";

Loading…
Cancel
Save