Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
8b8e62f6
Commit
8b8e62f6
authored
Apr 16, 2021
by
Eric Duminil
Browse files
Slowly getting there
parent
c6e6f831
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/sensor_commands.cpp
View file @
8b8e62f6
...
...
@@ -27,15 +27,44 @@ namespace sensor_commands {
}
bool
startsWith
(
const
char
*
a
,
const
char
*
b
)
{
if
(
strncmp
(
a
,
b
,
strlen
(
b
))
==
0
)
return
1
;
return
!
strncmp
(
a
,
b
,
strlen
(
b
));
}
bool
parseCommand
(
const
char
*
c
,
char
*
fname
,
long
*
param
)
{
return
0
;
}
void
run
(
const
char
*
command
)
{
Serial
.
print
(
F
(
"Received command : '"
));
void
run
(
const
char
*
c
)
{
char
command
[
30
];
char
*
function_name
;
long
parameter
;
parseCommand
(
c
,
function_name
,
&
parameter
);
strlcpy
(
command
,
c
,
30
);
Serial
.
print
(
F
(
"Received : '"
));
Serial
.
print
(
command
);
Serial
.
println
(
"'"
);
char
*
arg
;
function_name
=
strtok
(
command
,
" "
);
if
(
!
function_name
)
{
// Empty string
return
;
}
arg
=
strtok
(
NULL
,
" "
);
if
(
arg
)
{
char
*
end
;
parameter
=
strtol
(
arg
,
&
end
,
10
);
if
(
*
end
)
{
// Second argument isn't a number
parameter
=
-
9999
;
}
}
else
{
parameter
=
-
9999
;
}
Serial
.
print
(
"Command : '"
);
Serial
.
print
(
function_name
);
Serial
.
print
(
"'. Parameter : "
);
Serial
.
println
(
parameter
);
// Test all the callbacks.
for
(
uint8_t
i
=
0
;
i
<
callbacks_count
;
i
++
)
{
if
(
startsWith
(
command
,
callbacks
[
i
].
name
))
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment