Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Jun 26, 2024
1 parent 74074d6 commit db715bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions msgq/visionipc/visionipc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@ bool VisionIpcClient::connect(bool blocking){
}
// Send stream type to server to request FDs
int r = ipc_sendrecv_with_fds(true, socket_fd, &type, sizeof(type), nullptr, 0, nullptr);
if (r <= 0) {
close(socket_fd);
return false;
}

assert(r == sizeof(type));

// Get FDs
int fds[VISIONIPC_MAX_FDS];
VisionBuf bufs[VISIONIPC_MAX_FDS];
r = ipc_sendrecv_with_fds(false, socket_fd, &bufs, sizeof(bufs), fds, VISIONIPC_MAX_FDS, &num_buffers);
if (r <= 0) {
printf("err code *** %d\n", r);
close(socket_fd);
return false;
}

assert(num_buffers >= 0);
assert(r == sizeof(VisionBuf) * num_buffers);

// Import buffers
Expand Down Expand Up @@ -122,11 +131,19 @@ std::set<VisionStreamType> VisionIpcClient::getAvailableStreams(const std::strin
// Send VISION_STREAM_MAX to server to request available streams
int request = VISION_STREAM_MAX;
int r = ipc_sendrecv_with_fds(true, socket_fd, &request, sizeof(request), nullptr, 0, nullptr);
assert(r == sizeof(request));
if (r <= 0) {
close(socket_fd);
return {};
}

VisionStreamType available_streams[VISION_STREAM_MAX] = {};
r = ipc_sendrecv_with_fds(false, socket_fd, &available_streams, sizeof(available_streams), nullptr, 0, nullptr);
assert((r >= 0) && (r % sizeof(VisionStreamType) == 0));
if (r <= 0) {
close(socket_fd);
return {};
}

assert((r % sizeof(VisionStreamType)) == 0);
close(socket_fd);
return std::set<VisionStreamType>(available_streams, available_streams + r / sizeof(VisionStreamType));
}
Expand Down
2 changes: 1 addition & 1 deletion msgq/visionipc/visionipc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void VisionIpcServer::listener(){
}

if (buffers.count(type) <= 0) {
std::cout << "got request for invalid buffer type: " << type << std::endl;
// std::cout << "got request for invalid buffer type: " << type << std::endl;
close(fd);
continue;
}
Expand Down

0 comments on commit db715bd

Please sign in to comment.