Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jp7g21
duck
Commits
351b1558
Commit
351b1558
authored
Nov 14, 2021
by
jp7g21
Browse files
Read mode
parent
90559b09
Changes
3
Hide whitespace changes
Inline
Side-by-side
duck/duck.c
View file @
351b1558
...
...
@@ -94,9 +94,8 @@ int main(int argc, char **argv)
}
}
if
(
read_mode
)
{
while
(
1
)
{
char
c
;
if
(
read
(
duckfd
,
&
c
,
1
)
!=
1
)
err
(
read_duck_to_stdout
();
}
close_duck
();
return
0
;
}
...
...
libduck/libduck.c
View file @
351b1558
...
...
@@ -88,6 +88,15 @@ int duck_set_velocity(int motor, int deg_per_sec, int ms)
return
duck_printf
(
"v %d %d %d
\n
"
,
motor
,
deg_per_sec
,
ms
);
}
void
read_duck_to_stdout
(
void
)
{
while
(
1
)
{
char
c
;
if
(
read
(
duckfd
,
&
c
,
1
)
!=
1
)
err
(
EXIT_FAILURE
,
"Read failed
\n
"
);
putchar
(
c
);
}
}
void
close_duck
(
void
)
{
if
(
duck_debug_mode
)
{
...
...
libduck/libduck.h
View file @
351b1558
...
...
@@ -16,6 +16,7 @@ void configure_duck(void);
int
duck_set_position
(
int
motor
,
int
angle
);
int
duck_delay
(
int
ms
);
int
duck_set_velocity
(
int
motor
,
int
deg_per_sec
,
int
ms
);
void
read_duck_to_stdout
(
void
);
void
close_duck
(
void
);
#endif
/* _LIBDUCK_H */
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