Commit e1fd7b75 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

modernize c++

parents 20b4c992 94818bde
......@@ -4,8 +4,7 @@ cmake_minimum_required(VERSION 3.13)
# Set the name of the project as the directory basename
project(f_max)
find_package(blc)
find_package(blc REQUIRED)
add_executable(f_max f_max.cpp)
target_compile_features(f_max PRIVATE cxx_std_14)
target_link_libraries(f_max blc)
......@@ -13,3 +12,4 @@ target_link_libraries(f_max blc)
//
// Created by Arnaud Blanchard on 22/12/15.
// Copyright ETIS 2015. All rights reserved.
//
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <math.h>
#define DEFAULT_OUTPUT_NAME ":argmax<pid>"
static float find_float_max(float *floats, int floats_nb, float const *find_arg=NULL){
float max;
int i, imax;
max=floats[0];
imax=0;
for(i=1; i!=floats_nb; i++){
if(floats[i] > max){
max=floats[i];
imax=i;
}
}
if (find_arg) return (imax+0.5f)*(*find_arg);
else return max;
}
static void start_channel_float_loop(blc_channel const *input, blc_channel *output, float const *find_arg=NULL)
{
BLC_COMMAND_LOOP(0){
output->floats[0]=find_float_max(input->floats, input->total_length, find_arg);
}
}
static void start_print_float_loop(blc_channel const *input, float const* find_arg=NULL){
float imax;
BLC_COMMAND_LOOP(0){
imax=find_float_max(input->floats, input->total_length, find_arg);
printf("%f\n", imax);
if( blc_output_terminal) blc_eprint_cursor_up(1);
}
if( blc_output_terminal) blc_eprint_cursor_down(1);
}
int main(int argc, char **argv){
blc_channel input, output;
char const *output_name, *input_name, *find_arg_str;
float *find_arg_gain=NULL;
float arg_gain;
blc_program_set_description("Find the value of argument of the maximal value");
blc_program_add_option(&find_arg_str, 'a', "find_arg", "real", "Return argmax mutiplied by the real instead of max", NULL);
blc_program_add_option(&output_name, 'o', "output", "blc_channel-out", "channel name", DEFAULT_OUTPUT_NAME);
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "channel you want to find max", NULL);
blc_program_init(&argc, &argv, blc_quit);
blc_command_forward_blc_channels();
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 (find_arg_str){
SSCANF(1, find_arg_str, "%f", &arg_gain);
find_arg_gain=&arg_gain;
if(strcmp(output_name, DEFAULT_OUTPUT_NAME)==0) asprintf((char**)&output_name, ":imax%d", getpid());
}
else if(strcmp(output_name, DEFAULT_OUTPUT_NAME)==0) asprintf((char**)&output_name, ":max%d", getpid());
//The output is on terminal
if (strcmp(output_name, "-")==0){
switch (input.type){
case 'FL32':start_print_float_loop(&input, find_arg_gain);
break;
default:EXIT_ON_CHANNEL_ERROR(&input, "Type is not managed. Only 'FL32' is.");
break;
}
}
else
{
output.create_or_open(output_name, BLC_CHANNEL_WRITE, input.type, 'NDEF', 1, 1);
output.publish();
blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
blc_loop_try_add_posting_semaphore(output.sem_new_data);
switch (input.type){
case 'FL32':start_channel_float_loop(&input, &output, find_arg_gain);
break;
default:EXIT_ON_CHANNEL_ERROR(&input, "Type is not managed. Only 'FL32' is.");
break;
}
}
return EXIT_SUCCESS;
}
......@@ -22,3 +22,4 @@ target_link_libraries(i_discretize_file PRIVATE blc)
//Read only array of dim 1
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <termios.h>
#include <libgen.h> //basename
......@@ -58,6 +59,7 @@ int main(int argc, char** argv){
SSCANF(1, gain_str, "%f", &gain);
channel.create_or_open(channel_name, BLC_CHANNEL_WRITE, 'FL32', 'LPCM',{static_cast<size_t>(length)});
blc_loop_try_add_posting_semaphore(channel.sem_new_data);
blc_loop_try_add_waiting_semaphore(channel.sem_ack_data);
......
......@@ -11,9 +11,7 @@
cmake_minimum_required(VERSION 3.13)
project(i_fread)
find_package(blc REQUIRED)
add_executable(i_fread i_fread.cpp)
target_compile_features(i_fread PRIVATE cxx_std_14)
target_link_libraries(i_fread PRIVATE blc)
......
......@@ -2,6 +2,7 @@
#include "blc_text.h"
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <termios.h>
#include <libgen.h> //basename
......@@ -44,8 +45,9 @@ static void array_def_with_tsv_file_first_line(blc_array *array, char const *fil
}
if (time_str) length--; //The first coulmn dos not count it is the time.
array->def_array('FL32', 'NDEF', {static_cast<size_t>(length)});
fclose(file);
}
......
......@@ -3,11 +3,11 @@
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
cmake_minimum_required(VERSION 3.13)
......
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS
# Author: Arnaud Blanchard (November 2016)
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
cmake_minimum_required(VERSION 2.6)
project(i_keyboard)
find_package(blc_channel REQUIRED)
find_package(blc_program REQUIRED)
add_definitions(${BL_DEFINITIONS})
include_directories(${BL_INCLUDE_DIRS})
add_executable(i_keyboard src/i_keyboard.cpp)
target_link_libraries(i_keyboard ${BL_LIBRARIES})
cd `dirname $0`/..
./run.sh i_keyboard --display --toggle | ./run.sh f_gnuplot --with=boxes
......@@ -13,7 +13,7 @@ static blc_mem table;
static char *key_list;
static char const *display;
static int keys_nb;
static uchar min, max;
static uchar vmin, vmax;
static uchar quitting_key=0, neutral_key;
static float neutral_value, max_value, min_value, float_step_size=0.004;
static uchar uchar_step_size=1;
......@@ -26,7 +26,7 @@ static int update_index(int *index){
SYSTEM_ERROR_CHECK(ret=read(STDIN_FILENO, answer, 3), -1, "Waiting for keyboard input");
if (ret==1)
{
if (answer[0] >= min && answer[0] <= max && ((index_tmp=table.uchars[*answer-min]) != keys_nb)){
if (answer[0] >= vmin && answer[0] <= vmax && ((index_tmp=table.uchars[*answer-vmin]) != keys_nb)){
*index=index_tmp;
return INDEX_KEY;
}
......@@ -98,7 +98,7 @@ static int display_float(int index, float max_value, float min_value){
}
static void loop_toggle_uchar(){
int ret=NORMAL_KEY, index=0, graph_height;
int ret=NORMAL_KEY, index=0, graph_height=-1;
if (display) graph_height=display_uchar(index);
while (ret!=QUIT_KEY){
......@@ -128,7 +128,7 @@ static void loop_toggle_uchar(){
}
static void loop_uchar(){
int ret=NORMAL_KEY, index=0, graph_height;
int ret=NORMAL_KEY, index=0, graph_height=-1;
if (display) graph_height=display_uchar(index);
while (ret!=QUIT_KEY){
......@@ -161,7 +161,7 @@ static void loop_uchar(){
}
static void loop_toggle_float(){
int ret=NORMAL_KEY, index=0, graph_height;
int ret=NORMAL_KEY, index=0, graph_height=-1;
if (display) graph_height=display_float(index, max_value, min_value);
while (ret!=QUIT_KEY){
......@@ -190,7 +190,7 @@ static void loop_toggle_float(){
}
static void loop_float(){
int ret=0, index=0, previous_index=0, graph_height;
int ret=0, index=0, previous_index=0, graph_height=-1;
if (display) graph_height=display_float(index, max_value, min_value);
while (ret!=QUIT_KEY){
......@@ -225,7 +225,7 @@ int main(int argc, char** argv){
char const *channel_name, *type_str, *str_quitting_key, *str_neutral_key, *max_str, *min_str, *str_neutral_value, *toggle_mode, *step_size_str, *filename, *file_select_name;
char const *key_nb_str;
blc_channel channel_info;
uint32_t type;
uint32_t type=0;
int i;
char *pos;
uchar answer;
......@@ -303,9 +303,9 @@ int main(int argc, char** argv){
if (memchr(key_list, quitting_key, keys_nb)) EXIT_ON_ERROR("The quitting key '%c' is in your key list %.*s, you need to select an other one with --quitting_key=...", quitting_key, keys_nb, key_list);
if (memchr(key_list, neutral_key, keys_nb)) EXIT_ON_ERROR("The neutral key '%c' is in your key list %.*s, you need to select an other one with --neutral_key=...", neutral_key, keys_nb, key_list);
created=channel.create_or_open(channel_name, BLC_CHANNEL_WRITE, type, 'NDEF', { static_cast<size_t>(keys_nb) });
if (filename){
extension = blc_get_filename_extension(filename);
if(strcmp(extension, "blc")==0) channel.update_with_blc_file(filename);
......@@ -337,16 +337,16 @@ int main(int argc, char** argv){
fprintf(stderr, "Waiting for one key in '%.*s'. Quitting with '%s'\n", keys_nb, key_list, str_quitting_key);
//We pre calculate the answers
max=min=key_list[0];
vmax=vmin=key_list[0];
FOR(i, keys_nb) {
answer=key_list[i];
if (answer<min) min =answer;
else if (answer>max) max=answer;
if (answer<vmin) vmin =answer;
else if (answer>vmax) vmax=answer;
}
table.allocate(max-min+1);
table.allocate(vmax-vmin+1);
FOR(i, (int)table.size){
pos=strchr(key_list, i+min);
pos=strchr(key_list, i+vmin);
if (pos) table.uchars[i]=pos-key_list;
else table.uchars[i]=keys_nb;
}
......
#include "blc_core.h"
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <termios.h>
#include <libgen.h> //basename
enum{NORMAL_KEY=0, QUIT_KEY, NEUTRAL_KEY, INDEX_KEY, ARROW_CHANGE_INDEX, WRONG_KEY, DECREMENT_KEY, INCREMENT_KEY, FAST_DECREMENT_KEY, FAST_INCREMENT_KEY};
enum { LEFT_ARROW='D', RIGHT_ARROW='C', UP_ARROW='A', DOWN_ARROW='B'};
blc_channel channel;
blc_mem table;
char *key_list;
char const *display;
int keys_nb;
uchar min, max;
uchar quitting_key, neutral_key;
float neutral_value, max_value, min_value, float_step_size=0.004;
uchar uchar_step_size=1;
//quitting key return -1, neutral return -2;
static int update_index(int *index){
uchar answer[3];
ssize_t ret;
int index_tmp;
SYSTEM_ERROR_CHECK(ret=read(STDIN_FILENO, answer, 3), -1, "Waiting for keyboard input");
if (ret==1)
{
if (answer[0] >= min && answer[0] <= max && ((index_tmp=table.uchars[*answer-min]) != keys_nb)){
*index=index_tmp;
return INDEX_KEY;
}
else if (answer[0]==quitting_key) return QUIT_KEY;
else if (answer[0]==neutral_key) return NEUTRAL_KEY;
else fprintf(stderr, "\nThe key '%c' id '%d' is not possible. The possibilities are in '%s' or '%c' for quitting and '%c' for neutral value.\n", answer[0], answer[0], key_list, quitting_key, neutral_key);
} if (ret==2){
switch (answer[1]){
default:fprintf(stderr, "\nImpossible key of '%ld' bytes. Byte 0 '%c','%d', byte 1, '%c','%d'\n", ret, answer[0], answer[0], answer[1], answer[1]);
break;
}
}
else if (ret==3){
if ((answer[0]==27 && answer[1]=='[') || (answer[0]==239 && answer[1]==156)) {
switch (answer[2]){
case LEFT_ARROW: case 130: *index=MAX(0, *index-1);
return ARROW_CHANGE_INDEX;
break;
case RIGHT_ARROW: case 131: *index=MIN(keys_nb-1, *index+1);
return ARROW_CHANGE_INDEX;
break;
case UP_ARROW:case 128: return INCREMENT_KEY;
break;
case DOWN_ARROW:case 129: return DECREMENT_KEY;
break;
/* case PAGE_UP:case 172: return FAST_INCREMENT_KEY;
break;
case PAGE_DOWN:case 173: return FAST_DECREMENT_KEY;
break;*/
default: fprintf(stderr, "This key does not have effect\n");
break;
}
}
printf("Answer 0 '%c','%d', answer 1, '%c','%d', 2: '%c','%d'\n" , answer[0], answer[0] , answer[1], answer[1], answer[2], answer[2]);
}else fprintf(stderr, "\nImpossible key of '%ld' bytes. Byte 0 '%c','%d', byte 1, '%c','%d'\n", ret, answer[0], answer[0], answer[1], answer[1]);
return WRONG_KEY;
}
/**Return display size*/
static int display_uchar(int index){
char select_char;
int i;
channel.fprint_graph_uchars(stderr, channel.name, 6, 255, 0);
fprintf(stderr, ">");
FOR(i, keys_nb){
if (index==i) select_char='#';
else select_char=' ';
fprintf(stderr, "|%c%c", select_char, key_list[i]);
}
fprintf(stderr, "|\n");
return 7;
}
/**Return display size*/
static int display_float(int index){
char select_char;
int i;
channel.fprint_graph_floats(stderr, channel.name, 6, 1.0, 0);
fprintf(stderr, ">");
FOR(i, keys_nb){
if (index==i) select_char='#';
else select_char=' ';
fprintf(stderr, "|%c%c", select_char, key_list[i]);
}
fprintf(stderr, "|\n");
return 7;
}
static void loop_toggle_uchar(){
int ret=NORMAL_KEY, index=0, graph_height;
if (display) graph_height=display_uchar(index);
while (ret!=QUIT_KEY){
ret=update_index(&index);
switch (ret){
case INCREMENT_KEY:
channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(max_value);
break;
case DECREMENT_KEY: channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(min_value);
break;
case NEUTRAL_KEY:
channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(neutral_value);
break;
case INDEX_KEY:
if (channel.uchars[index] > BLC_NORMED_FLOAT_TO_UCHAR(neutral_value)) channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(min_value);
else channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(max_value);
case ARROW_CHANGE_INDEX:case QUIT_KEY:
break;
default:color_eprintf(BLC_YELLOW, "Unknownd ret '%d'", ret);
}
if (display){
graph_height=display_uchar(index);
blc_eprint_cursor_up(graph_height);
}
}
}
static void loop_uchar(){
int ret=NORMAL_KEY, index=0, graph_height;
if (display) graph_height=display_uchar(index);
while (ret!=QUIT_KEY){
if (display){
blc_eprint_cursor_up(graph_height);
graph_height=display_uchar(index);
}
ret=update_index(&index);
switch (ret){
case INCREMENT_KEY:
channel.uchars[index]=MIN(channel.uchars[index]+uchar_step_size, BLC_NORMED_FLOAT_TO_UCHAR(max_value));
break;
case DECREMENT_KEY: channel.uchars[index]=MAX(channel.uchars[index]-uchar_step_size, BLC_NORMED_FLOAT_TO_UCHAR(min_value));
break;
/* case FAST_INCREMENT_KEY:
channel.uchars[index]=MIN(channel.uchars[index]+10*uchar_step_size, UINT8_MAX);
previous_index=index;
break;
case FAST_DECREMENT_KEY:
channel.uchars[index]=MAX(channel.uchars[index]-10*uchar_step_size, 0);
break;*/
case NEUTRAL_KEY:
channel.uchars[index]=BLC_NORMED_FLOAT_TO_UCHAR(neutral_value);
break;
case INDEX_KEY:case QUIT_KEY:case ARROW_CHANGE_INDEX:
break;
default:EXIT_ON_ERROR("Unknownd ret '%d'", ret);
}
}
}
static void loop_toggle_float(){
int ret=NORMAL_KEY, index=0, graph_height;
if (display) graph_height=display_float(index);
while (ret!=QUIT_KEY){
if (display){
blc_eprint_cursor_up(graph_height);
graph_height=display_float(index);
}
ret=update_index(&index);
switch (ret){
case INCREMENT_KEY:
channel.floats[index]=max_value;
break;
case DECREMENT_KEY: channel.floats[index]=min_value;
break;
case NEUTRAL_KEY:
channel.floats[index]=neutral_value;
break;
case INDEX_KEY:
if (channel.floats[index] > neutral_value) channel.floats[index]=min_value;
else channel.floats[index]=max_value;
case ARROW_CHANGE_INDEX:case QUIT_KEY:
break;
default:color_eprintf(BLC_YELLOW, "Unknownd ret '%d'", ret);
}
}
}
static void loop_float(){
int ret=0, index=0, previous_index=0, graph_height;
if (display) graph_height=display_float(index);
while (ret!=QUIT_KEY){
if (display){
blc_eprint_cursor_up(graph_height);
graph_height=display_float(index);
}
ret=update_index(&index);
switch (ret){
case INCREMENT_KEY: channel.floats[index]=MIN(channel.floats[index]+float_step_size, max_value);
break;
case DECREMENT_KEY: channel.floats[index]=MAX(channel.floats[index]-float_step_size, min_value);
break;
/* case FAST_INCREMENT_KEY: channel.floats[index]+=float_step_size*10;
break;
case FAST_DECREMENT_KEY:channel.floats[index]-=float_step_size*10;
break;*/
case NEUTRAL_KEY:channel.floats[index]=neutral_value;
break;
case INDEX_KEY: case ARROW_CHANGE_INDEX:
previous_index=index;
case QUIT_KEY:break;
default:EXIT_ON_ERROR("Unknownd ret '%d'", ret);
}
}
}
int main(int argc, char** argv){
char *default_output=NULL;
char const *extension;
char const *channel_name, *type_str, *str_quitting_key, *str_neutral_key, *max_str, *min_str, *str_neutral_value, *toggle_mode, *step_size_str, *filename;
char const *key_nb_str;
int i;
char *pos;
uchar answer;
asprintf(&default_output, "/%s%d", basename(argv[0]), getpid()); //This will not be free but it is only allocate once
blc_program_set_description("Get keyboard inputs");
blc_program_add_option(&display, 'd', "display", NULL, "Display a text graph (UIN8 only)", NULL);
blc_program_add_option(&filename, 'f', "file", "filename", "Initialize the values with a tsv file", NULL);
blc_program_add_option((char const**)&key_list, 'k', "key_list", "string", "Define all the keys that can be stroke", "0123456789abcdef");
blc_program_add_option(&min_str, 'm', "min", "real", "Define the normed minimum value", "0.0");
blc_program_add_option(&str_neutral_key, 'n', "neutral_key", "string", "Define the neutral key", "escape");
blc_program_add_option(&channel_name, 'o', "output", "blc_channel", "Define where the result will be put", default_output);
blc_program_add_option(&str_quitting_key, 'q', "quitting_key", "string", "Define the key used to quit", "q");
blc_program_add_option(&key_nb_str, 's', "size", "integer", "Size of key vector", NULL);
blc_program_add_option(&type_str, 't', "type", "UIN8|FL32", "Define the type of the result", "UIN8");
blc_program_add_option(&max_str, 'M', "max", "real", "Define the normed max value", "1.0");
blc_program_add_option(&str_neutral_value, 'N', "neutral_value", "real", "Define the normed neutral value", "0.5");
blc_program_add_option(&step_size_str, 'S', "step", "real", "Set the normed step size", NULL);
blc_program_add_option(&toggle_mode, 'T', "toggle", NULL, "Set in toggle mode", NULL);
blc_program_init(&argc, &argv, blc_quit);
atexit(blc_set_back_stdin_mode);
if (strlen(str_quitting_key)!=1) EXIT_ON_ERROR("You can only have one quitting key. You propose %s", str_quitting_key);
if (strcmp(str_neutral_key, "escape")==0) neutral_key=27; //Escape
else if (strlen(str_neutral_key)!=1) EXIT_ON_ERROR("You can only have one neutral key. You propose %s", str_neutral_key);
else neutral_key=str_neutral_key[0];
neutral_value=strtof(str_neutral_value, NULL);
max_value=strtof(max_str, NULL);
min_value=strtof(min_str, NULL);
quitting_key=str_quitting_key[0];
if (key_nb_str) {
keys_nb=strtod(key_nb_str, NULL);
key_list=MANY_ALLOCATIONS(keys_nb, char);
FOR(i, keys_nb){
if (i<10) key_list[i]=48+i; //01234567890
else if (i<36) key_list[i]=97+i-10; //abc...xyz
else if (i<62) key_list[i]=65+i-36; //ABC...XYZ
else if (i==62) key_list[i]='[';
else if (i==63) key_list[i]=']';
else EXIT_ON_ERROR("Too many keys. You have '%d' max is 64", keys_nb);
}
}
else keys_nb=strlen(key_list);
if (memchr(key_list, quitting_key, keys_nb)) EXIT_ON_ERROR("The quitting key '%c' is in your key list %*s, you need to select an other one with --quitting_key=...", quitting_key, keys_nb, quitting_key);
if (memchr(key_list, neutral_key, keys_nb)) EXIT_ON_ERROR("The neutral key '%c' is in your key list %*s, you need to select an other one with --neutral_key=...", quitting_key, keys_nb, neutral_key);
channel.create_or_open(channel_name, BLC_CHANNEL_WRITE, STRING_TO_UINT32(type_str), 'NDEF', 1, keys_nb);
if (filename){
extension = blc_get_filename_extension(filename);
if(strcmp(extension, "blc")==0) channel.update_with_blc_file(filename);
else if (strcmp(extension, "tsv")==0) channel.update_with_tsv_file(filename);
else EXIT_ON_ERROR("'%s' is not a possible file type extension", extension);