From 5aa20d099b9fe7539050a5baa4c70b678aeab64e Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 18 Mar 2018 02:45:09 -0400 Subject: Moving things over... still todo: * Make functions for changing temp configs. * Make functions for config_read_str but where it checks the temp one first. * Parse command-line options. --- src/survive_cal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/survive_cal.c') diff --git a/src/survive_cal.c b/src/survive_cal.c index 2fd96ef..6f556f3 100755 --- a/src/survive_cal.c +++ b/src/survive_cal.c @@ -178,8 +178,8 @@ void survive_cal_install( struct SurviveContext * ctx ) } const char * DriverName; -// const char * PreferredPoser = config_read_str(ctx->global_config_values, "ConfigPoser", "PoserCharlesSlow"); - const char * PreferredPoser = config_read_str(ctx->global_config_values, "ConfigPoser", "PoserTurveyTori"); +// const char * PreferredPoser = survive_config_reads(ctx, "configposer", "PoserCharlesSlow"); + const char * PreferredPoser = survive_config_reads(ctx, "configposer", "PoserTurveyTori"); PoserCB PreferredPoserCB = 0; const char * FirstPoser = 0; printf( "Available posers:\n" ); -- cgit v1.2.3 From c44cca299fbea4196af125dfedd8e4d60f3ae0cc Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 18 Mar 2018 19:48:25 -0400 Subject: Almost at a config interface. --- src/survive_cal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/survive_cal.c') diff --git a/src/survive_cal.c b/src/survive_cal.c index 6f556f3..4b1df89 100755 --- a/src/survive_cal.c +++ b/src/survive_cal.c @@ -8,6 +8,7 @@ // to not include it at all on any stripped-down versions of libsurvive. // + #include "survive_cal.h" #include "survive_internal.h" #include "survive_reproject.h" @@ -178,8 +179,9 @@ void survive_cal_install( struct SurviveContext * ctx ) } const char * DriverName; -// const char * PreferredPoser = survive_config_reads(ctx, "configposer", "PoserCharlesSlow"); - const char * PreferredPoser = survive_config_reads(ctx, "configposer", "PoserTurveyTori"); +// const char * PreferredPoser = survive_configs(ctx, "configposer", "PoserCharlesSlow"); + const char * PreferredPoser = survive_configs(ctx, "configposer", SC_SETCONFIG, "PoserTurveyTori"); + PoserCB PreferredPoserCB = 0; const char * FirstPoser = 0; printf( "Available posers:\n" ); -- cgit v1.2.3 From 0996cfcee351bfd665f48a205d2f7fe37dec336c Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 18 Mar 2018 22:00:55 -0400 Subject: Fix configuration system and fix race condition in survive_vive. --- src/survive_cal.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/survive_cal.c') diff --git a/src/survive_cal.c b/src/survive_cal.c index 4b1df89..cb242ae 100755 --- a/src/survive_cal.c +++ b/src/survive_cal.c @@ -119,6 +119,11 @@ void survive_cal_install( struct SurviveContext * ctx ) int i; struct SurviveCalData * cd = ctx->calptr = calloc( 1, sizeof( struct SurviveCalData ) ); + if( ctx->state != SURVIVE_RUNNING ) + { + SV_ERROR( "Error: You cannot install a calibrator until the system is running." ); + } + for( i = 0; i < NUM_LIGHTHOUSES; i++ ) { ootx_init_decoder_context(&cd->ootx_decoders[i]); @@ -182,19 +187,27 @@ void survive_cal_install( struct SurviveContext * ctx ) // const char * PreferredPoser = survive_configs(ctx, "configposer", "PoserCharlesSlow"); const char * PreferredPoser = survive_configs(ctx, "configposer", SC_SETCONFIG, "PoserTurveyTori"); - PoserCB PreferredPoserCB = 0; - const char * FirstPoser = 0; - printf( "Available posers:\n" ); + SV_INFO( "Trying to load poser %s for cal.", PreferredPoser ); + PoserCB SelectedPoserCB = 0; + const char * SelectedPoserName = 0; i = 0; while( ( DriverName = GetDriverNameMatching( "Poser", i++ ) ) ) { PoserCB p = GetDriver( DriverName ); - if( !PreferredPoserCB ) PreferredPoserCB = p; + if( !SelectedPoserCB ) + { + SelectedPoserCB = p; + SelectedPoserName = DriverName; + } int ThisPoser = strcmp( DriverName, PreferredPoser ) == 0; - if( ThisPoser ) PreferredPoserCB = p; + if( ThisPoser ) + { + SelectedPoserCB = p; + SelectedPoserName = DriverName; + } } - cd->ConfigPoserFn = PreferredPoserCB; - printf( "Got config poser: %p\n", cd->ConfigPoserFn ); + cd->ConfigPoserFn = SelectedPoserCB; + SV_INFO( "Got config poser: %s (%p)", SelectedPoserName, cd->ConfigPoserFn ); ootx_packet_clbk = ootx_packet_clbk_d; ctx->calptr = cd; @@ -207,7 +220,7 @@ void survive_cal_light( struct SurviveObject * so, int sensor_id, int acode, int struct SurviveCalData * cd = ctx->calptr; if( !cd ) return; - + switch( cd->stage ) { default: @@ -222,6 +235,7 @@ void survive_cal_light( struct SurviveObject * so, int sensor_id, int acode, int //fprintf(stderr, "%s\n", so->codename); int lhid = -sensor_id-1; // Take the OOTX data from the first device. (if using HMD, WM0, WM1 only, this will be HMD) + if( lhid < NUM_LIGHTHOUSES && so == cd->poseobjects[0] ) { uint8_t dbit = (acode & 2)>>1; -- cgit v1.2.3