Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TEC ApplicationModule
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSK-SW
Infrastructure and Support
TEC
TEC ApplicationModule
Commits
7338eeb0
Commit
7338eeb0
authored
4 years ago
by
Christoph Kampmeyer
Browse files
Options
Downloads
Patches
Plain Diff
TecDummy: Correct byte order for timeout marker
parent
e94c587b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/TecDummy.cc
+9
-8
9 additions, 8 deletions
tests/src/TecDummy.cc
with
9 additions
and
8 deletions
tests/src/TecDummy.cc
+
9
−
8
View file @
7338eeb0
...
...
@@ -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
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment