ArmNN
 20.02
GatordMockMain.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 18 of file GatordMockMain.cpp.

References CommandLineProcessor::GetCommandFile(), Version::GetEncodedValue(), CommandLineProcessor::GetUdsNamespace(), CommandLineProcessor::IsEchoEnabled(), CommandFileParser::ParseFile(), CommandLineProcessor::ProcessCommandLine(), CommandHandlerRegistry::RegisterFunctor(), and PacketVersionResolver::ResolvePacketVersion().

19 {
20  // Process command line arguments
22  if (!cmdLine.ProcessCommandLine(argc, argv))
23  {
24  return EXIT_FAILURE;
25  }
26 
27  armnn::profiling::PacketVersionResolver packetVersionResolver;
28  // Create the Command Handler Registry
30 
31  // This functor will receive back the selection response packet.
32  armnn::gatordmock::PeriodicCounterSelectionResponseHandler periodicCounterSelectionResponseHandler(
33  0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue());
34  // This functor will receive the counter data.
36  3, 0, packetVersionResolver.ResolvePacketVersion(3, 0).GetEncodedValue());
37 
38  armnn::profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
39  0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), false);
40 
41  // Register different derived functors
42  registry.RegisterFunctor(&periodicCounterSelectionResponseHandler);
43  registry.RegisterFunctor(&counterCaptureCommandHandler);
44  registry.RegisterFunctor(&directoryCaptureCommandHandler);
45 
46  armnn::gatordmock::GatordMockService mockService(registry, cmdLine.IsEchoEnabled());
47 
48  if (!mockService.OpenListeningSocket(cmdLine.GetUdsNamespace()))
49  {
50  return EXIT_FAILURE;
51  }
52  std::cout << "Bound to UDS namespace: \\0" << cmdLine.GetUdsNamespace() << std::endl;
53 
54  // Wait for a single connection.
55  if (-1 == mockService.BlockForOneClient())
56  {
57  return EXIT_FAILURE;
58  }
59  std::cout << "Client connection established." << std::endl;
60 
61  // Send receive the strweam metadata and send connection ack.
62  if (!mockService.WaitForStreamMetaData())
63  {
64  return EXIT_FAILURE;
65  }
66  mockService.SendConnectionAck();
67 
68  // Prepare to receive data.
69  mockService.LaunchReceivingThread();
70 
71  // Process the SET and WAIT command from the file.
72  armnn::gatordmock::CommandFileParser commandLineParser;
73  commandLineParser.ParseFile(cmdLine.GetCommandFile(), mockService);
74 
75  // Once we've finished processing the file wait for the receiving thread to close.
76  mockService.WaitForReceivingThread();
77 
78  return EXIT_SUCCESS;
79 }
bool ProcessCommandLine(int argc, char *argv[])
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
void ParseFile(std::string CommandFile, GatordMockService &mockService)
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)
Use Boost program options to process the command line.
A class that implements a Mock Gatord server.
This class parses a command file for the GatordMockService.