Commit 4874c588 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add seperate rx block

parent f1e90f9d
...@@ -181,22 +181,30 @@ static struct controller_block * block_vesp_controller_create(char *name, ...@@ -181,22 +181,30 @@ static struct controller_block * block_vesp_controller_create(char *name,
{ {
struct controller_block *controller; struct controller_block *controller;
struct controller_block *controller_tx; struct controller_block *controller_tx;
struct controller_block *controller_rx;
char *busname = va_arg(ap, char *); char *busname = va_arg(ap, char *);
uint8_t address = va_arg(ap, int); uint8_t address = va_arg(ap, int);
uint8_t vid, dev; uint8_t vid, dev;
char *name_tx; char *name_tmp;
int i; int i;
asprintf(&name_tx, "%s_tx", name);
if (!(controller = controller_block_alloc("vesp_controller", name, sizeof(struct controller_block_private)))) if (!(controller = controller_block_alloc("vesp_controller", name, sizeof(struct controller_block_private))))
return NULL; return NULL;
if (!(controller_tx = controller_block_alloc("vesp_controller_tx", name_tx, 0)))
asprintf(&name_tmp, "%s_rx", name);
if (!(controller_rx = controller_block_alloc("vesp_controller_rx", name_tmp, 0)))
goto err_controller;
free(name_tmp);
controller_rx->private = controller->private;
asprintf(&name_tmp, "%s_tx", name);
if (!(controller_tx = controller_block_alloc("vesp_controller_tx", name_tmp, 0)))
goto err_controller; goto err_controller;
free(name_tx); free(name_tmp);
controller_tx->private = controller->private; controller_tx->private = controller->private;
controller->calculate = calculate_controller_rx; controller_rx->calculate = calculate_controller_rx;
controller_tx->calculate = calculate_controller_tx; controller_tx->calculate = calculate_controller_tx;
if (controller_block_outterm_list_init(controller, outterms)) if (controller_block_outterm_list_init(controller, outterms))
...@@ -205,6 +213,9 @@ static struct controller_block * block_vesp_controller_create(char *name, ...@@ -205,6 +213,9 @@ static struct controller_block * block_vesp_controller_create(char *name,
if (controller_block_interm_list_init(controller_tx, interms)) if (controller_block_interm_list_init(controller_tx, interms))
goto err_block; goto err_block;
controller->outputs = controller_rx->outputs;
controller->output = controller_rx->output;
controller->inputs = controller_tx->inputs; controller->inputs = controller_tx->inputs;
controller->input = calloc(controller->inputs, sizeof(struct controller_block_interm)); controller->input = calloc(controller->inputs, sizeof(struct controller_block_interm));
if (!controller->input) if (!controller->input)
...@@ -251,6 +262,10 @@ static struct controller_block * block_vesp_controller_create(char *name, ...@@ -251,6 +262,10 @@ static struct controller_block * block_vesp_controller_create(char *name,
if (controller_block_add(controller)) if (controller_block_add(controller))
goto err_add; goto err_add;
if (controller_block_add(controller_rx))
goto err_add;
if (controller_block_add(controller_tx))
goto err_add;
return controller; return controller;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment