From 6f7102581f57eb5074b816cc2cfd984218916773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 18 Jul 2023 04:17:09 +0200 Subject: [PATCH] visionipc: support OPENPILOT_PREFIX (#497) * OPENPILOT_PREFIX support in visionipc * Use prefix as filename prefix * Remove unnecessary import --- visionipc/visionipc_client.cc | 8 +++++++- visionipc/visionipc_server.cc | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/visionipc/visionipc_client.cc b/visionipc/visionipc_client.cc index 61e050a02..169afbb36 100644 --- a/visionipc/visionipc_client.cc +++ b/visionipc/visionipc_client.cc @@ -9,7 +9,13 @@ #include "cereal/logger/logger.h" static int connect_to_vipc_server(const std::string &name, bool blocking) { - std::string path = "/tmp/visionipc_" + name; + char* prefix = std::getenv("OPENPILOT_PREFIX"); + std::string path = "/tmp/"; + if (prefix) { + path = path + std::string(prefix) + "_"; + } + path = path + "visionipc_" + name; + int socket_fd = ipc_connect(path.c_str()); while (socket_fd < 0 && blocking) { std::cout << "VisionIpcClient connecting" << std::endl; diff --git a/visionipc/visionipc_server.cc b/visionipc/visionipc_server.cc index 65ba26a8d..c51e13ea1 100644 --- a/visionipc/visionipc_server.cc +++ b/visionipc/visionipc_server.cc @@ -83,7 +83,13 @@ void VisionIpcServer::start_listener(){ void VisionIpcServer::listener(){ std::cout << "Starting listener for: " << name << std::endl; - std::string path = "/tmp/visionipc_" + name; + char* prefix = std::getenv("OPENPILOT_PREFIX"); + std::string path = "/tmp/"; + if (prefix) { + path = path + std::string(prefix) + "_"; + } + path = path + "visionipc_" + name; + int sock = ipc_bind(path.c_str()); assert(sock >= 0);