aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/kinet.h
blob: a93c57619fea86da1d263df1aaf1ac44b7debd25 (plain)
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
#include "midimonster.h"

MM_PLUGIN_API int init();
static int kinet_configure(char* option, char* value);
static int kinet_configure_instance(instance* inst, char* option, char* value);
static int kinet_instance(instance* inst);
static channel* kinet_channel(instance* inst, char* spec, uint8_t flags);
static int kinet_set(instance* inst, size_t num, channel** c, channel_value* v);
static int kinet_handle(size_t num, managed_fd* fds);
static int kinet_start(size_t n, instance** inst);
static int kinet_shutdown(size_t n, instance** inst);

#define KINET_PORT "6038"
#define KINET_MAGIC htobe32(0x0401dc4a)

enum {
	kinet_op_dmx = 0x0101, //v1
	kinet_op_out = 0x0108 //v2
};

//As a byproduct of the sparse documentation, a lot of these
//fields are educated guesses.

#pragma pack(push, 1)
typedef struct /*_kinet_header*/ {
	uint8_t magic[4]; //04 01 dc 4a
	uint16_t version; //01 00
	uint16_t op; //08 01
	uint32_t seq; //00 00 00 00
	uint8_t output_port; //00 //FIXME verify this / usage?
	uint8_t pad; //00
	uint16_t flags; //00 00
} kinet_frame_hdr;

typedef struct /*_kinet_dmx*/ {
	uint32_t offset;
	uint8_t universe;
	uint8_t startcode; //FIXME test this 
	uint8_t data[512];
} kinet_dmx;

typedef struct /*_kinet_out*/ {
	uint8_t port;
	uint8_t padding;
	uint16_t flags;
	uint16_t length;
	uint16_t code;
	uint8_t data[512];
} kinet_out;
#pragma pack(pop)

typedef struct /*_kinet_instance_data*/ {
	size_t n;
} kinet_instance_data;