forked from gfto/videohubctrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.h
94 lines (81 loc) · 2.19 KB
/
cmd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* === Commands processing ===
*
* Blackmagic Design Videohub control application
* Copyright (C) 2014 Unix Solutions Ltd.
* Written by Georgi Chorbadzhiyski
*
* Released under MIT license.
* See LICENSE-MIT.txt for license terms.
*
*/
#ifndef CMD_H
#define CMD_H
#include <stdbool.h>
#define NUM_COMMANDS 24
enum vcmd {
CMD_PROTOCOL_PREAMBLE,
CMD_VIDEOHUB_DEVICE,
CMD_INPUT_LABELS,
CMD_OUTPUT_LABELS,
CMD_VIDEO_OUTPUT_LOCKS,
CMD_VIDEO_OUTPUT_ROUTING,
CMD_VIDEO_INPUT_STATUS,
CMD_VIDEO_OUTPUT_STATUS,
CMD_MONITORING_OUTPUT_LABELS,
CMD_MONITORING_OUTPUT_LOCKS,
CMD_MONITORING_OUTPUT_ROUTING,
CMD_SERIAL_PORT_LABELS,
CMD_SERIAL_PORT_LOCKS,
CMD_SERIAL_PORT_ROUTING,
CMD_SERIAL_PORT_STATUS,
CMD_SERIAL_PORT_DIRECTIONS,
CMD_PROCESSING_UNIT_ROUTING,
CMD_PROCESSING_UNIT_LOCKS,
CMD_FRAME_LABELS,
CMD_FRAME_BUFFER_ROUTING,
CMD_FRAME_BUFFER_LOCKS,
CMD_PING,
CMD_ACK,
CMD_NAK = (NUM_COMMANDS - 1),
};
enum cmd_flags {
PARSE_NONE, /* The result if this command needs no parsing */
PARSE_CUSTOM, /* Use custom parser for this command */
PARSE_LABEL, /* Parse [port_num] [port_text] */
PARSE_STATUS, /* Parse [port_num] [port_status] */
PARSE_ROUTE, /* Parse [port_num] [dest_port] */
PARSE_LOCK, /* Parse [port_num] [dest_slot] */
PARSE_DIR, /* Parse [port_num] [port_direction] - for serial ports */
};
struct videohub_commands {
enum vcmd cmd;
enum cmd_flags type;
size_t ports1;
size_t ports2;
const char *port_id1;
const char *port_id2;
const char *opt_prefix;
bool allow_disconnect;
};
extern struct videohub_commands videohub_commands[NUM_COMMANDS];
bool parse_command(struct videohub_data *d, char *cmd);
int parse_text_buffer(struct videohub_data *data, char *cmd_buffer);
struct vcmd_param {
char *param;
unsigned int port_no;
};
struct vcmd_entry {
struct videohub_commands *cmd;
struct vcmd_param p1;
struct vcmd_param p2;
bool do_lock;
enum port_lock lock;
enum serial_dir direction;
bool clear_port;
bool reversed_args;
};
void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e);
void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz);
void show_cmd(struct videohub_data *d, struct vcmd_entry *e);
#endif