This commit is contained in:
Devaev Maxim 2018-09-16 00:41:30 +03:00
parent 1ebe26fd08
commit c1d4356fd3
5 changed files with 16 additions and 14 deletions

View File

@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -c -Wall -Wextra -DDEBUG
CFLAGS = -c -Wall -Wextra
LDFLAGS =
SOURCES = $(shell ls src/*.c)
OBJECTS = $(SOURCES:.c=.o)

View File

@ -3,8 +3,8 @@
#include <sys/select.h>
#include <linux/videodev2.h>
#include "device.h"
#include "tools.h"
#include "device.h"
static int _capture_init_loop(struct device *dev);

View File

@ -9,8 +9,8 @@
#include <sys/mman.h>
#include <linux/videodev2.h>
#include "device.h"
#include "tools.h"
#include "device.h"
static const char DEFAULT_DEVICE[] = "/dev/video0";

View File

@ -6,9 +6,9 @@
#include <signal.h>
#include <getopt.h>
#include "tools.h"
#include "device.h"
#include "capture.h"
#include "tools.h"
static const char _short_opts[] = "hd:f:s:e:tb:q:";
@ -26,6 +26,7 @@ static const struct option _long_opts[] = {
{"height", required_argument, NULL, 1001},
{"v4l2-timeout", required_argument, NULL, 1002},
{"v4l2-error-timeout", required_argument, NULL, 1003},
{"debug", no_argument, NULL, 5000},
{NULL, 0, NULL, 0},
};
@ -56,7 +57,7 @@ static void _parse_options(int argc, char *argv[], struct device *dev) {
int index;
int ch;
LOG_DEBUG("Parsing CLI options ...");
debug = false;
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
switch (ch) {
case 0: break;
@ -75,6 +76,7 @@ static void _parse_options(int argc, char *argv[], struct device *dev) {
case 1001: OPT_UNSIGNED(dev->height, "--height");
case 1002: OPT_UNSIGNED(dev->timeout, "--timeout");
case 1003: OPT_UNSIGNED(dev->error_timeout, "--error-timeout");
case 5000: OPT_TRUE(debug);
case 'h': _help(EXIT_SUCCESS); break;
default: _help(EXIT_FAILURE); break;
}

View File

@ -1,25 +1,25 @@
#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
bool debug;
#define SEP_INFO(_x_ch) \
{ for (int _i = 0; _i < 80; ++_i) putchar(_x_ch); putchar('\n'); }
#define LOG_INFO(_x_msg, ...) \
printf("-- INFO -- " _x_msg "\n", ##__VA_ARGS__)
#ifdef DEBUG
# define LOG_DEBUG(_x_msg, ...) \
printf(" DEBUG -- " _x_msg "\n", ##__VA_ARGS__)
# define SEP_DEBUG(_x_ch) \
SEP_INFO(_x_ch)
#else
# define LOG_DEBUG(...)
# define SEP_DEBUG(_x_ch)
#endif
#define LOG_DEBUG(_x_msg, ...) \
if (debug) { printf(" DEBUG -- " _x_msg "\n", ##__VA_ARGS__); }
#define SEP_DEBUG(_x_ch) \
if (debug) { SEP_INFO(_x_ch); }
#define LOG_ERROR(_x_msg, ...) \
printf("** ERROR -- " _x_msg "\n", ##__VA_ARGS__)