From 204b8f9206cca050643e152132109ceb5ceff8f5 Mon Sep 17 00:00:00 2001 From: chrisweir Date: Thu, 9 Jan 2020 15:25:45 -0800 Subject: [PATCH] Refactor baudrate to bitrate Refactoring baudrate to bitrate to be consistent with terminology in the broader literature. Bug: 147448388 Test: Manual + VTS Change-Id: I161b39727a3fd50ea5eddafed6fbd4924ccd149f --- automotive/can/1.0/ICanController.hal | 10 +++++----- automotive/can/1.0/default/CanBusNative.cpp | 12 ++++++------ automotive/can/1.0/default/CanBusNative.h | 4 ++-- automotive/can/1.0/default/CanBusSlcan.cpp | 2 +- automotive/can/1.0/default/CanController.cpp | 4 ++-- automotive/can/1.0/tools/canhalctrl.cpp | 14 +++++++------- .../VtsHalCanControllerV1_0TargetTest.cpp | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/automotive/can/1.0/ICanController.hal b/automotive/can/1.0/ICanController.hal index 2c7494a907..0c6f53eff3 100644 --- a/automotive/can/1.0/ICanController.hal +++ b/automotive/can/1.0/ICanController.hal @@ -97,8 +97,8 @@ interface ICanController { */ BAD_ADDRESS, - /** Provided baud rate is not supported by the hardware. */ - BAD_BAUDRATE, + /** Provided bit rate is not supported by the hardware. */ + BAD_BITRATE, }; /** @@ -152,13 +152,13 @@ interface ICanController { } interfaceId; /** - * Baud rate for CAN communication. + * Bit rate for CAN communication. * - * Typical baud rates are: 100000, 125000, 250000, 500000. + * Typical bit rates are: 100000, 125000, 250000, 500000. * * For virtual interfaces this value is ignored. */ - uint32_t baudrate; + uint32_t bitrate; }; /** diff --git a/automotive/can/1.0/default/CanBusNative.cpp b/automotive/can/1.0/default/CanBusNative.cpp index 047b09091b..ef04d01832 100644 --- a/automotive/can/1.0/default/CanBusNative.cpp +++ b/automotive/can/1.0/default/CanBusNative.cpp @@ -22,8 +22,8 @@ namespace android::hardware::automotive::can::V1_0::implementation { -CanBusNative::CanBusNative(const std::string& ifname, uint32_t baudrate) - : CanBus(ifname), mBaudrate(baudrate) {} +CanBusNative::CanBusNative(const std::string& ifname, uint32_t bitrate) + : CanBus(ifname), mBitrate(bitrate) {} ICanController::Result CanBusNative::preUp() { if (!netdevice::exists(mIfname)) { @@ -31,7 +31,7 @@ ICanController::Result CanBusNative::preUp() { return ICanController::Result::BAD_ADDRESS; } - if (mBaudrate == 0) { + if (mBitrate == 0) { // interface is already up and we just want to register it return ICanController::Result::OK; } @@ -41,9 +41,9 @@ ICanController::Result CanBusNative::preUp() { return ICanController::Result::UNKNOWN_ERROR; } - if (!netdevice::can::setBitrate(mIfname, mBaudrate)) { - LOG(ERROR) << "Can't set bitrate " << mBaudrate << " for " << mIfname; - return ICanController::Result::BAD_BAUDRATE; + if (!netdevice::can::setBitrate(mIfname, mBitrate)) { + LOG(ERROR) << "Can't set bitrate " << mBitrate << " for " << mIfname; + return ICanController::Result::BAD_BITRATE; } return ICanController::Result::OK; diff --git a/automotive/can/1.0/default/CanBusNative.h b/automotive/can/1.0/default/CanBusNative.h index 7eda68342e..04d7194e37 100644 --- a/automotive/can/1.0/default/CanBusNative.h +++ b/automotive/can/1.0/default/CanBusNative.h @@ -21,13 +21,13 @@ namespace android::hardware::automotive::can::V1_0::implementation { struct CanBusNative : public CanBus { - CanBusNative(const std::string& ifname, uint32_t baudrate); + CanBusNative(const std::string& ifname, uint32_t bitrate); protected: virtual ICanController::Result preUp() override; private: - const uint32_t mBaudrate; + const uint32_t mBitrate; }; } // namespace android::hardware::automotive::can::V1_0::implementation diff --git a/automotive/can/1.0/default/CanBusSlcan.cpp b/automotive/can/1.0/default/CanBusSlcan.cpp index e42005b6db..0feee8f51a 100644 --- a/automotive/can/1.0/default/CanBusSlcan.cpp +++ b/automotive/can/1.0/default/CanBusSlcan.cpp @@ -71,7 +71,7 @@ ICanController::Result CanBusSlcan::preUp() { if (kBitrate != 0) { const auto lookupIt = slcanprotocol::kBitrateCommands.find(kBitrate); if (lookupIt == slcanprotocol::kBitrateCommands.end()) { - return ICanController::Result::BAD_BAUDRATE; + return ICanController::Result::BAD_BITRATE; } canBitrateCommand = lookupIt->second; } diff --git a/automotive/can/1.0/default/CanController.cpp b/automotive/can/1.0/default/CanController.cpp index cd17dd8edb..fb648c1d80 100644 --- a/automotive/can/1.0/default/CanController.cpp +++ b/automotive/can/1.0/default/CanController.cpp @@ -61,7 +61,7 @@ Return CanController::upInterface( if (config.iftype == ICanController::InterfaceType::SOCKETCAN) { // TODO(b/135918744): support serialno if (config.interfaceId.getDiscriminator() == IfaceIdDisc::address) { - busService = new CanBusNative(config.interfaceId.address(), config.baudrate); + busService = new CanBusNative(config.interfaceId.address(), config.bitrate); } else { return ICanController::Result::BAD_ADDRESS; } @@ -73,7 +73,7 @@ Return CanController::upInterface( } } else if (config.iftype == ICanController::InterfaceType::SLCAN) { if (config.interfaceId.getDiscriminator() == IfaceIdDisc::address) { - busService = new CanBusSlcan(config.interfaceId.address(), config.baudrate); + busService = new CanBusSlcan(config.interfaceId.address(), config.bitrate); } else { return ICanController::Result::BAD_ADDRESS; } diff --git a/automotive/can/1.0/tools/canhalctrl.cpp b/automotive/can/1.0/tools/canhalctrl.cpp index 5c9849bf0a..5494ba31a3 100644 --- a/automotive/can/1.0/tools/canhalctrl.cpp +++ b/automotive/can/1.0/tools/canhalctrl.cpp @@ -29,12 +29,12 @@ using ICanController = V1_0::ICanController; static void usage() { std::cerr << "CAN bus HAL Control tool" << std::endl; std::cerr << std::endl << "usage:" << std::endl << std::endl; - std::cerr << "canhalctrl up [baudrate]" << std::endl; + std::cerr << "canhalctrl up [bitrate]" << std::endl; std::cerr << "where:" << std::endl; std::cerr << " bus name - name under which ICanBus will be published" << std::endl; std::cerr << " type - one of: virtual, socketcan, slcan, indexed" << std::endl; std::cerr << " interface - hardware identifier (like can0, vcan0, /dev/ttyUSB0)" << std::endl; - std::cerr << " baudrate - such as 100000, 125000, 250000, 500000" << std::endl; + std::cerr << " bitrate - such as 100000, 125000, 250000, 500000" << std::endl; std::cerr << std::endl; std::cerr << "canhalctrl down " << std::endl; std::cerr << "where:" << std::endl; @@ -59,7 +59,7 @@ static bool isSupported(sp ctrl, ICanController::InterfaceType i } static int up(const std::string& busName, ICanController::InterfaceType type, - const std::string& interface, uint32_t baudrate) { + const std::string& interface, uint32_t bitrate) { bool anySupported = false; for (auto&& service : getControlServices()) { auto ctrl = ICanController::getService(service); @@ -74,7 +74,7 @@ static int up(const std::string& busName, ICanController::InterfaceType type, ICanController::BusConfiguration config = {}; config.name = busName; config.iftype = type; - config.baudrate = baudrate; + config.bitrate = bitrate; if (type == ICanController::InterfaceType::INDEXED) { config.interfaceId.index(std::stol(interface)); @@ -146,12 +146,12 @@ static int main(int argc, char* argv[]) { return -1; } - long long baudrate = 0; + long long bitrate = 0; if (argc == 4) { - baudrate = std::stoll(argv[3]); + bitrate = std::stoll(argv[3]); } - return up(busName, *type, interface, baudrate); + return up(busName, *type, interface, bitrate); } else if (cmd == "down") { if (argc != 1) { std::cerr << "Invalid number of arguments to down command: " << argc << std::endl; diff --git a/automotive/can/1.0/vts/functional/VtsHalCanControllerV1_0TargetTest.cpp b/automotive/can/1.0/vts/functional/VtsHalCanControllerV1_0TargetTest.cpp index 9bc789aa29..b2edd78391 100644 --- a/automotive/can/1.0/vts/functional/VtsHalCanControllerV1_0TargetTest.cpp +++ b/automotive/can/1.0/vts/functional/VtsHalCanControllerV1_0TargetTest.cpp @@ -172,7 +172,7 @@ TEST_F(CanControllerHalTest, IdentifierCompatibility) { ICanController::BusConfiguration config = {}; config.name = "compattestsrv"; config.iftype = iftype; - config.baudrate = 125000; + config.bitrate = 125000; // using random-ish addresses, which may not be valid - we can't test the success case if (iddisc == IdDisc::address) {