Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RBComb Temperature Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
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
Pascal Engeler
RBComb Temperature Control
Commits
c61a23e9
Commit
c61a23e9
authored
2 weeks ago
by
Sebastian Huber
Browse files
Options
Downloads
Patches
Plain Diff
Changed flushing and send size of different vector for logging
parent
c7521171
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
firmware/drivers/communicator/communicator.cpp
+11
-18
11 additions, 18 deletions
firmware/drivers/communicator/communicator.cpp
with
11 additions
and
18 deletions
firmware/drivers/communicator/communicator.cpp
+
11
−
18
View file @
c61a23e9
...
...
@@ -22,6 +22,13 @@ std::vector<char> Communicator::arg_ = std::vector<char>(256, '\0'); //arguments
unsigned
long
Communicator
::
last_transaction_ms_
=
0u
;
//time of last transaction
unsigned
long
Communicator
::
interval_assume_eow_ms_
=
1800000u
;
//no transaction for 30 minutes means we shut down
extern
"C"
char
*
sbrk
(
int
i
);
double
checkFreeMemory
()
{
char
stack_dummy
=
0
;
return
static_cast
<
double
>
(
&
stack_dummy
-
sbrk
(
0
));
}
bool
Communicator
::
communicate
(){
if
(
!
serialCharAvailable_
()){
//no communication
if
(
msElapsedSinceLastTransaction_
()
>
interval_assume_eow_ms_
){
...
...
@@ -55,18 +62,15 @@ bool Communicator::communicate(){
}
if
(
PTimer
::
elapsed
()
>=
timeout_us_
){
handleTimeout_
();
//timeout
flushSerialBuffer_
();
return
false
;
}
else
if
(
i
>=
arg_
.
size
()
-
10
){
handleInputOverflow_
();
//input overflow
flushSerialBuffer_
();
return
false
;
}
//apply the setting
else
{
handleSetCommand_
();
flushSerialBuffer_
();
return
true
;
}
}
...
...
@@ -74,15 +78,15 @@ bool Communicator::communicate(){
if
(
cmd_
==
't'
){
//getTemperature
snprintf
(
outbuf_
,
255
,
"%f,%f,%f,%f,%f;"
,
"%f,%f,%f,%f,%f
,%f
;"
,
Temperatures
::
temperatures
[
0
],
Temperatures
::
temperatures
[
1
],
Temperatures
::
temperatures
[
2
],
Temperatures
::
temperatures
[
3
],
Temperatures
::
temperatures
[
4
]
Temperatures
::
temperatures
[
4
],
Communicator
::
arg_
.
capacity
()
);
sendBuf_
();
flushSerialBuffer_
();
return
true
;
}
else
if
(
cmd_
==
'p'
){
//getPidCoeff
...
...
@@ -95,7 +99,6 @@ bool Communicator::communicate(){
kpids
[
2
]
);
sendBuf_
();
flushSerialBuffer_
();
return
true
;
}
else
if
(
cmd_
==
'v'
){
//getPropIntDer
...
...
@@ -108,35 +111,29 @@ bool Communicator::communicate(){
pids
[
2
]
);
sendBuf_
();
flushSerialBuffer_
();
return
true
;
}
else
if
(
cmd_
==
'o'
){
//getOutput
snprintf
(
outbuf_
,
255
,
"%f;"
,
Pid_controller
::
get_output
());
sendBuf_
();
flushSerialBuffer_
();
return
true
;
}
else
if
(
cmd_
==
's'
){
//getSetpoint
snprintf
(
outbuf_
,
255
,
"%f;"
,
Pid_controller
::
get_setpoint
());
sendBuf_
();
flushSerialBuffer_
();
return
true
;
}
else
{
//invalid command
handleInvalidCommand_
();
flushSerialBuffer_
();
return
false
;
}
}
else
if
(
isNopCommand_
()){
handleNopCommand_
();
flushSerialBuffer_
();
return
true
;
}
else
{
//invalid command
handleInvalidCommand_
();
flushSerialBuffer_
();
return
false
;
}
}
...
...
@@ -179,6 +176,7 @@ char Communicator::getSerialChar_(){
void
Communicator
::
sendBuf_
(){
SERCHAN
.
write
(
outbuf_
);
SERCHAN
.
flush
();
}
void
Communicator
::
handleTimeout_
(){
...
...
@@ -257,8 +255,3 @@ unsigned long Communicator::msElapsedSinceLastTransaction_(){
}
void
Communicator
::
flushSerialBuffer_
(){
while
(
SERCHAN
.
available
())
{
SERCHAN
.
read
();
// Dump any remaining data
}
}
\ No newline at end of file
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