summaryrefslogtreecommitdiff
path: root/gnss/common/utils/default/DeviceFileReader.cpp
diff options
context:
space:
mode:
authorYuchen He <yuchenhe@google.com>2022-01-20 22:57:09 +0000
committerHao Chen <chenhaosjtuacm@google.com>2022-02-18 18:05:09 -0800
commitf46bb4ac80c5729da401de11d2f96355e4364a6b (patch)
treeba9dda0bcf1ba37f10e3b614bf8664c60d0e03c8 /gnss/common/utils/default/DeviceFileReader.cpp
parent76ff33b72d974b93b15c4e6697c580262db71955 (diff)
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
Diffstat (limited to 'gnss/common/utils/default/DeviceFileReader.cpp')
-rw-r--r--gnss/common/utils/default/DeviceFileReader.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/gnss/common/utils/default/DeviceFileReader.cpp b/gnss/common/utils/default/DeviceFileReader.cpp
index 7d4fb04339..dfc086a8b8 100644
--- a/gnss/common/utils/default/DeviceFileReader.cpp
+++ b/gnss/common/utils/default/DeviceFileReader.cpp
@@ -22,8 +22,17 @@ namespace common {
void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMinIntervalMs) {
char inputBuffer[INPUT_BUFFER_SIZE];
- int mGnssFd = open(ReplayUtils::getGnssPath().c_str(),
- O_RDWR | O_NONBLOCK);
+ std::string deviceFilePath = "";
+ 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) {
return;
@@ -68,10 +77,13 @@ void DeviceFileReader::getDataFromDeviceFile(const std::string& command, int mMi
}
// Cache the injected data.
- if (ReplayUtils::isGnssRawMeasurement(inputStr)) {
- data_[CMD_GET_RAWMEASUREMENT] = inputStr;
- } else if (ReplayUtils::isNMEA(inputStr)) {
+ if (command == CMD_GET_LOCATION) {
+ // TODO validate data
data_[CMD_GET_LOCATION] = inputStr;
+ } else if (command == CMD_GET_RAWMEASUREMENT) {
+ if (ReplayUtils::isGnssRawMeasurement(inputStr)) {
+ data_[CMD_GET_RAWMEASUREMENT] = inputStr;
+ }
}
}