...
|
...
|
@@ -7,36 +7,36 @@ |
|
|
#include <unistd.h>
|
|
|
|
|
|
int main(int argc, char **argv){
|
|
|
blc_channel input, output1, output2;
|
|
|
char const *output_name1, *output_name2, *input_name;
|
|
|
blc_channel input, output1, output2;
|
|
|
char const *output_name1, *output_name2, *input_name;
|
|
|
|
|
|
blc_program_set_description("Duplicate a channel");
|
|
|
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
|
|
|
blc_program_add_parameter(&output_name1, "blc_channel-out", 1, "first copy of input", NULL);
|
|
|
blc_program_add_parameter(&output_name2, "blc_channel-out", 1, "second_copy of input", NULL);
|
|
|
blc_program_set_description("Duplicate a channel");
|
|
|
blc_program_add_option(&output_name1,'1', "output1", "blc_channel-out", "first copy of input", NULL);
|
|
|
blc_program_add_option(&output_name2, '2', "output2", "blc_channel-out", "second_copy of input", NULL);
|
|
|
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
|
|
|
|
|
|
blc_program_init(&argc, &argv, blc_quit);
|
|
|
|
|
|
input.open(input_name, BLC_CHANNEL_READ);
|
|
|
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
|
|
|
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
|
|
|
if (output_name1==NULL) EXIT_ON_ERROR("You need option -1 <name of output channel>");
|
|
|
if (output_name2==NULL) EXIT_ON_ERROR("You need option -2 <name of output channel>");
|
|
|
|
|
|
input.open(input_name, BLC_CHANNEL_READ);
|
|
|
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
|
|
|
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
|
|
|
|
|
|
|
|
|
output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
|
|
|
|
|
|
output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
|
|
|
|
|
|
|
|
|
BLC_COMMAND_LOOP(0){
|
|
|
if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
|
|
|
memcpy(output1.data, input.data, output1.size);
|
|
|
if (output1.sem_new_data) sem_post(output1.sem_new_data);
|
|
|
|
|
|
|
|
|
if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
|
|
|
memcpy(output2.data, input.data, output2.size);
|
|
|
if (output2.sem_new_data) sem_post(output2.sem_new_data);
|
|
|
|
|
|
BLC_COMMAND_LOOP(0){
|
|
|
if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
|
|
|
memcpy(output1.data, input.data, output1.size);
|
|
|
if (output1.sem_new_data) sem_post(output1.sem_new_data);
|
|
|
|
|
|
if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
|
|
|
memcpy(output2.data, input.data, output2.size);
|
|
|
if (output2.sem_new_data) sem_post(output2.sem_new_data);
|
|
|
}
|
|
|
return EXIT_SUCCESS;
|
|
|
return EXIT_SUCCESS;
|
|
|
} |
...
|
...
|
|