Commit 351b1558 authored by jp7g21's avatar jp7g21
Browse files

Read mode

parent 90559b09
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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 */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment