diff options
Diffstat (limited to 'src/profiling/RequestCounterDirectoryCommandHandler.cpp')
-rw-r--r-- | src/profiling/RequestCounterDirectoryCommandHandler.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/profiling/RequestCounterDirectoryCommandHandler.cpp b/src/profiling/RequestCounterDirectoryCommandHandler.cpp index 0fdcf10de4..e85acb4215 100644 --- a/src/profiling/RequestCounterDirectoryCommandHandler.cpp +++ b/src/profiling/RequestCounterDirectoryCommandHandler.cpp @@ -5,7 +5,7 @@ #include "RequestCounterDirectoryCommandHandler.hpp" -#include <boost/assert.hpp> +#include <boost/format.hpp> namespace armnn { @@ -15,10 +15,36 @@ namespace profiling void RequestCounterDirectoryCommandHandler::operator()(const Packet& packet) { - BOOST_ASSERT(packet.GetLength() == 0); - - // Write packet to Counter Stream Buffer - m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory); + ProfilingState currentState = m_StateMachine.GetCurrentState(); + switch (currentState) + { + case ProfilingState::Uninitialised: + case ProfilingState::NotConnected: + case ProfilingState::WaitingForAck: + throw RuntimeException(boost::str(boost::format("Request Counter Directory Handler invoked while in an " + "wrong state: %1%") + % GetProfilingStateName(currentState))); + case ProfilingState::Active: + // Process the packet + if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 3u)) + { + throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 3 but " + "received family = %1%, id = %2%") + % packet.GetPacketFamily() + % packet.GetPacketId())); + } + + // Write a Counter Directory packet to the Counter Stream Buffer + m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory); + + // Notify the Send Thread that new data is available in the Counter Stream Buffer + m_SendCounterPacket.SetReadyToRead(); + + break; + default: + throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%") + % static_cast<int>(currentState))); + } } } // namespace profiling |