Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Libcoincellhell
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
Libcoincellhell
Commits
6a90d7be
Commit
6a90d7be
authored
1 year ago
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
add the ability to start ramps to the cli
parent
8d489866
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.c
+34
-0
34 additions, 0 deletions
main.c
with
34 additions
and
0 deletions
main.c
+
34
−
0
View file @
6a90d7be
...
...
@@ -30,6 +30,7 @@
#include
<stdlib.h>
#include
<string.h>
#include
<signal.h>
#include
<time.h>
#include
"coincellhell/coincellhell.h"
#include
"options.h"
...
...
@@ -39,6 +40,7 @@ static void print_commands(void)
{
puts
(
"Valid commands:"
);
puts
(
"set [HEATER] [TEMP]
\t
| set the temperature setpoint of the given heater"
);
puts
(
"ramp [HEATER] [TEMP] [SECONDS] | ramp to the given temperature in given seconds"
);
puts
(
"get [HEATER] [LOCATION]
\t
| get the temperature of the given heater"
);
puts
(
"get_setpoint [HEATER]
\t
| get the temperature setpoint of the given heater"
);
puts
(
"state
\t\t\t
| get the state of eatch heater"
);
...
...
@@ -62,6 +64,18 @@ static int convert_string_to_heater_id(const char* str)
return
id
;
}
static
long
convert_string_to_seconds
(
const
char
*
str
)
{
char
*
str_end
;
long
seconds
=
strtol
(
str
,
&
str_end
,
10
);
if
(
str
==
str_end
||
seconds
<
0
)
{
puts
(
"SECONDS must be a whole nummber above 0"
);
return
-
1
;
}
return
seconds
;
}
static
float
convert_string_to_temperature
(
const
char
*
str
)
{
char
*
str_end
;
...
...
@@ -108,6 +122,26 @@ static int process_commands(char** commands, size_t command_count, struct coince
ret
=
coincellhell_set_temperature
(
hell
,
id
,
temperature
);
}
else
if
(
strcmp
(
commands
[
0
],
"ramp"
)
==
0
)
{
if
(
command_count
<
4
)
printf
(
"Usage %s %s [HEATER] [TEMPERATURE] [SECONDS]
\n
"
,
name
,
commands
[
0
]);
int
id
=
convert_string_to_heater_id
(
commands
[
1
]);
if
(
id
<
0
)
return
1
;
float
temperature
=
convert_string_to_temperature
(
commands
[
2
]);
if
(
temperature
==
FLT_MIN
)
return
2
;
long
seconds
=
convert_string_to_seconds
(
commands
[
3
]);
if
(
seconds
<
0
)
return
2
;
time_t
endtime
=
time
(
NULL
)
+
seconds
;
ret
=
coincellhell_set_temperature_ramp
(
hell
,
id
,
endtime
,
temperature
);
}
else
if
(
strcmp
(
commands
[
0
],
"get"
)
==
0
)
{
if
(
command_count
==
1
)
...
...
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