Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
AcubeSat-OBC
ECSS Services
Commits
aab9e132
Commit
aab9e132
authored
6 years ago
by
Grigoris Pavlakis
Browse files
Options
Downloads
Patches
Plain Diff
Complete basic implementation of parameter setting, untested
parent
a8fd2802
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inc/Services/ParameterService.hpp
+2
-2
2 additions, 2 deletions
inc/Services/ParameterService.hpp
src/Services/ParameterService.cpp
+45
-21
45 additions, 21 deletions
src/Services/ParameterService.cpp
src/main.cpp
+2
-0
2 additions, 0 deletions
src/main.cpp
with
49 additions
and
23 deletions
inc/Services/ParameterService.hpp
+
2
−
2
View file @
aab9e132
...
...
@@ -45,9 +45,9 @@ class ParameterService : public Service {
public:
ParameterService
();
Message
reportParameter
(
Message
paramId
);
Message
reportParameter
Id
(
Message
paramId
);
//
void setParamData(Message
&
newParamValues);
void
setParamData
(
Message
newParamValues
);
};
...
...
This diff is collapsed.
Click to expand it.
src/Services/ParameterService.cpp
+
45
−
21
View file @
aab9e132
...
...
@@ -5,6 +5,7 @@
#ifdef DEMOMODE
#include
<ctime>
#include
<cstdlib>
#endif
...
...
@@ -12,35 +13,32 @@ ParameterService::ParameterService() {
#ifdef DEMOMODE
/**
* Initializes the parameter list with some dummy values for now.
* This normally will be initialized with actual values on boot.
*/
for
(
int
i
=
0
;
i
<
CONFIGLENGTH
;
i
++
)
{
paramsList
[
i
].
paramId
=
0
;
paramsList
[
i
].
settingData
=
0
;
paramsList
[
i
].
pfc
=
1
;
paramsList
[
i
].
ptc
=
1
;
}
// Test code, setting up one of the parameter fields
// Test code, setting up some of the parameter fields
time_t
currTime
=
time
(
nullptr
);
struct
tm
*
today
=
localtime
(
&
currTime
);
paramsList
[
2
].
paramId
=
341
;
// random parameter ID
paramsList
[
2
].
settingData
=
today
->
tm_min
;
// the minute of the current hour
paramsList
[
2
].
ptc
=
3
;
// unsigned int
paramsList
[
2
].
pfc
=
14
;
// 32 bits
paramsList
[
0
].
paramId
=
341
;
// random parameter ID
paramsList
[
0
].
settingData
=
today
->
tm_hour
;
// the current hour
paramsList
[
0
].
ptc
=
3
;
// unsigned int
paramsList
[
0
].
pfc
=
14
;
// 32 bits
paramsList
[
1
].
paramId
=
345
;
// random parameter ID
paramsList
[
1
].
settingData
=
today
->
tm_min
;
// the current minute
paramsList
[
1
].
ptc
=
3
;
// unsigned int
paramsList
[
1
].
pfc
=
14
;
// 32 bits
#endif
}
Message
ParameterService
::
reportParameter
(
Message
paramId
)
{
Message
ParameterService
::
reportParameter
Id
(
Message
paramId
)
{
/**
* This function receives a TC[20, 1] packet and returns a TM[20, 2] packet
* containing the current configuration. No error checking for now, just whether
* the package is of the correct type (in which case it returns an empty message)
* containing the current configuration **for the parameter specified in the carried ID**.
* No sophisticated error checking for now, just whether the package is of the correct type
* (in which case it returns an empty message)
*
* @param paramId: a valid TC[20, 1] packet carrying the requested parameter ID
* @return A TM[20, 2] packet containing the parameter ID
...
...
@@ -57,8 +55,8 @@ Message ParameterService::reportParameter(Message paramId) {
if
(
paramsList
[
i
].
paramId
==
reqParamId
)
{
reqParam
.
appendUint16
(
paramsList
[
i
].
paramId
);
reqParam
.
appendUint32
(
paramsList
[
i
].
settingData
);
reqParam
.
appendUint16
(
paramsList
[
i
].
paramId
);
// first 16 bits are the parameter ID
reqParam
.
appendUint32
(
paramsList
[
i
].
settingData
);
// rest 32 are the current setting
break
;
}
}
...
...
@@ -67,6 +65,32 @@ Message ParameterService::reportParameter(Message paramId) {
return
reqParam
;
}
/*void ParameterService::setParamData(Message& newParamValues) {
void
ParameterService
::
setParamData
(
Message
newParamValues
)
{
/**
* This function receives a TC[20, 3] message and after checking whether its type is correct,
* replaces the setting specified in the settingData field of the parameter with the ID
* contained in the message with the value that the message carries. If the message type is
* not correct, the settings stay as they are.
*
* @param newParamValues: a valid TC[20, 3] message carrying parameter ID and replacement value
* @return None
* @todo Use pointers for changing and storing addresses to comply with the standard
*/
uint16_t
reqParamId
=
newParamValues
.
readUint16
();
if
(
newParamValues
.
packetType
==
Message
::
TC
&&
newParamValues
.
serviceType
==
20
&&
newParamValues
.
messageType
==
1
)
{
}*/
//TODO: Separate searching from rest of code
for
(
int
i
=
0
;
i
<
CONFIGLENGTH
;
i
++
)
{
if
(
paramsList
[
i
].
paramId
==
reqParamId
)
{
paramsList
[
i
].
settingData
=
newParamValues
.
readUint32
();
break
;
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main.cpp
+
2
−
0
View file @
aab9e132
...
...
@@ -31,6 +31,8 @@ int main() {
//ST[20] test
ParameterService
paramService
;
//Test code for reportParameter
Message
sentPacket
=
Message
(
20
,
1
,
Message
::
TC
,
1
);
//application id is a dummy number (1)
sentPacket
.
appendUint16
(
341
);
//the packet sent contains the ID of the desired parameter
Message
returnedPacket
=
paramService
.
reportParameter
(
sentPacket
);
...
...
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