Skip to content

Commit

Permalink
visionipc: support OPENPILOT_PREFIX (#497)
Browse files Browse the repository at this point in the history
* OPENPILOT_PREFIX support in visionipc

* Use prefix as filename prefix

* Remove unnecessary import
  • Loading branch information
fredyshox authored Jul 18, 2023
1 parent cf9c5cb commit 6f71025
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion visionipc/visionipc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion visionipc/visionipc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6f71025

Please sign in to comment.