mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
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
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ Return<ICanController::Result> 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<ICanController::Result> 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;
|
||||
}
|
||||
|
||||
@@ -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 <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 bool isSupported(sp<ICanController> 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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user