Skip to content
Snippets Groups Projects
Commit 351b1558 authored by jp7g21's avatar jp7g21
Browse files

Read mode

parent 90559b09
No related branches found
No related tags found
No related merge requests found
...@@ -94,9 +94,8 @@ int main(int argc, char **argv) ...@@ -94,9 +94,8 @@ int main(int argc, char **argv)
} }
} }
if (read_mode) { if (read_mode) {
while (1) { read_duck_to_stdout();
char c; }
if (read(duckfd, &c, 1) != 1) err(
close_duck(); close_duck();
return 0; return 0;
} }
......
...@@ -88,6 +88,15 @@ int duck_set_velocity(int motor, int deg_per_sec, int ms) ...@@ -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); 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) void close_duck(void)
{ {
if (duck_debug_mode) { if (duck_debug_mode) {
......
...@@ -16,6 +16,7 @@ void configure_duck(void); ...@@ -16,6 +16,7 @@ void configure_duck(void);
int duck_set_position(int motor, int angle); int duck_set_position(int motor, int angle);
int duck_delay(int ms); int duck_delay(int ms);
int duck_set_velocity(int motor, int deg_per_sec, int ms); int duck_set_velocity(int motor, int deg_per_sec, int ms);
void read_duck_to_stdout(void);
void close_duck(void); void close_duck(void);
#endif /* _LIBDUCK_H */ #endif /* _LIBDUCK_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment