summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <colomar.6.4.3@gmail.com>2020-03-03 20:21:38 +0100
committerAlejandro Colomar <colomar.6.4.3@gmail.com>2020-03-03 20:21:38 +0100
commit3067e8af207da1c2cdd1961afa42cc7448c561ae (patch)
treeec430e2a2d7017d183517afb34d94f4c58a7f7f6
parent957cabc4126c89716f9dda074483156728b55140 (diff)
Wait for robcam_0.5.0
-rw-r--r--cam/cam.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/cam/cam.c b/cam/cam.c
index c4acb0c..5b9f464 100644
--- a/cam/cam.c
+++ b/cam/cam.c
@@ -99,6 +99,8 @@ void cv_deinit (img_s *img);
static
int session (int i, img_s *img);
static
+int wait_rob (void);
+static
int proc_cv (uint8_t *restrict blue11, img_s *restrict img);
@@ -300,9 +302,9 @@ int session (int i, img_s *img)
time_0 = clock();
status = -1;
- n = recv(rob, buf, ARRAY_SIZE(cam_data) - 1, 0);
- if (n < 0)
+ if (wait_rob())
goto err;
+ status--;
if (proc_cv(&blue11, img))
goto err;
status--;
@@ -325,6 +327,26 @@ err:
}
static
+int wait_rob (void)
+{
+ char buf[BUFSIZ];
+ ssize_t n;
+ int status;
+
+ status = -1;
+ n = recv(rob, buf, ARRAY_SIZE(buf) - 1, 0);
+ if (n < 0)
+ goto err;
+ status--;
+ if (!n)
+ goto err;
+ return 0;
+err:
+ fprintf(stderr, "cam#%"PRIpid": ERROR: wait_rob(): %i\n", pid, status);
+ return status;
+}
+
+static
int proc_cv (uint8_t *restrict blue11, img_s *restrict img)
{
clock_t time_0;