-
Notifications
You must be signed in to change notification settings - Fork 48
/
TestGen.cpp
52 lines (45 loc) · 1.16 KB
/
TestGen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2016-2016 Lime Microsystems
// SPDX-License-Identifier: BSL-1.0
#include <Pothos/Framework.hpp>
#include <iostream>
#include <cstring>
/***********************************************************************
* |PothosDoc LoRa Test Gen
*
* Generate test messages for the LoRa encoder for testing purposes.
*
* |category /LoRa
* |keywords lora
*
* |factory /lora/test_gen()
**********************************************************************/
class TestGen : public Pothos::Block
{
public:
TestGen(void)
{
this->setupOutput(0);
}
static Block *make(void)
{
return new TestGen();
}
void activate(void)
{
_count = 0;
}
void work(void)
{
auto msgStr = std::to_string(_count++);
Pothos::BufferChunk msgBuff(typeid(uint8_t), msgStr.size());
std::memcpy(msgBuff.as<void *>(), msgStr.data(), msgStr.size());
Pothos::Packet outPkt;
outPkt.payload = msgBuff;
this->output(0)->postMessage(outPkt);
}
private:
//configuration
unsigned long long _count;
};
static Pothos::BlockRegistry registerTestGen(
"/lora/test_gen", &TestGen::make);