Skip to content

Commit

Permalink
Merge branch 'commaai:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rav4kumar authored Jan 17, 2024
2 parents 87d0a6f + d81d86e commit 230917f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ repos:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.8.0
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.1.9
hooks:
- id: ruff
- repo: local
Expand Down
3 changes: 2 additions & 1 deletion log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ struct InitData {

struct FrameData {
frameId @0 :UInt32;
encodeId @1 :UInt32; # DEPRECATED
frameIdSensor @25 :UInt32;
requestId @28 :UInt32;
encodeId @1 :UInt32;

frameType @7 :FrameType;

Expand Down
13 changes: 4 additions & 9 deletions visionipc/visionipc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@
#include <iostream>
#include <thread>

#include <unistd.h>
#include "cereal/visionipc/ipc.h"
#include "cereal/visionipc/visionipc_client.h"
#include "cereal/visionipc/visionipc_server.h"
#include "cereal/logger/logger.h"

static int connect_to_vipc_server(const std::string &name, bool blocking) {
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());
const std::string ipc_path = get_ipc_path(name);
int socket_fd = ipc_connect(ipc_path.c_str());
while (socket_fd < 0 && blocking) {
std::cout << "VisionIpcClient connecting" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
socket_fd = ipc_connect(path.c_str());
socket_fd = ipc_connect(ipc_path.c_str());
}
return socket_fd;
}
Expand Down
3 changes: 0 additions & 3 deletions visionipc/visionipc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

#include <set>
#include <string>
#include <vector>
#include <unistd.h>

#include "cereal/messaging/messaging.h"
#include "cereal/visionipc/visionipc.h"
#include "cereal/visionipc/visionbuf.h"

class VisionIpcClient {
Expand Down
20 changes: 11 additions & 9 deletions visionipc/visionipc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ std::string get_endpoint_name(std::string name, VisionStreamType type){
}
}

std::string get_ipc_path(const std::string& name) {
std::string path = "/tmp/";
if (char* prefix = std::getenv("OPENPILOT_PREFIX")) {
path += std::string(prefix) + "_";
}
return path + "visionipc_" + name;
}

VisionIpcServer::VisionIpcServer(std::string name, cl_device_id device_id, cl_context ctx) : name(name), device_id(device_id), ctx(ctx) {
msg_ctx = Context::create();

Expand Down Expand Up @@ -83,14 +91,8 @@ void VisionIpcServer::start_listener(){
void VisionIpcServer::listener(){
std::cout << "Starting listener for: " << name << std::endl;

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());
const std::string ipc_path = get_ipc_path(name);
int sock = ipc_bind(ipc_path.c_str());
assert(sock >= 0);

while (!should_exit){
Expand Down Expand Up @@ -160,7 +162,7 @@ void VisionIpcServer::listener(){

std::cout << "Stopping listener for: " << name << std::endl;
close(sock);
unlink(path.c_str());
unlink(ipc_path.c_str());
}


Expand Down
2 changes: 1 addition & 1 deletion visionipc/visionipc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <map>

#include "cereal/messaging/messaging.h"
#include "cereal/visionipc/visionipc.h"
#include "cereal/visionipc/visionbuf.h"

std::string get_endpoint_name(std::string name, VisionStreamType type);
std::string get_ipc_path(const std::string &name);

class VisionIpcServer {
private:
Expand Down

0 comments on commit 230917f

Please sign in to comment.