X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Futils%2Fsocketcan-isotp.cpp;h=928e8c72e98e4d4597724337e389a4dbd2928e00;hb=24bb25c9f16ecace05b64142493dce596f5a9e37;hp=1aab9afaf15a8ed2d38246c5685d0aed11fde327;hpb=b8e8186c95f50e76aa4d88c3c751053568ab7cdf;p=apps%2Fagl-service-can-low-level.git diff --git a/low-can-binding/utils/socketcan-isotp.cpp b/low-can-binding/utils/socketcan-isotp.cpp index 1aab9afa..928e8c72 100644 --- a/low-can-binding/utils/socketcan-isotp.cpp +++ b/low-can-binding/utils/socketcan-isotp.cpp @@ -36,7 +36,7 @@ namespace utils int socketcan_isotp_t::open(std::string device_name) { AFB_WARNING("NOT USE THIS FUNCTION !"); - return open(device_name,NO_CAN_ID,NO_CAN_ID); + return open(device_name, NO_CAN_ID, NO_CAN_ID); } /** @@ -59,13 +59,11 @@ namespace utils return -1; } - if(define_tx_address(device_name,rx_id,tx_id) < 0) - { + if(define_tx_address(device_name, rx_id, tx_id) < 0) return -1; - } struct can_isotp_options opts; - memset(&opts,0,sizeof(opts)); + memset(&opts, 0, sizeof(opts)); setopt(SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)); if(bind((struct sockaddr *)&tx_address_, sizeof(tx_address_)) < 0) @@ -88,7 +86,7 @@ namespace utils std::shared_ptr cm = std::make_shared(); uint8_t msg[MAX_ISOTP_FRAMES]; - ssize_t nbytes = read(socket(),msg,MAX_ISOTP_FRAMES); + ssize_t nbytes = read(socket(), msg, MAX_ISOTP_FRAMES); cm->set_id(tx_address_.can_addr.tp.rx_id); @@ -100,13 +98,11 @@ namespace utils std::vector data; for (int i=0; i < nbytes; i++) - { data.push_back(msg[i]); - } std::string data_string; - data_string = converter_t::to_hex(msg,nbytes); - AFB_DEBUG("DATA ISO TP for id : %x = %s",cm->get_id(),data_string.c_str()); + data_string = converter_t::to_hex(msg, nbytes); + AFB_DEBUG("DATA ISO TP for id : %x = %s", cm->get_id(), data_string.c_str()); cm->set_data(data); @@ -130,7 +126,7 @@ namespace utils size_t size = m.get_length(); if(size < MAX_ISOTP_FRAMES) { - ssize_t ret = write(socket(),m.get_data(),size); + ssize_t ret = write(socket(), m.get_data(), size); if(ret < 0) { AFB_ERROR("Error sending : %i %s", errno, ::strerror(errno)); @@ -138,9 +134,7 @@ namespace utils } if(ret != size) - { - AFB_WARNING("ISOTP wrote only %zd byte",ret); - } + AFB_WARNING("ISOTP wrote only %zd byte", ret); } else { @@ -171,9 +165,7 @@ namespace utils close(); } else - { tx_address_.can_ifindex = ifr.ifr_ifindex; - } tx_address_.can_family = AF_CAN; @@ -188,4 +180,4 @@ namespace utils return 0; } -} \ No newline at end of file +}