openpilot v0.8.8 release

This commit is contained in:
Vehicle Researcher
2021-08-22 22:13:11 -07:00
parent 444aace15f
commit baffaeee93
193 changed files with 60566 additions and 1933 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const ch
return prg;
}
// Given a cl code and return a string represenation
// Given a cl code and return a string representation
#define CL_ERR_TO_STR(err) case err: return #err
const char* cl_get_error_string(int err) {
switch (err) {
+1 -1
View File
@@ -11,7 +11,7 @@
#define CL_CHECK(_expr) \
do { \
assert(CL_SUCCESS == _expr); \
assert(CL_SUCCESS == (_expr)); \
} while (0)
#define CL_CHECK_ERR(_expr) \
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
const int TRAJECTORY_SIZE = 33;
const int LON_MPC_N = 32;
const int LAT_MPC_N = 16;
const int LON_MPC_N = 32;
const float MIN_DRAW_DISTANCE = 10.0;
const float MAX_DRAW_DISTANCE = 100.0;
+10 -15
View File
@@ -33,10 +33,6 @@
namespace {
const std::string default_params_path = Hardware::PC() ? util::getenv_default("HOME", "/.comma/params", "/data/params")
: "/data/params";
const std::string persistent_params_path = Hardware::PC() ? default_params_path : "/persist/comma/params";
volatile sig_atomic_t params_do_exit = 0;
void params_sig_handler(int signal) {
params_do_exit = 1;
@@ -78,7 +74,7 @@ int mkdir_p(std::string path) {
return 0;
}
static bool create_params_path(const std::string &param_path, const std::string &key_path) {
bool create_params_path(const std::string &param_path, const std::string &key_path) {
// Make sure params path exists
if (!util::file_exists(param_path) && mkdir_p(param_path) != 0) {
return false;
@@ -117,7 +113,7 @@ static bool create_params_path(const std::string &param_path, const std::string
return chmod(key_path.c_str(), 0777) == 0;
}
static void ensure_params_path(const std::string &params_path) {
void ensure_params_path(const std::string &params_path) {
if (!create_params_path(params_path, params_path + "/d")) {
throw std::runtime_error(util::string_format("Failed to ensure params path, errno=%d", errno));
}
@@ -198,6 +194,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"PandaFirmware", 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},
{"PandaHeartbeatLost", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
{"Passive", PERSISTENT},
{"PrimeRedirected", PERSISTENT},
{"RecordFront", PERSISTENT},
@@ -231,15 +228,13 @@ std::unordered_map<std::string, uint32_t> keys = {
} // namespace
Params::Params(bool persistent_param) : Params(persistent_param ? persistent_params_path : default_params_path) {}
Params::Params() : params_path(Path::params()) {
static std::once_flag once_flag;
std::call_once(once_flag, ensure_params_path, params_path);
}
std::once_flag default_params_path_ensured;
Params::Params(const std::string &path) : params_path(path) {
if (path == default_params_path) {
std::call_once(default_params_path_ensured, ensure_params_path, path);
} else {
ensure_params_path(path);
}
ensure_params_path(params_path);
}
bool Params::checkKey(const std::string &key) {
@@ -331,12 +326,12 @@ std::string Params::get(const char *key, bool block) {
}
}
int Params::readAll(std::map<std::string, std::string> *params) {
std::map<std::string, std::string> Params::readAll() {
FileLock file_lock(params_path + "/.lock", LOCK_SH);
std::lock_guard<FileLock> lk(file_lock);
std::string key_path = params_path + "/d";
return util::read_files_in_dir(key_path, params);
return util::read_files_in_dir(key_path);
}
void Params::clearAll(ParamKeyType key_type) {
+6 -6
View File
@@ -13,15 +13,12 @@ enum ParamKeyType {
CLEAR_ON_IGNITION_ON = 0x10,
CLEAR_ON_IGNITION_OFF = 0x20,
DONT_LOG = 0x40,
ALL = 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40
ALL = 0xFFFFFFFF
};
class Params {
private:
std::string params_path;
public:
Params(bool persistent_param = false);
Params();
Params(const std::string &path);
bool checkKey(const std::string &key);
@@ -35,7 +32,7 @@ public:
void clearAll(ParamKeyType type);
// read all values
int readAll(std::map<std::string, std::string> *params);
std::map<std::string, std::string> readAll();
// helpers for reading values
std::string get(const char *key, bool block = false);
@@ -78,4 +75,7 @@ public:
inline int putBool(const std::string &key, bool val) {
return putBool(key.c_str(), val);
}
private:
const std::string params_path;
};
+1 -1
View File
@@ -31,7 +31,7 @@ void cloudlog_bind(const char* k, const char* v);
\
if (__begin + __millis*1000000ULL < __ts) { \
if (__missed) { \
cloudlog(CLOUDLOG_WARNING, "cloudlog: %d messages supressed", __missed); \
cloudlog(CLOUDLOG_WARNING, "cloudlog: %d messages suppressed", __missed); \
} \
__begin = 0; \
__printed = 0; \
+22 -17
View File
@@ -1,5 +1,7 @@
#include "selfdrive/common/util.h"
#include <sys/stat.h>
#include <cassert>
#include <cerrno>
#include <cstring>
@@ -76,19 +78,20 @@ std::string read_file(const std::string& fn) {
return std::string();
}
int read_files_in_dir(const std::string &path, std::map<std::string, std::string> *contents) {
std::map<std::string, std::string> read_files_in_dir(const std::string &path) {
std::map<std::string, std::string> ret;
DIR *d = opendir(path.c_str());
if (!d) return -1;
if (!d) return ret;
struct dirent *de = NULL;
while ((de = readdir(d))) {
if (isalnum(de->d_name[0])) {
(*contents)[de->d_name] = util::read_file(path + "/" + de->d_name);
ret[de->d_name] = util::read_file(path + "/" + de->d_name);
}
}
closedir(d);
return 0;
return ret;
}
int write_file(const char* path, const void* data, size_t size, int flags, mode_t mode) {
@@ -112,17 +115,23 @@ std::string readlink(const std::string &path) {
}
bool file_exists(const std::string& fn) {
std::ifstream f(fn);
return f.good();
struct stat st = {};
return stat(fn.c_str(), &st) != -1;
}
std::string getenv_default(const char* env_var, const char * suffix, const char* default_val) {
const char* env_val = getenv(env_var);
if (env_val != NULL) {
return std::string(env_val) + std::string(suffix);
} else {
return std::string(default_val);
}
std::string getenv(const char* key, const char* default_val) {
const char* val = ::getenv(key);
return val ? val : default_val;
}
int getenv(const char* key, int default_val) {
const char* val = ::getenv(key);
return val ? atoi(val) : default_val;
}
float getenv(const char* key, float default_val) {
const char* val = ::getenv(key);
return val ? atof(val) : default_val;
}
std::string tohex(const uint8_t *buf, size_t buf_size) {
@@ -155,10 +164,6 @@ std::string dir_name(std::string const &path) {
return path.substr(0, pos);
}
bool is_valid_dongle_id(std::string const& dongle_id) {
return !dongle_id.empty() && dongle_id != "UnregisteredDevice";
}
struct tm get_time() {
time_t rawtime;
time(&rawtime);
+5 -7
View File
@@ -41,10 +41,6 @@ T map_val(T x, T a1, T a2, T b1, T b2) {
// ***** string helpers *****
inline bool starts_with(const std::string& s, const std::string& prefix) {
return s.compare(0, prefix.size(), prefix) == 0;
}
template <typename... Args>
std::string string_format(const std::string& format, Args... args) {
size_t size = snprintf(nullptr, 0, format.c_str(), args...) + 1;
@@ -53,16 +49,18 @@ std::string string_format(const std::string& format, Args... args) {
return std::string(buf.get(), buf.get() + size - 1);
}
std::string getenv_default(const char* env_var, const char* suffix, const char* default_val);
std::string getenv(const char* key, const char* default_val = "");
int getenv(const char* key, int default_val);
float getenv(const char* key, float default_val);
std::string tohex(const uint8_t* buf, size_t buf_size);
std::string hexdump(const std::string& in);
std::string base_name(std::string const& path);
std::string dir_name(std::string const& path);
bool is_valid_dongle_id(std::string const& dongle_id);
// **** file fhelpers *****
std::string read_file(const std::string& fn);
int read_files_in_dir(const std::string& path, std::map<std::string, std::string>* contents);
std::map<std::string, std::string> read_files_in_dir(const std::string& path);
int write_file(const char* path, const void* data, size_t size, int flags = O_WRONLY, mode_t mode = 0777);
std::string readlink(const std::string& path);
bool file_exists(const std::string& fn);
+1 -1
View File
@@ -1 +1 @@
#define COMMA_VERSION "0.8.7"
#define COMMA_VERSION "0.8.8"