Line data Source code
1 : #include <unistd.h> // usleep
2 : #include <cstdio> // printf
3 : #include <cstdlib> // strtoul
4 : #include <iostream>
5 : #include <string>
6 :
7 : #include "DTCSoftwareCFO.h"
8 :
9 : #include "TRACE/tracemf.h"
10 :
11 0 : void printHelpMsg()
12 : {
13 0 : std::cout << "Usage: requestSender [options]" << std::endl;
14 0 : std::cout << "Options are:" << std::endl
15 0 : << " -h: This message." << std::endl
16 0 : << " -n: Number of times to repeat test. (Default: 1)" << std::endl
17 0 : << " -o: Starting Timestamp offest. (Default: 1)." << std::endl
18 0 : << " -i: Do not increment Timestamps." << std::endl
19 0 : << " -d: Delay between tests, in us (Default: 0)." << std::endl
20 0 : << " -c: Number of Debug Packets to request (Default: 0)." << std::endl
21 0 : << " -q: Quiet mode (Don't print)" << std::endl;
22 0 : exit(0);
23 : }
24 :
25 0 : int main(int argc, char* argv[])
26 : {
27 0 : DTCLib::DTC theDTC;
28 0 : DTCLib::DTCSoftwareCFO theEmulator(&theDTC, false);
29 :
30 0 : auto incrementTimestamp = true;
31 0 : auto quiet = false;
32 0 : unsigned delay = 0;
33 0 : unsigned number = 1;
34 0 : unsigned timestampOffset = 1;
35 0 : unsigned packetCount = 0;
36 :
37 0 : for (auto optind = 1; optind < argc; ++optind)
38 : {
39 0 : if (argv[optind][0] == '-')
40 : {
41 0 : switch (argv[optind][1])
42 : {
43 0 : case 'i':
44 0 : incrementTimestamp = false;
45 0 : break;
46 0 : case 'd':
47 0 : delay = DTCLib::Utilities::getOptionValue(&optind, &argv);
48 0 : break;
49 0 : case 'n':
50 0 : number = DTCLib::Utilities::getOptionValue(&optind, &argv);
51 0 : break;
52 0 : case 'o':
53 0 : timestampOffset = DTCLib::Utilities::getOptionValue(&optind, &argv);
54 0 : break;
55 0 : case 'c':
56 0 : packetCount = DTCLib::Utilities::getOptionValue(&optind, &argv);
57 0 : break;
58 0 : case 'q':
59 0 : quiet = true;
60 0 : break;
61 0 : default:
62 0 : std::cout << "Unknown option: " << argv[optind] << std::endl;
63 0 : printHelpMsg();
64 0 : break;
65 0 : case 'h':
66 0 : printHelpMsg();
67 0 : break;
68 : }
69 : }
70 : }
71 :
72 0 : std::string incrementStr = incrementTimestamp ? "true" : "false";
73 0 : std::string quietStr = quiet ? "true" : "false";
74 : std::cout << "Options are: "
75 0 : << "Num: " << number << ", Delay: " << delay << ", TS Offset: " << timestampOffset
76 0 : << ", PacketCount: " << packetCount << ", Increment TS: " << incrementStr << ", Quiet Mode: " << quietStr
77 0 : << std::endl;
78 :
79 0 : theEmulator.setQuiet(quiet);
80 0 : theEmulator.setDebugPacketCount(packetCount);
81 :
82 0 : if (number > 1)
83 : {
84 0 : theEmulator.SendRequestsForRange(number, DTCLib::DTC_EventWindowTag(timestampOffset), incrementTimestamp, delay);
85 : }
86 : else
87 : {
88 0 : theEmulator.SendRequestForTimestamp(DTCLib::DTC_EventWindowTag(timestampOffset));
89 : }
90 0 : }
|