new plugin serialoutput

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1452 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
hellwig
2012-07-13 13:49:22 +00:00
parent 2076d21e61
commit 39a82218cc
3 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,10 @@
set(PLUGIN_NAME serialoutput)
set(MY_PLUGIN_SRCS
SerialOutput.cc
SerialOutput.hpp
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
## Build library
add_library(${PLUGIN_NAME} ${MY_PLUGIN_SRCS})

View File

@ -0,0 +1,33 @@
#include <iostream>
#include "SerialOutput.hpp"
using namespace std;
using namespace fail;
bool SerialOutput::run()
{
IOPortListener ev_ioport(m_port, m_out);
BaseListener *ev;
while (true) {
simulator.addListener(&ev_ioport);
ev = simulator.resume();
simulator.removeListener(&ev_ioport);
if (ev == &ev_ioport) {
m_output += ev_ioport.getData();
} else {
break;
}
}
return true;
}
void SerialOutput::resetOutput()
{
m_output.clear();
}
string SerialOutput::getOutput()
{
return m_output;
}

View File

@ -0,0 +1,49 @@
#ifndef __SERIAL_OUTPUT_HPP__
#define __SERIAL_OUTPUT_HPP__
#include <string>
#include "efw/ExperimentFlow.hpp"
#include "config/FailConfig.hpp"
// Check if configuration dependencies are satisfied:
#if !defined(CONFIG_EVENT_IOPORT)
#warning The serialoutput plugin may (depending on its use) need ioport event. Enable these in the cmake configuration tool.
#endif
/**
* \class SerialOutput
*
* \brief Plugin to record ioport traffic.
*/
class SerialOutput : public fail::ExperimentFlow
{
private:
bool m_out; //!< Defines the direction of the listener.
unsigned m_port; //!< the port the listener is listening on
std::string m_output; //!< contains the traffic of ioport
public:
/**
* Constructor of SerialOutput.
*
* @param port the port the listener is listening on
* @param out Defines the direction of the listener.
* \arg \c true Output on the given port is captured.
* \arg \c false Input on the given port is captured.
*/
SerialOutput(unsigned port, bool out) : m_out(out), m_port(port) { }
bool run();
/**
* Resets the output variable which contains the traffic of
* ioport.
*/
void resetOutput();
/**
* Returns the output variable.
*/
std::string getOutput();
};
#endif // __SERIAL_OUTPUT_HPP__