ggwave : update tests

This commit is contained in:
Georgi Gerganov
2022-07-12 23:52:33 +03:00
parent 324b012949
commit a29fb485e1
4 changed files with 11 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ jobs:
run: |
make
ctest --output-on-failure
./bin/test-ggwave-cpp --full
ubuntu-18_04-python:
runs-on: ubuntu-18.04

View File

@@ -214,15 +214,15 @@ bool GGWave_mainLoop() {
if (n <= 0) break;
if (g_filter2) {
GGWave::filter(GGWAVE_FILTER_FIRST_ORDER_HIGH_PASS, data, g_nSamplesPerFrame, 750.0f, GGWave::kDefaultSampleRate, workF2);
GGWave::filter(GGWAVE_FILTER_FIRST_ORDER_HIGH_PASS, data, g_nSamplesPerFrame, 250.0f, GGWave::kDefaultSampleRate, workF2);
}
if (g_filter0) {
GGWave::filter(GGWAVE_FILTER_HANN, data, g_nSamplesPerFrame, 750.0f, GGWave::kDefaultSampleRate, workF0);
GGWave::filter(GGWAVE_FILTER_HANN, data, g_nSamplesPerFrame, 250.0f, GGWave::kDefaultSampleRate, workF0);
}
if (g_filter1) {
GGWave::filter(GGWAVE_FILTER_HAMMING, data, g_nSamplesPerFrame, 750.0f, GGWave::kDefaultSampleRate, workF1);
GGWave::filter(GGWAVE_FILTER_HAMMING, data, g_nSamplesPerFrame, 250.0f, GGWave::kDefaultSampleRate, workF1);
}
if (GGWave::computeFFTR(data, out, g_nSamplesPerFrame, workI, workF) == false) {

View File

@@ -1672,11 +1672,13 @@ void GGWave::decode_variable() {
if ((rsLength.Decode(m_dataEncoded.data(), m_rx.data.data()) == 0) && (m_rx.data[0] > 0 && m_rx.data[0] <= 140)) {
knownLength = true;
decodedLength = m_rx.data[0];
//printf("decoded length = %d, recvDuration_frames = %d\n", decodedLength, m_rx.recvDuration_frames);
const int nTotalBytesExpected = m_encodedDataOffset + decodedLength + ::getECCBytesForLength(decodedLength);
const int nTotalFramesExpected = 2*m_nMarkerFrames + ((nTotalBytesExpected + protocol.bytesPerTx - 1)/protocol.bytesPerTx)*protocol.framesPerTx;
if (m_rx.recvDuration_frames > nTotalFramesExpected ||
m_rx.recvDuration_frames < nTotalFramesExpected - 2*m_nMarkerFrames) {
//printf(" - invalid number of frames: %d (expected %d)\n", m_rx.recvDuration_frames, nTotalFramesExpected);
knownLength = false;
break;
}

View File

@@ -265,7 +265,9 @@ int main(int argc, char ** argv) {
auto parameters = GGWave::getDefaultParameters();
parameters.sampleFormatInp = formatInp;
parameters.sampleFormatOut = formatOut;
if (rand() % 2 == 0) parameters.operatingMode |= GGWAVE_OPERATING_MODE_USE_DSS;
// it seems DSS is not suitable for "variable-length" transmission
// sometimes, the decoder incorrectly detects an early "end" marker when DSS is enabled
//if (rand() % 2 == 0) parameters.operatingMode |= GGWAVE_OPERATING_MODE_USE_DSS;
GGWave instance(parameters);
instance.rxProtocols().only(GGWave::ProtocolId(protocolId));
@@ -275,6 +277,7 @@ int main(int argc, char ** argv) {
printf("Expected = %d, actual = %d\n", expectedSize, nBytes);
CHECK(expectedSize == nBytes);
{ auto p = (const uint8_t *)(instance.txWaveform()); buffer.resize(nBytes); memcpy(buffer.data(), p, nBytes); }
addNoiseHelper(0.02, parameters.sampleFormatOut); // add some artificial noise
convertHelper(formatOut, formatInp);
instance.decode(buffer.data(), buffer.size());
@@ -303,6 +306,7 @@ int main(int argc, char ** argv) {
printf("Expected = %d, actual = %d\n", expectedSize, nBytes);
CHECK(expectedSize == nBytes);
{ auto p = (const uint8_t *)(instance.txWaveform()); buffer.resize(nBytes); memcpy(buffer.data(), p, nBytes); }
addNoiseHelper(0.10, parameters.sampleFormatOut); // add some artificial noise
convertHelper(formatOut, formatInp);
instance.decode(buffer.data(), buffer.size());