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:
10
src/plugins/serialoutput/CMakeLists.txt
Normal file
10
src/plugins/serialoutput/CMakeLists.txt
Normal 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})
|
||||||
33
src/plugins/serialoutput/SerialOutput.cc
Normal file
33
src/plugins/serialoutput/SerialOutput.cc
Normal 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;
|
||||||
|
}
|
||||||
49
src/plugins/serialoutput/SerialOutput.hpp
Normal file
49
src/plugins/serialoutput/SerialOutput.hpp
Normal 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__
|
||||||
Reference in New Issue
Block a user