Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ env = Environment(
"ACADOS_PYTHON_INTERFACE_PATH": Dir("#third_party/acados/acados_template").abspath,
"TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer"
},
CC='clang',
CXX='clang++',
CCFLAGS=[
"-g",
"-fPIC",
"-O2",
"-Wunused",
"-Werror",
"-Wshadow",
"-Wshadow" if arch in ("Darwin", "larch64") else "-Wshadow=local",
"-Wno-unknown-warning-option",
"-Wno-inconsistent-missing-override",
"-Wno-c99-designator",
Expand Down Expand Up @@ -106,6 +104,8 @@ env = Environment(

# Arch-specific flags and paths
if arch == "larch64":
env["CC"] = "clang"
env["CXX"] = "clang++"
env.Append(LIBPATH=[
"/usr/local/lib",
"/system/vendor/lib64",
Expand Down Expand Up @@ -162,7 +162,7 @@ if os.environ.get('SCONS_PROGRESS'):
py_include = sysconfig.get_paths()['include']
envCython = env.Clone()
envCython["CPPPATH"] += [py_include, np.get_include()]
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-cpp", "-Wno-shadow", "-Wno-deprecated-declarations"]
envCython["CCFLAGS"].remove("-Werror")

envCython["LIBS"] = []
Expand Down
8 changes: 4 additions & 4 deletions common/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class OpenpilotPrefix {
auto param_path = Params().getParamPath();
if (util::file_exists(param_path)) {
std::string real_path = util::readlink(param_path);
system(util::string_format("rm %s -rf", real_path.c_str()).c_str());
util::check_system(util::string_format("rm %s -rf", real_path.c_str()));
unlink(param_path.c_str());
}
if (getenv("COMMA_CACHE") == nullptr) {
system(util::string_format("rm %s -rf", Path::download_cache_root().c_str()).c_str());
util::check_system(util::string_format("rm %s -rf", Path::download_cache_root().c_str()));
}
system(util::string_format("rm %s -rf", Path::comma_home().c_str()).c_str());
system(util::string_format("rm %s -rf", msgq_path.c_str()).c_str());
util::check_system(util::string_format("rm %s -rf", Path::comma_home().c_str()));
util::check_system(util::string_format("rm %s -rf", msgq_path.c_str()));
unsetenv("OPENPILOT_PREFIX");
}

Expand Down
6 changes: 3 additions & 3 deletions common/ratekeeper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include "common/timing.h"
#include "common/util.h"

RateKeeper::RateKeeper(const std::string &name, float rate, float print_delay_threshold)
: name(name),
print_delay_threshold(std::max(0.f, print_delay_threshold)) {
RateKeeper::RateKeeper(const std::string &name_, float rate, float print_delay_threshold_)
: name(name_),
print_delay_threshold(std::max(0.f, print_delay_threshold_)) {
interval = 1 / rate;
last_monitor_time = seconds_since_boot();
next_frame_time = last_monitor_time + interval;
Expand Down
10 changes: 5 additions & 5 deletions common/tests/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_CASE("util::read_file") {
REQUIRE(util::read_file(filename).empty());

std::string content = random_bytes(64 * 1024);
write(fd, content.c_str(), content.size());
REQUIRE(write(fd, content.c_str(), content.size()) == (ssize_t)content.size());
std::string ret = util::read_file(filename);
bool equal = (ret == content);
REQUIRE(equal);
Expand Down Expand Up @@ -114,12 +114,12 @@ TEST_CASE("util::safe_fwrite") {
}

TEST_CASE("util::create_directories") {
system("rm /tmp/test_create_directories -rf");
REQUIRE(system("rm /tmp/test_create_directories -rf") == 0);
std::string dir = "/tmp/test_create_directories/a/b/c/d/e/f";

auto check_dir_permissions = [](const std::string &dir, mode_t mode) -> bool {
auto check_dir_permissions = [](const std::string &path, mode_t mode) -> bool {
struct stat st = {};
return stat(dir.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR && (st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) == mode;
return stat(path.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR && (st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) == mode;
};

SECTION("create_directories") {
Expand All @@ -132,7 +132,7 @@ TEST_CASE("util::create_directories") {
}
SECTION("a file exists with the same name") {
REQUIRE(util::create_directories(dir, 0755));
int f = open((dir + "/file").c_str(), O_RDWR | O_CREAT);
int f = open((dir + "/file").c_str(), O_RDWR | O_CREAT, 0644);
REQUIRE(f != -1);
close(f);
REQUIRE(util::create_directories(dir + "/file", 0755) == false);
Expand Down
8 changes: 4 additions & 4 deletions common/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ bool file_exists(const std::string& fn) {
}

static bool createDirectory(std::string dir, mode_t mode) {
auto verify_dir = [](const std::string& dir) -> bool {
auto verify_dir = [](const std::string& path) -> bool {
struct stat st = {};
return (stat(dir.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR);
return (stat(path.c_str(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR);
};
// remove trailing /'s
while (dir.size() > 1 && dir.back() == '/') {
Expand Down Expand Up @@ -288,7 +288,7 @@ std::string strip(const std::string &str) {
std::string check_output(const std::string& command) {
char buffer[128];
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
std::unique_ptr<FILE, int(*)(FILE*)> pipe(popen(command.c_str(), "r"), pclose);

if (!pipe) {
return "";
Expand All @@ -303,7 +303,7 @@ std::string check_output(const std::string& command) {

bool system_time_valid() {
// Default to August 26, 2024
tm min_tm = {.tm_year = 2024 - 1900, .tm_mon = 7, .tm_mday = 26};
tm min_tm = {.tm_mday = 26, .tm_mon = 7, .tm_year = 2024 - 1900};
time_t min_date = mktime(&min_tm);

struct stat st;
Expand Down
7 changes: 7 additions & 0 deletions common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ bool create_directories(const std::string &dir, mode_t mode);

std::string check_output(const std::string& command);

inline void check_system(const std::string& cmd) {
int ret = std::system(cmd.c_str());
if (ret != 0) {
fprintf(stderr, "system command failed (%d): %s\n", ret, cmd.c_str());
}
}

bool system_time_valid();

inline void sleep_for(const int milliseconds) {
Expand Down
2 changes: 1 addition & 1 deletion rednose_repo
2 changes: 1 addition & 1 deletion selfdrive/pandad/spi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const std::string SPI_DEVICE = "/dev/spidev0.0";

class LockEx {
public:
LockEx(int fd, std::recursive_mutex &m) : fd(fd), m(m) {
LockEx(int fd_, std::recursive_mutex &m_) : fd(fd_), m(m_) {
m.lock();
flock(fd, LOCK_EX);
}
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/pandad/tests/test_pandad_canprotocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct PandaTest : public Panda {
capnp::List<cereal::CanData>::Reader can_data_list;
};

PandaTest::PandaTest(int can_list_size, cereal::PandaState::PandaType hw_type) : can_list_size(can_list_size), Panda() {
this->hw_type = hw_type;
PandaTest::PandaTest(int can_list_size_, cereal::PandaState::PandaType hw_type_) : can_list_size(can_list_size_), Panda() {
this->hw_type = hw_type_;
int data_limit = ((hw_type == cereal::PandaState::PandaType::RED_PANDA) ? std::size(dlc_to_len) : 8);
// prepare test data
for (int i = 0; i < data_limit; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ if GetOption('extras'):
obj = raylib_env.Object(f"installer/installers/installer_{name}.o", ["installer/installer.cc"], CPPDEFINES=d)
f = raylib_env.Program(f"installer/installers/installer_{name}", [obj, cont, inter, inter_bold, inter_light], LIBS=raylib_libs)
# keep installers small
assert f[0].get_size() < 1900*1e3, f[0].get_size()
assert f[0].get_size() < 2500*1e3, f[0].get_size()
10 changes: 5 additions & 5 deletions system/loggerd/encoder/v4l_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@ static void dequeue_buffer(int fd, v4l2_buf_type buf_type, unsigned int *index=N

static void queue_buffer(int fd, v4l2_buf_type buf_type, unsigned int index, VisionBuf *buf, struct timeval timestamp={}) {
v4l2_plane plane = {
.bytesused = (uint32_t)buf->len,
.length = (unsigned int)buf->len,
.m = { .userptr = (unsigned long)buf->addr, },
.bytesused = (uint32_t)buf->len,
.reserved = {(unsigned int)buf->fd}
};

v4l2_buffer v4l_buf = {
.type = buf_type,
.index = index,
.type = buf_type,
.flags = V4L2_BUF_FLAG_TIMESTAMP_COPY,
.timestamp = timestamp,
.memory = V4L2_MEMORY_USERPTR,
.m = { .planes = &plane, },
.length = 1,
.flags = V4L2_BUF_FLAG_TIMESTAMP_COPY,
.timestamp = timestamp
};
util::safe_ioctl(fd, VIDIOC_QBUF, &v4l_buf, "VIDIOC_QBUF failed");
}

static void request_buffers(int fd, v4l2_buf_type buf_type, unsigned int count) {
struct v4l2_requestbuffers reqbuf = {
.count = count,
.type = buf_type,
.memory = V4L2_MEMORY_USERPTR,
.count = count
};
util::safe_ioctl(fd, VIDIOC_REQBUFS, &reqbuf, "VIDIOC_REQBUFS failed");
}
Expand Down
4 changes: 2 additions & 2 deletions system/loggerd/loggerd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ void handle_preserve_segment(LoggerdState *s) {

void loggerd_thread() {
// setup messaging
typedef struct ServiceState {
struct ServiceState {
std::string name;
int counter, freq;
bool encoder, preserve_segment, record_audio;
} ServiceState;
};
std::unordered_map<SubSocket*, ServiceState> service_state;
std::unordered_map<SubSocket*, struct RemoteEncoder> remote_encoders;

Expand Down
4 changes: 2 additions & 2 deletions system/loggerd/loggerd.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ const EncoderInfo stream_driver_encoder_info = {
const EncoderInfo qcam_encoder_info = {
.publish_name = "qRoadEncodeData",
.filename = "qcamera.ts",
.get_settings = [](int){return EncoderSettings::QcamEncoderSettings();},
.include_audio = Params().getBool("RecordAudio"),
.frame_width = 526,
.frame_height = 330,
.include_audio = Params().getBool("RecordAudio"),
.get_settings = [](int){return EncoderSettings::QcamEncoderSettings();},
INIT_ENCODE_FUNCTIONS(QRoadEncode),
};

Expand Down
2 changes: 1 addition & 1 deletion system/loggerd/tests/test_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void write_msg(LoggerState *logger) {
TEST_CASE("logger") {
const int segment_cnt = 100;
const std::string log_root = "/tmp/test_logger";
system(("rm " + log_root + " -rf").c_str());
REQUIRE(system(("rm " + log_root + " -rf").c_str()) == 0);
std::string route_name;
{
LoggerState logger(log_root);
Expand Down
2 changes: 1 addition & 1 deletion tools/cabana/chart/chart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void ChartView::showTip(double sec) {
if (s.series->isVisible()) {
QString value = "--";
// use reverse iterator to find last item <= sec.
auto it = std::lower_bound(s.vals.crbegin(), s.vals.crend(), sec, [](auto &p, double x) { return p.x() > x; });
auto it = std::lower_bound(s.vals.crbegin(), s.vals.crend(), sec, [](auto &p, double v) { return p.x() > v; });
if (it != s.vals.crend() && it->x() >= axis_x->min()) {
value = s.sig->formatValue(it->y(), false);
s.track_pt = *it;
Expand Down
4 changes: 2 additions & 2 deletions tools/cabana/signalview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ SignalModel::SignalModel(QObject *parent) : root(new Item), QAbstractItemModel(p
}

void SignalModel::insertItem(SignalModel::Item *root_item, int pos, const cabana::Signal *sig) {
Item *parent_item = new Item{.sig = sig, .parent = root_item, .title = sig->name, .type = Item::Sig};
Item *parent_item = new Item{.type = Item::Sig, .parent = root_item, .sig = sig, .title = sig->name};
root_item->children.insert(pos, parent_item);
QString titles[]{"Name", "Size", "Receiver Nodes", "Little Endian", "Signed", "Offset", "Factor", "Type",
"Multiplex Value", "Extra Info", "Unit", "Comment", "Minimum Value", "Maximum Value", "Value Table"};
for (int i = 0; i < std::size(titles); ++i) {
auto item = new Item{.sig = sig, .parent = parent_item, .title = titles[i], .type = (Item::Type)(i + Item::Name)};
auto item = new Item{.type = (Item::Type)(i + Item::Name), .parent = parent_item, .sig = sig, .title = titles[i]};
parent_item->children.push_back(item);
if (item->type == Item::ExtraInfo) {
parent_item = item;
Expand Down
4 changes: 2 additions & 2 deletions tools/cabana/utils/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ UnixSignalHandler::~UnixSignalHandler() {
}

void UnixSignalHandler::signalHandler(int s) {
::write(sig_fd[0], &s, sizeof(s));
(void)!::write(sig_fd[0], &s, sizeof(s));
}

void UnixSignalHandler::handleSigTerm() {
sn->setEnabled(false);
int tmp;
::read(sig_fd[1], &tmp, sizeof(tmp));
(void)!::read(sig_fd[1], &tmp, sizeof(tmp));

printf("\nexiting...\n");
qApp->closeAllWindows();
Expand Down
13 changes: 7 additions & 6 deletions tools/cabana/videowidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
const int MIN_VIDEO_HEIGHT = 100;
const int THUMBNAIL_MARGIN = 3;

// Indexed by TimelineType: None, Engaged, AlertInfo, AlertWarning, AlertCritical, UserBookmark
static const QColor timeline_colors[] = {
[(int)TimelineType::None] = QColor(111, 143, 175),
[(int)TimelineType::Engaged] = QColor(0, 163, 108),
[(int)TimelineType::UserBookmark] = Qt::magenta,
[(int)TimelineType::AlertInfo] = Qt::green,
[(int)TimelineType::AlertWarning] = QColor(255, 195, 0),
[(int)TimelineType::AlertCritical] = QColor(199, 0, 57),
QColor(111, 143, 175),
QColor(0, 163, 108),
Qt::green,
QColor(255, 195, 0),
QColor(199, 0, 57),
Qt::magenta,
};

static Replay *getReplay() {
Expand Down
1 change: 0 additions & 1 deletion tools/install_ubuntu_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function install_ubuntu_common_requirements() {
# normal stuff, mostly for the bare docker image
$SUDO apt-get install -y --no-install-recommends \
ca-certificates \
clang \
build-essential \
curl \
libssl-dev \
Expand Down
2 changes: 1 addition & 1 deletion tools/replay/qcom_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ bool MsmVidc::setPlaneFormat(enum v4l2_buf_type type, uint32_t fourcc) {
bool MsmVidc::setFPS(uint32_t fps) {
struct v4l2_streamparm streamparam = {
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
.parm.output.timeperframe = {1, fps}
};
streamparam.parm.output.timeperframe = {1, fps};
util::safe_ioctl(fd, VIDIOC_S_PARM, &streamparam, "VIDIOC_S_PARM failed");
return true;
}
Expand Down