Loading automotive/can/1.0/default/CanBusSlcan.cpp +9 −11 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ ICanController::Result CanBusSlcan::updateIfaceName(base::unique_fd& uartFd) { * that has already been configured and brought up. */ if (ioctl(uartFd.get(), SIOCGIFNAME, ifrequest.ifr_name) < 0) { LOG(ERROR) << "Failed to get the name of the created device: " << strerror(errno); PLOG(ERROR) << "Failed to get the name of the created device"; return ICanController::Result::UNKNOWN_ERROR; } Loading @@ -80,7 +80,7 @@ ICanController::Result CanBusSlcan::preUp() { * controlling terminal */ mFd = base::unique_fd(open(mUartName.c_str(), O_RDWR | O_NONBLOCK | O_NOCTTY)); if (!mFd.ok()) { LOG(ERROR) << "SLCAN Failed to open " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "SLCAN Failed to open " << mUartName; return ICanController::Result::BAD_INTERFACE_ID; } Loading @@ -92,7 +92,7 @@ ICanController::Result CanBusSlcan::preUp() { // blank terminal settings and pull them from the device struct termios terminalSettings = {}; if (tcgetattr(mFd.get(), &terminalSettings) < 0) { LOG(ERROR) << "Failed to read attrs of" << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to read attrs of" << mUartName; return ICanController::Result::UNKNOWN_ERROR; } Loading @@ -107,42 +107,40 @@ ICanController::Result CanBusSlcan::preUp() { struct serial_struct serialSettings; // get serial settings if (ioctl(mFd.get(), TIOCGSERIAL, &serialSettings) < 0) { LOG(ERROR) << "Failed to read serial settings from " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to read serial settings from " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } // set low latency mode serialSettings.flags |= ASYNC_LOW_LATENCY; // apply serial settings if (ioctl(mFd.get(), TIOCSSERIAL, &serialSettings) < 0) { LOG(ERROR) << "Failed to set low latency mode on " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to set low latency mode on " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } /* TCSADRAIN applies settings after we finish writing the rest of our * changes (as opposed to TCSANOW, which changes immediately) */ if (tcsetattr(mFd.get(), TCSADRAIN, &terminalSettings) < 0) { LOG(ERROR) << "Failed to apply terminal settings to " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to apply terminal settings to " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } // apply speed setting for CAN if (write(mFd.get(), canBitrateCommand->c_str(), canBitrateCommand->length()) <= 0) { LOG(ERROR) << "Failed to apply CAN bitrate: " << strerror(errno); PLOG(ERROR) << "Failed to apply CAN bitrate"; return ICanController::Result::UNKNOWN_ERROR; } // TODO(b/144775286): set open flag & support listen only if (write(mFd.get(), slcanprotocol::kOpenCommand.c_str(), slcanprotocol::kOpenCommand.length()) <= 0) { LOG(ERROR) << "Failed to set open flag: " << strerror(errno); PLOG(ERROR) << "Failed to set open flag"; return ICanController::Result::UNKNOWN_ERROR; } // set line discipline to slcan if (ioctl(mFd.get(), TIOCSETD, &slcanprotocol::kSlcanDiscipline) < 0) { LOG(ERROR) << "Failed to set line discipline to slcan: " << strerror(errno); PLOG(ERROR) << "Failed to set line discipline to slcan"; return ICanController::Result::UNKNOWN_ERROR; } Loading automotive/can/1.0/default/CanSocket.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ CanSocket::~CanSocket() { bool CanSocket::send(const struct canfd_frame& frame) { const auto res = write(mSocket.get(), &frame, CAN_MTU); if (res < 0) { LOG(DEBUG) << "CanSocket send failed: " << errno; PLOG(DEBUG) << "CanSocket send failed"; return false; } if (res != CAN_MTU) { Loading Loading @@ -102,7 +102,7 @@ void CanSocket::readerThread() { const auto sel = selectRead(mSocket, kReadPooling); if (sel == 0) continue; // timeout if (sel == -1) { LOG(ERROR) << "Select failed: " << errno; PLOG(ERROR) << "Select failed"; break; } Loading Loading @@ -130,7 +130,7 @@ void CanSocket::readerThread() { if (errno == EAGAIN) continue; errnoCopy = errno; LOG(ERROR) << "Failed to read CAN packet: " << strerror(errno) << " (" << errno << ")"; PLOG(ERROR) << "Failed to read CAN packet"; break; } Loading automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace android::netdevice { NetlinkSocket::NetlinkSocket(int protocol) { mFd.reset(socket(AF_NETLINK, SOCK_RAW, protocol)); if (!mFd.ok()) { LOG(ERROR) << "Can't open Netlink socket: " << errno; PLOG(ERROR) << "Can't open Netlink socket"; mFailed = true; return; } Loading @@ -32,7 +32,7 @@ NetlinkSocket::NetlinkSocket(int protocol) { sa.nl_family = AF_NETLINK; if (bind(mFd.get(), reinterpret_cast<struct sockaddr*>(&sa), sizeof(sa)) < 0) { LOG(ERROR) << "Can't bind Netlink socket: " << errno; PLOG(ERROR) << "Can't bind Netlink socket"; mFd.reset(); mFailed = true; } Loading @@ -57,7 +57,7 @@ bool NetlinkSocket::send(struct nlmsghdr* nlmsg) { msg.msg_iovlen = 1; if (sendmsg(mFd.get(), &msg, 0) < 0) { LOG(ERROR) << "Can't send Netlink message: " << errno; PLOG(ERROR) << "Can't send Netlink message"; return false; } return true; Loading @@ -79,7 +79,7 @@ bool NetlinkSocket::receiveAck() { const ssize_t status = recvmsg(mFd.get(), &msg, 0); if (status < 0) { LOG(ERROR) << "Failed to receive Netlink message: " << errno; PLOG(ERROR) << "Failed to receive Netlink message"; return false; } size_t remainingLen = status; Loading automotive/can/1.0/default/libnetdevice/can.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ base::unique_fd socket(const std::string& ifname) { } if (setsockopt(sock.get(), SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &kErrMask, sizeof(kErrMask)) < 0) { LOG(ERROR) << "Can't receive error frames, CAN setsockpt failed: " << strerror(errno); PLOG(ERROR) << "Can't receive error frames, CAN setsockpt failed"; return {}; } Loading automotive/can/1.0/default/libnetdevice/libnetdevice.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ static bool sendIfreq(unsigned long request, struct ifreq& ifr) { } if (ioctl(sock.get(), request, &ifr) < 0) { LOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed: " << errno; PLOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed"; return false; } Loading Loading
automotive/can/1.0/default/CanBusSlcan.cpp +9 −11 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ ICanController::Result CanBusSlcan::updateIfaceName(base::unique_fd& uartFd) { * that has already been configured and brought up. */ if (ioctl(uartFd.get(), SIOCGIFNAME, ifrequest.ifr_name) < 0) { LOG(ERROR) << "Failed to get the name of the created device: " << strerror(errno); PLOG(ERROR) << "Failed to get the name of the created device"; return ICanController::Result::UNKNOWN_ERROR; } Loading @@ -80,7 +80,7 @@ ICanController::Result CanBusSlcan::preUp() { * controlling terminal */ mFd = base::unique_fd(open(mUartName.c_str(), O_RDWR | O_NONBLOCK | O_NOCTTY)); if (!mFd.ok()) { LOG(ERROR) << "SLCAN Failed to open " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "SLCAN Failed to open " << mUartName; return ICanController::Result::BAD_INTERFACE_ID; } Loading @@ -92,7 +92,7 @@ ICanController::Result CanBusSlcan::preUp() { // blank terminal settings and pull them from the device struct termios terminalSettings = {}; if (tcgetattr(mFd.get(), &terminalSettings) < 0) { LOG(ERROR) << "Failed to read attrs of" << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to read attrs of" << mUartName; return ICanController::Result::UNKNOWN_ERROR; } Loading @@ -107,42 +107,40 @@ ICanController::Result CanBusSlcan::preUp() { struct serial_struct serialSettings; // get serial settings if (ioctl(mFd.get(), TIOCGSERIAL, &serialSettings) < 0) { LOG(ERROR) << "Failed to read serial settings from " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to read serial settings from " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } // set low latency mode serialSettings.flags |= ASYNC_LOW_LATENCY; // apply serial settings if (ioctl(mFd.get(), TIOCSSERIAL, &serialSettings) < 0) { LOG(ERROR) << "Failed to set low latency mode on " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to set low latency mode on " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } /* TCSADRAIN applies settings after we finish writing the rest of our * changes (as opposed to TCSANOW, which changes immediately) */ if (tcsetattr(mFd.get(), TCSADRAIN, &terminalSettings) < 0) { LOG(ERROR) << "Failed to apply terminal settings to " << mUartName << ": " << strerror(errno); PLOG(ERROR) << "Failed to apply terminal settings to " << mUartName; return ICanController::Result::UNKNOWN_ERROR; } // apply speed setting for CAN if (write(mFd.get(), canBitrateCommand->c_str(), canBitrateCommand->length()) <= 0) { LOG(ERROR) << "Failed to apply CAN bitrate: " << strerror(errno); PLOG(ERROR) << "Failed to apply CAN bitrate"; return ICanController::Result::UNKNOWN_ERROR; } // TODO(b/144775286): set open flag & support listen only if (write(mFd.get(), slcanprotocol::kOpenCommand.c_str(), slcanprotocol::kOpenCommand.length()) <= 0) { LOG(ERROR) << "Failed to set open flag: " << strerror(errno); PLOG(ERROR) << "Failed to set open flag"; return ICanController::Result::UNKNOWN_ERROR; } // set line discipline to slcan if (ioctl(mFd.get(), TIOCSETD, &slcanprotocol::kSlcanDiscipline) < 0) { LOG(ERROR) << "Failed to set line discipline to slcan: " << strerror(errno); PLOG(ERROR) << "Failed to set line discipline to slcan"; return ICanController::Result::UNKNOWN_ERROR; } Loading
automotive/can/1.0/default/CanSocket.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ CanSocket::~CanSocket() { bool CanSocket::send(const struct canfd_frame& frame) { const auto res = write(mSocket.get(), &frame, CAN_MTU); if (res < 0) { LOG(DEBUG) << "CanSocket send failed: " << errno; PLOG(DEBUG) << "CanSocket send failed"; return false; } if (res != CAN_MTU) { Loading Loading @@ -102,7 +102,7 @@ void CanSocket::readerThread() { const auto sel = selectRead(mSocket, kReadPooling); if (sel == 0) continue; // timeout if (sel == -1) { LOG(ERROR) << "Select failed: " << errno; PLOG(ERROR) << "Select failed"; break; } Loading Loading @@ -130,7 +130,7 @@ void CanSocket::readerThread() { if (errno == EAGAIN) continue; errnoCopy = errno; LOG(ERROR) << "Failed to read CAN packet: " << strerror(errno) << " (" << errno << ")"; PLOG(ERROR) << "Failed to read CAN packet"; break; } Loading
automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace android::netdevice { NetlinkSocket::NetlinkSocket(int protocol) { mFd.reset(socket(AF_NETLINK, SOCK_RAW, protocol)); if (!mFd.ok()) { LOG(ERROR) << "Can't open Netlink socket: " << errno; PLOG(ERROR) << "Can't open Netlink socket"; mFailed = true; return; } Loading @@ -32,7 +32,7 @@ NetlinkSocket::NetlinkSocket(int protocol) { sa.nl_family = AF_NETLINK; if (bind(mFd.get(), reinterpret_cast<struct sockaddr*>(&sa), sizeof(sa)) < 0) { LOG(ERROR) << "Can't bind Netlink socket: " << errno; PLOG(ERROR) << "Can't bind Netlink socket"; mFd.reset(); mFailed = true; } Loading @@ -57,7 +57,7 @@ bool NetlinkSocket::send(struct nlmsghdr* nlmsg) { msg.msg_iovlen = 1; if (sendmsg(mFd.get(), &msg, 0) < 0) { LOG(ERROR) << "Can't send Netlink message: " << errno; PLOG(ERROR) << "Can't send Netlink message"; return false; } return true; Loading @@ -79,7 +79,7 @@ bool NetlinkSocket::receiveAck() { const ssize_t status = recvmsg(mFd.get(), &msg, 0); if (status < 0) { LOG(ERROR) << "Failed to receive Netlink message: " << errno; PLOG(ERROR) << "Failed to receive Netlink message"; return false; } size_t remainingLen = status; Loading
automotive/can/1.0/default/libnetdevice/can.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ base::unique_fd socket(const std::string& ifname) { } if (setsockopt(sock.get(), SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &kErrMask, sizeof(kErrMask)) < 0) { LOG(ERROR) << "Can't receive error frames, CAN setsockpt failed: " << strerror(errno); PLOG(ERROR) << "Can't receive error frames, CAN setsockpt failed"; return {}; } Loading
automotive/can/1.0/default/libnetdevice/libnetdevice.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ static bool sendIfreq(unsigned long request, struct ifreq& ifr) { } if (ioctl(sock.get(), request, &ifr) < 0) { LOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed: " << errno; PLOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed"; return false; } Loading