Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josevcm committed Nov 24, 2024
1 parent e693e6f commit a954193
Show file tree
Hide file tree
Showing 20 changed files with 4,251 additions and 3,625 deletions.
24 changes: 13 additions & 11 deletions src/nfc-test/test-sdr/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ bool readFrames(const std::string &path, std::list<lab::RawFrame> &list)
lab::RawFrame frame(256);

frame.setTechType(entry["techType"]);
frame.setDateTime(entry["dateTime"]);
frame.setFrameType(entry["frameType"]);
frame.setFramePhase(entry["framePhase"]);
frame.setFrameFlags(entry["frameFlags"]);
Expand Down Expand Up @@ -108,12 +109,13 @@ bool writeFrames(const std::string &path, std::list<lab::RawFrame> &list)
});

frames.push_back({
{"techType", frame.techType()},
{"dateTime", frame.dateTime()},
{"sampleStart", frame.sampleStart()},
{"sampleEnd", frame.sampleEnd()},
{"sampleRate", frame.sampleEnd()},
{"sampleRate", frame.sampleRate()},
{"timeStart", frame.timeStart()},
{"timeEnd", frame.timeEnd()},
{"techType", frame.techType()},
{"frameType", frame.frameType()},
{"frameRate", frame.frameRate()},
{"frameFlags", frame.frameFlags()},
Expand All @@ -127,7 +129,7 @@ bool writeFrames(const std::string &path, std::list<lab::RawFrame> &list)

std::ofstream output(path);

output << std::setw(3) << info << std::endl;
output << std::setw(3) << info.dump(2) << std::endl;

return true;
}
Expand All @@ -137,7 +139,7 @@ bool writeFrames(const std::string &path, std::list<lab::RawFrame> &list)
*/
bool readSignal(const std::string &path, std::list<lab::RawFrame> &list)
{
if (!rt::FileSystem::exists(path))
if (!FileSystem::exists(path))
return false;

hw::RecordDevice source(path);
Expand All @@ -154,8 +156,8 @@ bool readSignal(const std::string &path, std::list<lab::RawFrame> &list)

std::list<lab::RawFrame> frames;

int channelCount = std::get<int>(source.get(hw::SignalDevice::PARAM_CHANNEL_COUNT));
int sampleRate = std::get<int>(source.get(hw::SignalDevice::PARAM_SAMPLE_RATE));
unsigned int channelCount = std::get<unsigned int>(source.get(hw::SignalDevice::PARAM_CHANNEL_COUNT));
unsigned int sampleRate = std::get<unsigned int>(source.get(hw::SignalDevice::PARAM_SAMPLE_RATE));

while (!source.isEof())
{
Expand Down Expand Up @@ -216,7 +218,7 @@ int testFile(const std::string &signal)

int testPath(const std::string &path)
{
for (const auto &entry: rt::FileSystem::directoryList(path))
for (const auto &entry: FileSystem::directoryList(path))
{
if (entry.name.find(".wav") != std::string::npos)
{
Expand All @@ -232,20 +234,20 @@ int main(int argc, char *argv[])
// Logger::init(std::cout, false);

logger->info("***********************************************************************");
logger->info("NFC laboratory, 2021 Jose Vicente Campos Martinez - <[email protected]>");
logger->info("NFC laboratory, 2024 Jose Vicente Campos Martinez - <[email protected]>");
logger->info("***********************************************************************");

for (int i = 1; i < argc; i++)
{
std::string path{argv[i]};
std::string path {argv[i]};

if (rt::FileSystem::isDirectory(path))
if (FileSystem::isDirectory(path))
{
logger->info("processing path {}", {path});

testPath(path);
}
else if (rt::FileSystem::isRegularFile(path))
else if (FileSystem::isRegularFile(path))
{
logger->info("processing file {}", {path});

Expand Down
264 changes: 142 additions & 122 deletions wav/test_NFC-A_106kbps_001.json
Original file line number Diff line number Diff line change
@@ -1,124 +1,144 @@
{
"frames": [
{
"frameData": "52",
"frameFlags": 1,
"framePhase": 1,
"frameRate": 105938,
"frameType": 2,
"sampleEnd": 11567,
"sampleStart": 10807,
"techType": 1,
"timeEnd": 0.0011567,
"timeStart": 0.0010807
},
{
"frameData": "04:00",
"frameFlags": 0,
"framePhase": 1,
"frameRate": 105938,
"frameType": 3,
"sampleEnd": 14215,
"sampleStart": 12469,
"techType": 1,
"timeEnd": 0.0014215,
"timeStart": 0.0012469
},
{
"frameData": "93:70:46:30:AC:C9:13:08:FA",
"frameFlags": 0,
"framePhase": 1,
"frameRate": 105938,
"frameType": 2,
"sampleEnd": 26864,
"sampleStart": 19124,
"techType": 1,
"timeEnd": 0.0026864,
"timeStart": 0.0019124
},
{
"frameData": "08:B6:DD",
"frameFlags": 0,
"framePhase": 1,
"frameRate": 105938,
"frameType": 3,
"sampleEnd": 30356,
"sampleStart": 27762,
"techType": 1,
"timeEnd": 0.0030356,
"timeStart": 0.0027762
},
{
"frameData": "60:08:BD:F7",
"frameFlags": 0,
"framePhase": 2,
"frameRate": 105938,
"frameType": 2,
"sampleEnd": 58249,
"sampleStart": 54701,
"techType": 1,
"timeEnd": 0.0058249,
"timeStart": 0.0054701
},
{
"frameData": "49:B5:18:7D",
"frameFlags": 2,
"framePhase": 2,
"frameRate": 105938,
"frameType": 3,
"sampleEnd": 64999,
"sampleStart": 61554,
"techType": 1,
"timeEnd": 0.0064999,
"timeStart": 0.0061554
},
{
"frameData": "20:0D:25:13:4B:39:7A:D1",
"frameFlags": 18,
"framePhase": 2,
"frameRate": 105938,
"frameType": 2,
"sampleEnd": 75751,
"sampleStart": 68860,
"techType": 1,
"timeEnd": 0.0075751,
"timeStart": 0.006886
},
{
"frameData": "43:CD:B2:8F",
"frameFlags": 18,
"framePhase": 2,
"frameRate": 105938,
"frameType": 3,
"sampleEnd": 80149,
"sampleStart": 76657,
"techType": 1,
"timeEnd": 0.0080149,
"timeStart": 0.0076657
},
{
"frameData": "D1:C5:A5:29",
"frameFlags": 18,
"framePhase": 2,
"frameRate": 105938,
"frameType": 2,
"sampleEnd": 87644,
"sampleStart": 84153,
"techType": 1,
"timeEnd": 0.0087644,
"timeStart": 0.0084153
},
{
"frameData": "23:90:AA:D6:06:1E:8A:32:96:3A:BD:DB:D8:E0:5E:DA:3B:5B",
"frameFlags": 18,
"framePhase": 2,
"frameRate": 105938,
"frameType": 3,
"sampleEnd": 104739,
"sampleStart": 89400,
"techType": 1,
"timeEnd": 0.0104739,
"timeStart": 0.00894
}
]
"frames": [
{
"dateTime": 0.0010807,
"frameData": "52",
"frameFlags": 1,
"framePhase": 258,
"frameRate": 105938,
"frameType": 258,
"sampleEnd": 11567,
"sampleRate": 10000000,
"sampleStart": 10807,
"techType": 257,
"timeEnd": 0.0011567,
"timeStart": 0.0010807
},
{
"dateTime": 0.0012469,
"frameData": "04:00",
"frameFlags": 0,
"framePhase": 258,
"frameRate": 105938,
"frameType": 259,
"sampleEnd": 14215,
"sampleRate": 10000000,
"sampleStart": 12469,
"techType": 257,
"timeEnd": 0.0014215,
"timeStart": 0.0012469
},
{
"dateTime": 0.0019124,
"frameData": "93:70:46:30:AC:C9:13:08:FA",
"frameFlags": 0,
"framePhase": 258,
"frameRate": 105938,
"frameType": 258,
"sampleEnd": 26864,
"sampleRate": 10000000,
"sampleStart": 19124,
"techType": 257,
"timeEnd": 0.0026864,
"timeStart": 0.0019124
},
{
"dateTime": 0.0027762,
"frameData": "08:B6:DD",
"frameFlags": 0,
"framePhase": 258,
"frameRate": 105938,
"frameType": 259,
"sampleEnd": 30356,
"sampleRate": 10000000,
"sampleStart": 27762,
"techType": 257,
"timeEnd": 0.0030356,
"timeStart": 0.0027762
},
{
"dateTime": 0.0054701,
"frameData": "60:08:BD:F7",
"frameFlags": 0,
"framePhase": 259,
"frameRate": 105938,
"frameType": 258,
"sampleEnd": 58249,
"sampleRate": 10000000,
"sampleStart": 54701,
"techType": 257,
"timeEnd": 0.0058249,
"timeStart": 0.0054701
},
{
"dateTime": 0.0061554,
"frameData": "49:B5:18:7D",
"frameFlags": 2,
"framePhase": 259,
"frameRate": 105938,
"frameType": 259,
"sampleEnd": 64999,
"sampleRate": 10000000,
"sampleStart": 61554,
"techType": 257,
"timeEnd": 0.0064999,
"timeStart": 0.0061554
},
{
"dateTime": 0.006886,
"frameData": "20:0D:25:13:4B:39:7A:D1",
"frameFlags": 2,
"framePhase": 259,
"frameRate": 105938,
"frameType": 258,
"sampleEnd": 75751,
"sampleRate": 10000000,
"sampleStart": 68860,
"techType": 257,
"timeEnd": 0.0075751,
"timeStart": 0.006886
},
{
"dateTime": 0.0076657,
"frameData": "43:CD:B2:8F",
"frameFlags": 2,
"framePhase": 259,
"frameRate": 105938,
"frameType": 259,
"sampleEnd": 80149,
"sampleRate": 10000000,
"sampleStart": 76657,
"techType": 257,
"timeEnd": 0.0080149,
"timeStart": 0.0076657
},
{
"dateTime": 0.0084153,
"frameData": "D1:C5:A5:29",
"frameFlags": 2,
"framePhase": 259,
"frameRate": 105938,
"frameType": 258,
"sampleEnd": 87644,
"sampleRate": 10000000,
"sampleStart": 84153,
"techType": 257,
"timeEnd": 0.0087644,
"timeStart": 0.0084153
},
{
"dateTime": 0.00894,
"frameData": "23:90:AA:D6:06:1E:8A:32:96:3A:BD:DB:D8:E0:5E:DA:3B:5B",
"frameFlags": 2,
"framePhase": 259,
"frameRate": 105938,
"frameType": 259,
"sampleEnd": 104739,
"sampleRate": 10000000,
"sampleStart": 89400,
"techType": 257,
"timeEnd": 0.0104739,
"timeStart": 0.00894
}
]
}
Loading

0 comments on commit a954193

Please sign in to comment.