Skip to content

Commit 9e0fd3b

Browse files
committed
pcm-raw: add option to select first record in pmt db match result
Change-Id: I0142ddf9d94d238c80b50e0ab60d8eb445fb6e96
1 parent 2c4a1fb commit 9e0fd3b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/pcm-raw.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr)
10741074
const auto configArray = split(configStr, ',');
10751075
bool fixed = false;
10761076
std::string lookup;
1077-
auto pmtAddRecord = [&lookup, &pmuName, &config](const std::vector<TelemetryDB::PMTRecord> & records) -> AddEventStatus
1077+
auto pmtAddRecord = [&lookup, &pmuName, &config](const std::vector<TelemetryDB::PMTRecord> & records, const bool first = false) -> AddEventStatus
10781078
{
10791079
if (pmuName == "pmt")
10801080
{
@@ -1083,7 +1083,7 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr)
10831083
cerr << "ERROR: lookup \"" << lookup << "\" not found in PMT telemetry database\n";
10841084
return AddEventStatus::Failed;
10851085
}
1086-
if (records.size() > 1)
1086+
if (records.size() > 1 && first == false)
10871087
{
10881088
cerr << "ERROR: lookup \"" << lookup << "\" is ambiguous in PMT telemetry database\n\n";
10891089
for (const auto & record : records)
@@ -1092,10 +1092,11 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr)
10921092
record.print(cerr);
10931093
cerr << "\n";
10941094
}
1095+
cerr << "Alternatively use lookupf or ilookupf to select the first record in the list.\n";
10951096
return AddEventStatus::Failed;
10961097
}
10971098
config.second = records[0].fullName;
1098-
assert(records.size() == 1);
1099+
assert(records.size() >= 1);
10991100
config.first[PCM::PMTEventPosition::UID] = records[0].uid;
11001101
config.first[PCM::PMTEventPosition::offset] = records[0].qWordOffset;
11011102
config.first[PCM::PMTEventPosition::type] = (records[0].sampleType == "Snapshot") ? PCM::MSRType::Static : PCM::MSRType::Freerun;
@@ -1150,6 +1151,16 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr)
11501151
if (pmtAddRecord(telemDB.ilookup(lookup)) != AddEventStatus::OK)
11511152
return AddEventStatus::Failed;
11521153
}
1154+
else if (pcm_sscanf(item) >> s_expect("lookupf=") >> setw(255) >> lookup)
1155+
{
1156+
if (pmtAddRecord(telemDB.lookup(lookup), true) != AddEventStatus::OK)
1157+
return AddEventStatus::Failed;
1158+
}
1159+
else if (pcm_sscanf(item) >> s_expect("ilookupf=") >> setw(255) >> lookup)
1160+
{
1161+
if (pmtAddRecord(telemDB.ilookup(lookup), true) != AddEventStatus::OK)
1162+
return AddEventStatus::Failed;
1163+
}
11531164
else if (item == "fixed")
11541165
{
11551166
fixed = true;

0 commit comments

Comments
 (0)