Skip to content
Snippets Groups Projects
Commit 7338eeb0 authored by Christoph Kampmeyer's avatar Christoph Kampmeyer
Browse files

TecDummy: Correct byte order for timeout marker

parent e94c587b
No related branches found
No related tags found
No related merge requests found
......@@ -22,11 +22,10 @@ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInB
if(bar != TecDummy_bar || address != TecDummy_address_loopDone) return;
if(reg_loopStart != 1) return;
if (loopDoneDelay) {
if(loopDoneDelay) {
loopDoneDelay--;
return;
}
// convert command into string
// FIXME: this can be done better if the DummyRegisterRawAccessor would allow us to use the raw pointer to this...
......@@ -53,13 +52,16 @@ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInB
frameData.erase(endOfFrame);
std::string frameReply{""};
if(!simulateSerialTimeout){
if(!simulateSerialTimeout) {
// perform data processing
frameReply = processFrame(frameData);
}
else{
else {
// In case of timeout, the marker is written to the start of the frame
const uint32_t timeoutMarker{TEC_TIMEOUT};
// The byte order is swapped here to compensate swapping of the reg_command,
// this is neccessary, because the TEC lib checks the timeout marker before
// changing the byte order of the received frame.
const uint32_t timeoutMarker{htonl(TEC_TIMEOUT)};
frameReply = std::string(sizeof(uint32_t), '\0');
std::memcpy(&(frameReply[0]), &timeoutMarker, sizeof(uint32_t));
}
......@@ -68,7 +70,6 @@ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInB
frameReply += "\r";
frameReply += std::string(frameLength - frameReply.size(), '\0');
reply += frameReply;
}
assert(reply.size() == nFrames * frameLength);
......@@ -78,7 +79,6 @@ void TecDummy::read(uint8_t bar, uint32_t address, int32_t* data, size_t sizeInB
std::memcpy(&word, &(reply[4 * i]), 4);
reg_command[i] = htonl(word);
}
*data = 1;
}
......@@ -165,7 +165,8 @@ std::string TecDummy::processFrame(const std::string& command) {
// Handle store command
int32_t value = std::stol("0x" + parsedFrame[TecFramePart::PAYLOAD], nullptr, 16);
std::cout << "Storing raw value " << value << "(" << parsedFrame[TecFramePart::PAYLOAD] << ") for parameter " << parameterId << std::endl;
std::cout << "Storing raw value " << value << "(" << parsedFrame[TecFramePart::PAYLOAD] << ") for parameter "
<< parameterId << std::endl;
rawValues[parameterId] = value;
result = "!" + parsedFrame[TecFramePart::ADDRESS] + parsedFrame[TecFramePart::SEQUENCE];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment