From d299d44f88dfbacbc84ac1d99125c94e4eef9b7a Mon Sep 17 00:00:00 2001 From: Martin Hierholzer <martin.hierholzer@desy.de> Date: Mon, 23 Mar 2020 13:51:02 +0100 Subject: [PATCH] instantiate tec lib classes properly, fix byte orders in dummy --- modules/src/TecModule.cc | 25 ++++++++++++++++++++++++- tests/src/TecDummy.cc | 9 +++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/modules/src/TecModule.cc b/modules/src/TecModule.cc index b48f181..5626b17 100644 --- a/modules/src/TecModule.cc +++ b/modules/src/TecModule.cc @@ -1,6 +1,7 @@ #include "TecModule.h" #include "TecParameters.h" #include <tec/TecChimeraInterface.h> +#include <tec/TecController.h> /**********************************************************************************************************************/ @@ -24,7 +25,29 @@ TecModule::TecModule(EntityOwner* owner, const std::string& name, const std::str void TecModule::mainLoop() { std::cout << "Processing TecModule::mainLoop()" << std::endl; - TecChimeraInterface tec{triggerCommands, responseStatus, commandMemoryRaw, true}; + auto tecIface = std::make_shared<TecChimeraInterface>( + triggerCommands, responseStatus, commandMemoryRaw_wr, commandMemoryRaw_rd, true); + TecController tec{tecIface}; + tec.addFrame(0, TecFrame::TecParameter::ExpFanControlEnable, TecFrame::TecFrameType::TecParameterValueSet, 1); + std::cout << "constructAllFrames:" << std::endl; + tec.constructAllFrames(); + for(uint8_t i = 0; i < tec.getFrameCount(); i++) { + tec.getFrameAt(i)->print(); + } + std::cout << "copyCommandsToHardware:" << std::endl; + tec.copyCommandsToHardware(); + std::cout << "triggerHardwareCommands:" << std::endl; + tec.triggerHardwareCommands(); + std::cout << "readHardwareResponses:" << std::endl; + tec.readHardwareResponses(); + std::cout << "copyResponsesFromHardware:" << std::endl; + tec.copyResponsesFromHardware(); + std::cout << "parseAllFrames:" << std::endl; + tec.parseAllFrames(); + for(uint8_t i = 0; i < tec.getFrameCount(); i++) { + tec.getFrameAt(i)->print(); + } + std::cout << "done." << std::endl; // Here the group maps need to be filled by iterating the descriptor list and obtaining the corresponding inputs from // the groupCommandMap diff --git a/tests/src/TecDummy.cc b/tests/src/TecDummy.cc index 19565ea..ff510a9 100644 --- a/tests/src/TecDummy.cc +++ b/tests/src/TecDummy.cc @@ -1,4 +1,5 @@ #include "TecDummy.h" +#include <arpa/inet.h> TecDummy::BackendRegisterer TecDummy::backendRegisterer; @@ -12,15 +13,19 @@ TecDummy::BackendRegisterer::BackendRegisterer() { /*********************************************************************************************************************/ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInBytes) { + std::cout << "HIER0" << std::endl; DummyBackend::read(bar, address, data, sizeInBytes); + std::cout << "HIER1" << std::endl; if(bar != TecDummy_bar || address != TecDummy_address_loopDone) return; + std::cout << "HIER2" << std::endl; if(reg_loopStart != 1) return; + std::cout << "HIER3" << std::endl; // convert command into string // FIXME: this can be done better if the DummyRegisterRawAccessor would allow us to use the raw pointer to this... std::string commandString(reg_command.getNumberOfElements() * 4, 0); for(size_t i = 0; i < reg_command.getNumberOfElements(); ++i) { - uint32_t word = reg_command[i]; + uint32_t word = ntohl(reg_command[i]); std::memcpy(&(commandString[4 * i]), &word, 4); } @@ -31,7 +36,7 @@ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInB for(size_t i = 0; i < reply.length(); ++i) { uint32_t word; std::memcpy(&word, &(reply[4 * i]), 4); - reg_command[i] = word; + reg_command[i] = htonl(word); } reg_loopDone = 1; -- GitLab