Skip to content
Merged
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
35 changes: 16 additions & 19 deletions src/main/CanVendorSocketCan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,25 +388,22 @@ int CanVendorSocketCan::subscriber() noexcept {
}
}

for (int i = 0; i < nfds; ++i) {
if (events[i].data.fd == m_socket_fd) {
struct can_frame canFrame;
int nbytes = ::read(m_socket_fd, &canFrame, sizeof(struct can_frame));
if (nbytes < 0) {
LOG(Log::ERR, CanLogIt::h())
<< "Unexpected error reading from socket, exiting";
return -1;
}

if (nbytes == sizeof(canFrame)) {
LOG(Log::DBG, CanLogIt::h()) << "Received CAN frame via SocketCAN";

CanFrame frame = translate(canFrame);
received(
frame); // Call the received method with the translated frame
} else {
LOG(Log::ERR, CanLogIt::h()) << "Corrupted CanFrame received";
}
if (nfds > 0 && events[0].data.fd == m_socket_fd) {
struct can_frame canFrame;
int nbytes = ::read(m_socket_fd, &canFrame, sizeof(struct can_frame));
if (nbytes < 0) {
LOG(Log::ERR, CanLogIt::h())
<< "Unexpected error reading from socket, exiting";
return -1;
}

if (nbytes == sizeof(canFrame)) {
LOG(Log::DBG, CanLogIt::h()) << "Received CAN frame via SocketCAN";

CanFrame frame = translate(canFrame);
received(frame); // Call the received method with the translated frame
} else {
LOG(Log::ERR, CanLogIt::h()) << "Corrupted CanFrame received";
}
}
}
Expand Down
Loading