11#include <libtrap/trap.h>
21 : m_interfaceID(interfaceID)
22 , m_prioritizedDataPointer(nullptr)
23 , m_EoFOnNextReceive(false)
30 const void* receivedData;
31 uint16_t dataSize = 0;
43 int errorCode = trap_recv(
m_interfaceID, &receivedData, &dataSize);
44 if (errorCode == TRAP_E_TIMEOUT) {
47 if (errorCode == TRAP_E_FORMAT_CHANGED) {
67 if (errorCode == TRAP_E_OK) {
70 if (errorCode == TRAP_E_NOT_INITIALIZED) {
71 throw std::runtime_error(
72 "UnirecInputInterface::receive() has failed. Trap interface is not initialized.");
74 if (errorCode == TRAP_E_TERMINATED) {
75 throw std::runtime_error(
76 "UnirecInputInterface::receive() has failed. Trap interface is terminated.");
78 if (errorCode == TRAP_E_NOT_SELECTED) {
79 throw std::runtime_error(
80 "UnirecInputInterface::receive() has failed. Interface ID out of range.");
82 throw std::runtime_error(
83 "UnirecInputInterface::receive() has failed. Return code: " + std::to_string(errorCode)
84 +
", msg: " + trap_last_error_msg);
89 int ret = trap_set_required_fmt(
m_interfaceID, TRAP_FMT_UNIREC, templateSpecification.c_str());
90 if (ret != TRAP_E_OK) {
91 throw std::runtime_error(
92 "UnirecInputInterface::setRequieredFormat() has failed. Unable to set required "
99 trap_ifcctl(TRAPIFC_INPUT,
m_interfaceID, TRAPCTL_SETTIMEOUT, timeout);
105 const char* spec =
nullptr;
107 int ret = trap_get_data_fmt(TRAPIFC_INPUT,
m_interfaceID, &dataType, &spec);
108 if (ret != TRAP_E_OK) {
109 throw std::runtime_error(
110 "UnirecInputInterface::changeTemplate() has failed. Data format was not "
116 throw std::runtime_error(
117 "UnirecInputInterface::changeTemplate() has failed. Template could not be "
122 if (ret != TRAP_E_OK) {
123 throw std::runtime_error(
"UnirecInputInterface::changeTemplate() has failed.");
An exception that is thrown when the end of the input stream is reached.
Provides a view into a UniRec record.
ur_template_t * ur_define_fields_and_update_template(const char *ifc_data_fmt, ur_template_t *tmplt)
Defined new fields and expand an UniRec template Define new fields (function ur_define_set_of_fields)...
void ur_free_template(ur_template_t *tmplt)
Destroy UniRec template Free all memory allocated for a template created previously by ur_create_temp...
#define ur_set_input_template(ifc, tmplt)
Set UniRec template to input interface.