mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 02:42:35 +00:00
Supported synchronized fixed location and measurement from device files
Replace NMEA by one row fixed location data Test: atest VtsHalGnssTargetTest Test: launch_cvd -cpus 16 -memory_mb 16192 --start_gnss_proxy --gnss_file_path=/usr/local/google/home/yuchenhe/Downloads/raw.txt --fixed_location_file_path=/google/data/rw/users/yu/yuchenhe/input.txt Bug: 213225295 Merged-In: Ide7bbb3e81a90414496084691227bd95a2e7af18 Change-Id: Ide7bbb3e81a90414496084691227bd95a2e7af18
This commit is contained in:
@@ -22,8 +22,17 @@ namespace common {
|
|||||||
|
|
||||||
void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMinIntervalMs) {
|
void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMinIntervalMs) {
|
||||||
char inputBuffer[INPUT_BUFFER_SIZE];
|
char inputBuffer[INPUT_BUFFER_SIZE];
|
||||||
int mGnssFd = open(ReplayUtils::getGnssPath().c_str(),
|
std::string deviceFilePath = "";
|
||||||
O_RDWR | O_NONBLOCK);
|
if (command == CMD_GET_LOCATION) {
|
||||||
|
deviceFilePath = ReplayUtils::getFixedLocationPath();
|
||||||
|
} else if (command == CMD_GET_RAWMEASUREMENT) {
|
||||||
|
deviceFilePath = ReplayUtils::getGnssPath();
|
||||||
|
} else {
|
||||||
|
// Invalid command
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mGnssFd = open(deviceFilePath.c_str(), O_RDWR | O_NONBLOCK);
|
||||||
|
|
||||||
if (mGnssFd == -1) {
|
if (mGnssFd == -1) {
|
||||||
return;
|
return;
|
||||||
@@ -68,10 +77,13 @@ void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache the injected data.
|
// Cache the injected data.
|
||||||
if (ReplayUtils::isGnssRawMeasurement(inputStr)) {
|
if (command == CMD_GET_LOCATION) {
|
||||||
data_[CMD_GET_RAWMEASUREMENT] = inputStr;
|
// TODO validate data
|
||||||
} else if (ReplayUtils::isNMEA(inputStr)) {
|
|
||||||
data_[CMD_GET_LOCATION] = inputStr;
|
data_[CMD_GET_LOCATION] = inputStr;
|
||||||
|
} else if (command == CMD_GET_RAWMEASUREMENT) {
|
||||||
|
if (ReplayUtils::isGnssRawMeasurement(inputStr)) {
|
||||||
|
data_[CMD_GET_RAWMEASUREMENT] = inputStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,24 @@ std::string ReplayUtils::getGnssPath() {
|
|||||||
return GNSS_PATH;
|
return GNSS_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ReplayUtils::getFixedLocationPath() {
|
||||||
|
char devname_value[PROPERTY_VALUE_MAX] = "";
|
||||||
|
if (property_get("debug.location.fixedlocation.devname", devname_value, NULL) > 0) {
|
||||||
|
return devname_value;
|
||||||
|
}
|
||||||
|
return FIXED_LOCATION_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
bool ReplayUtils::hasGnssDeviceFile() {
|
bool ReplayUtils::hasGnssDeviceFile() {
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
return stat(getGnssPath().c_str(), &sb) != -1;
|
return stat(getGnssPath().c_str(), &sb) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReplayUtils::hasFixedLocationDeviceFile() {
|
||||||
|
struct stat sb;
|
||||||
|
return stat(getFixedLocationPath().c_str(), &sb) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool ReplayUtils::isGnssRawMeasurement(const std::string& inputStr) {
|
bool ReplayUtils::isGnssRawMeasurement(const std::string& inputStr) {
|
||||||
// TODO: add more logic check to by pass invalid data.
|
// TODO: add more logic check to by pass invalid data.
|
||||||
return !inputStr.empty() && (inputStr.find("Raw") != std::string::npos);
|
return !inputStr.empty() && (inputStr.find("Raw") != std::string::npos);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const float kIrnssL5FreqHz = 1176.45 * 1e6;
|
|||||||
|
|
||||||
// Location replay constants
|
// Location replay constants
|
||||||
constexpr char GNSS_PATH[] = "/dev/gnss0";
|
constexpr char GNSS_PATH[] = "/dev/gnss0";
|
||||||
|
constexpr char FIXED_LOCATION_PATH[] = "/dev/gnss1";
|
||||||
constexpr int INPUT_BUFFER_SIZE = 256;
|
constexpr int INPUT_BUFFER_SIZE = 256;
|
||||||
constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
|
constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
|
||||||
constexpr char CMD_GET_RAWMEASUREMENT[] = "CMD_GET_RAWMEASUREMENT";
|
constexpr char CMD_GET_RAWMEASUREMENT[] = "CMD_GET_RAWMEASUREMENT";
|
||||||
|
|||||||
@@ -37,10 +37,14 @@ namespace common {
|
|||||||
struct ReplayUtils {
|
struct ReplayUtils {
|
||||||
static std::string getGnssPath();
|
static std::string getGnssPath();
|
||||||
|
|
||||||
|
static std::string getFixedLocationPath();
|
||||||
|
|
||||||
static std::string getDataFromDeviceFile(const std::string& command, int mMinIntervalMs);
|
static std::string getDataFromDeviceFile(const std::string& command, int mMinIntervalMs);
|
||||||
|
|
||||||
static bool hasGnssDeviceFile();
|
static bool hasGnssDeviceFile();
|
||||||
|
|
||||||
|
static bool hasFixedLocationDeviceFile();
|
||||||
|
|
||||||
static bool isGnssRawMeasurement(const std::string& inputStr);
|
static bool isGnssRawMeasurement(const std::string& inputStr);
|
||||||
|
|
||||||
static bool isNMEA(const std::string& inputStr);
|
static bool isNMEA(const std::string& inputStr);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
|
|
||||||
#include "DeviceFileReader.h"
|
#include "DeviceFileReader.h"
|
||||||
|
#include "FixLocationParser.h"
|
||||||
#include "GnssAntennaInfo.h"
|
#include "GnssAntennaInfo.h"
|
||||||
#include "GnssConfiguration.h"
|
#include "GnssConfiguration.h"
|
||||||
#include "GnssDebug.h"
|
#include "GnssDebug.h"
|
||||||
@@ -38,7 +39,6 @@
|
|||||||
#include "GnssMeasurementCorrections.h"
|
#include "GnssMeasurementCorrections.h"
|
||||||
#include "GnssReplayUtils.h"
|
#include "GnssReplayUtils.h"
|
||||||
#include "MockLocation.h"
|
#include "MockLocation.h"
|
||||||
#include "NmeaFixInfo.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace android::hardware::gnss::common::implementation {
|
namespace android::hardware::gnss::common::implementation {
|
||||||
@@ -162,9 +162,12 @@ GnssTemplate<T_IGnss>::~GnssTemplate() {
|
|||||||
template <class T_IGnss>
|
template <class T_IGnss>
|
||||||
std::unique_ptr<V2_0::GnssLocation> GnssTemplate<T_IGnss>::getLocationFromHW() {
|
std::unique_ptr<V2_0::GnssLocation> GnssTemplate<T_IGnss>::getLocationFromHW() {
|
||||||
mHardwareModeChecked = true;
|
mHardwareModeChecked = true;
|
||||||
|
if (!ReplayUtils::hasFixedLocationDeviceFile()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
std::string inputStr =
|
std::string inputStr =
|
||||||
::android::hardware::gnss::common::DeviceFileReader::Instance().getLocationData();
|
::android::hardware::gnss::common::DeviceFileReader::Instance().getLocationData();
|
||||||
return NmeaFixInfo::getLocationFromInputStr(inputStr);
|
return FixLocationParser::getLocationFromInputStr(inputStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T_IGnss>
|
template <class T_IGnss>
|
||||||
|
|||||||
Reference in New Issue
Block a user