hostsim enhancements, some bugs remaining (freeze sometimes)
[aversive.git] / projects / microb2010 / tests / hostsim / robotsim.c
index 990104b..85224a3 100644 (file)
@@ -22,8 +22,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
-#include <sys/types.h>
+#include <unistd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <fcntl.h>
 #include <unistd.h>
 
@@ -111,11 +112,13 @@ void robotsim_dump(void)
        char buf[BUFSIZ];
        int len;
 
-       len =snprintf(buf, sizeof(buf), "%d %d %d\n",
+       len = snprintf(buf, sizeof(buf), "%d %d %d\n",
                      position_get_x_s16(&mainboard.pos),
                      position_get_y_s16(&mainboard.pos),
                      position_get_a_deg_s16(&mainboard.pos));
+       hostsim_lock();
        write(fd, buf, len);
+       hostsim_unlock();
 }
 
 void robotsim_pwm(void *arg, int32_t val)