From 5eca26af7fc0e0741a1e2111700bd8adc8e02520 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 May 2019 22:30:07 -0300 Subject: [PATCH] changes in .h to work with ofxEtherdream --- driver/libetherdream/etherdream.c | 89 ---------------------------- driver/libetherdream/etherdream.h | 98 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 89 deletions(-) diff --git a/driver/libetherdream/etherdream.c b/driver/libetherdream/etherdream.c index 04d5283..484f4d1 100644 --- a/driver/libetherdream/etherdream.c +++ b/driver/libetherdream/etherdream.c @@ -16,98 +16,9 @@ * along with this program. If not, see . */ -#define _POSIX_C_SOURCE 199309L -#define _DARWIN_C_SOURCE 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __MACH__ -#include -#include -#endif -#include #include "etherdream.h" -#define BUFFER_POINTS_PER_FRAME 16000 -#define BUFFER_NFRAMES 2 -#define MAX_LATE_ACKS 64 -#define MIN_SEND_POINTS 40 -#define DEFAULT_TIMEOUT 2000000 -#define DEBUG_THRESHOLD_POINTS 800 - -struct etherdream_conn { - int dc_sock; - char dc_read_buf[1024]; - int dc_read_buf_size; - struct dac_response resp; - long long dc_last_ack_time; - - struct { - struct queue_command queue; - struct data_command_header header; - struct dac_point data[1000]; - } __attribute__((packed)) dc_local_buffer; - - int dc_begin_sent; - int ackbuf[MAX_LATE_ACKS]; - int ackbuf_prod; - int ackbuf_cons; - int unacked_points; - int pending_meta_acks; -}; - -struct buffer_item { - struct dac_point data[BUFFER_POINTS_PER_FRAME]; - int points; - int pps; - int repeatcount; - int idx; -}; - -enum dac_state { - ST_DISCONNECTED, - ST_READY, - ST_RUNNING, - ST_BROKEN, - ST_SHUTDOWN -}; - -struct etherdream { - pthread_mutex_t mutex; - pthread_cond_t loop_cond; - - struct buffer_item buffer[BUFFER_NFRAMES]; - int frame_buffer_read; - int frame_buffer_fullness; - int bounce_count; - - pthread_t workerthread; - - struct in_addr addr; - struct etherdream_conn conn; - unsigned long dac_id; - int sw_revision; - char mac_address[6]; - char version[32]; - - enum dac_state state; - - struct etherdream * next; -}; static FILE *trace_fp = NULL; #if __MACH__ diff --git a/driver/libetherdream/etherdream.h b/driver/libetherdream/etherdream.h index 1cadeb9..bc11c27 100644 --- a/driver/libetherdream/etherdream.h +++ b/driver/libetherdream/etherdream.h @@ -7,6 +7,39 @@ extern "C" { #include + +#define _POSIX_C_SOURCE 199309L +#define _DARWIN_C_SOURCE 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __MACH__ +#include +#include +#endif + +#include + +#define BUFFER_POINTS_PER_FRAME 16000 +#define BUFFER_NFRAMES 2 +#define MAX_LATE_ACKS 64 +#define MIN_SEND_POINTS 40 +#define DEFAULT_TIMEOUT 2000000 +#define DEBUG_THRESHOLD_POINTS 800 + struct etherdream_point { int16_t x; int16_t y; @@ -18,6 +51,71 @@ struct etherdream_point { uint16_t u2; }; +enum dac_state { + ST_DISCONNECTED, + ST_READY, + ST_RUNNING, + ST_BROKEN, + ST_SHUTDOWN +}; + +struct etherdream_conn { + int dc_sock; + char dc_read_buf[1024]; + int dc_read_buf_size; + struct dac_response resp; + long long dc_last_ack_time; + + struct { + struct queue_command queue; + struct data_command_header header; + struct dac_point data[1000]; + } __attribute__((packed)) dc_local_buffer; + + int dc_begin_sent; + int ackbuf[MAX_LATE_ACKS]; + int ackbuf_prod; + int ackbuf_cons; + int unacked_points; + int pending_meta_acks; +}; + + + + + +struct buffer_item { + struct dac_point data[BUFFER_POINTS_PER_FRAME]; + int points; + int pps; + int repeatcount; + int idx; +}; + + +struct etherdream { + pthread_mutex_t mutex; + pthread_cond_t loop_cond; + + struct buffer_item buffer[BUFFER_NFRAMES]; + int frame_buffer_read; + int frame_buffer_fullness; + int bounce_count; + + pthread_t workerthread; + + struct in_addr addr; + struct etherdream_conn conn; + unsigned long dac_id; + int sw_revision; + char mac_address[6]; + char version[32]; + + enum dac_state state; + + struct etherdream * next; +}; + struct etherdream; /* etherdream_lib_start()