Commit 3f05a49c authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Update few funcitons for compatibility with old apps

parent 89991b1e
......@@ -28,6 +28,8 @@ Few functions helping for pseudo realtime applications.
#include "blc_tools.h"
#define BLC_COMMAND_LOOP_THREAD() for(blc_command_loop_init(-2); blc_command_loop_start();blc_command_loop_end())
period in microseconds
0 for system as fast as possible, -1 for blocking on keyborad, -2 blocking after first iteration.
......@@ -126,6 +128,10 @@ void blc_command_loop_init(long loop_period);
int blc_command_loop_start();
void blc_command_loop_end();
/**Wait until the blc_loop_stop.
Return the loop_thred pointer (always NULL for now)*/
void *blc_loop_wait_stop();
/** Stop a textual program
* - Send a quitting message with the name of the app on stderr.
* - Send 'q' and flush on stdout if it is a piped output
......@@ -29,6 +29,7 @@
#include "blc_core.h"
#include "blc_command.h"
///Set the desciption of the program used for help. A copy of desciption is done (strdup).
......@@ -33,6 +33,7 @@
#include "blc_tools.h"
#include "blc_program.h"
//Identical to argparse in Python
#define POSITIONAL_ARGUMENTS_TITLE "\npositional arguments:\n"
#define OPTIONAL_ARGUMENTS_TITLE "\noptional arguments:\n"
......@@ -48,6 +49,7 @@ typedef struct
void *user_data;
// Static means it is only existing in this file
static blc_command *blc_commands = NULL;
static int blc_commands_nb = 0;
......@@ -102,6 +104,7 @@ void blc_command_add(const char *command_name, type_blc_command_cb callback, con
APPEND_ITEM(&blc_commands, &blc_commands_nb, &tmp_command);
void blc_command_remove(const char *command_name){
int i;
......@@ -113,6 +116,8 @@ void blc_command_remove(const char *command_name){
REMOVE_ITEM_POSITION(&blc_commands, &blc_commands_nb, i);
void blc_command_interpret_string(char const *input_string, size_t size){
char const*parameter;
char *parameter2;
......@@ -14,8 +14,10 @@ struct timeval blc_loop_timer;
static uint blc_period=0;
static uint blc_duration=0;
static uint blc_duration_min=UINT_MAX, blc_duration_max=0;
static long blc_current_duration;
static int intermediate_iteration;
long blc_command_loop_period=-2; //unitialised
uint64_t blc_loop_iteration_limit=UINT64_MAX;
uint64_t blc_loop_iteration=0;
......@@ -190,6 +192,7 @@ static void *command_thread_interpret_loop(void *){
if (blc_command_loop_period==-1) BLC_PTHREAD_CHECK(pthread_mutex_unlock(&mutex_lock_keyboard), NULL);
return NULL;
......@@ -229,6 +232,7 @@ void blc_command_loop_init(long loop_period){
int blc_command_loop_start(){
int continue_value;
int i;
//We wait before counting the duration time as the time for waiting does not matter
if (blc_profile_file) gettimeofday(&profile_timer, NULL); //this is only for profiling
......@@ -294,3 +298,9 @@ void blc_command_loop_end(){
void *blc_loop_wait_stop(){
void *result;
SYSTEM_ERROR_CHECK(pthread_join(loop_thread, &result), -1, NULL);
return result;
......@@ -176,6 +176,7 @@ static void blc_program_option_interpret(int *argc, char **argv[])
type_program_option *program_option;
char pipe_name[PATH_MAX+1];
blc_program_name = basename(*argv[0]);
//We store enough room for all the optional letters + ':' + terminating null char
optstring = MANY_ALLOCATIONS(blc_program_options_nb*2+1, char);
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