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
diff --git a/automotive/can/1.0/ICanController.hal b/automotive/can/1.0/ICanController.hal
index 2c7494a..0c6f53e 100644
--- a/automotive/can/1.0/ICanController.hal
+++ b/automotive/can/1.0/ICanController.hal
@@ -97,8 +97,8 @@
          */
         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 @@
         } 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 047b090..ef04d01 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 @@
         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 @@
         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 7eda683..04d7194 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 e42005b..0feee8f 100644
--- a/automotive/can/1.0/default/CanBusSlcan.cpp
+++ b/automotive/can/1.0/default/CanBusSlcan.cpp
@@ -71,7 +71,7 @@
     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 cd17dd8..fb648c1 100644
--- a/automotive/can/1.0/default/CanController.cpp
+++ b/automotive/can/1.0/default/CanController.cpp
@@ -61,7 +61,7 @@
     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 @@
         }
     } 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 5c9849b..5494ba3 100644
--- a/automotive/can/1.0/tools/canhalctrl.cpp
+++ b/automotive/can/1.0/tools/canhalctrl.cpp
@@ -29,12 +29,12 @@
 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 <bus name> <type> <interface> [baudrate]" << std::endl;
+    std::cerr << "canhalctrl up <bus name> <type> <interface> [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 <bus name>" << std::endl;
     std::cerr << "where:" << std::endl;
@@ -59,7 +59,7 @@
 }
 
 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 @@
         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 @@
             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 9bc789a..b2edd78 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 @@
             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) {