From 170219fe413602508b31c39df23c8938adc6c35f Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 20 Dec 2016 23:36:55 -0500 Subject: get the new disambiguator closer, but it's still not perfect. --- Makefile | 2 +- data_recorder.c | 3 ++- include/survive.h | 2 +- src/disambiguator.c | 5 ++++- src/survive.c | 12 ++++++------ src/survive_data.c | 5 +++-- src/survive_usb.c | 12 ++++++------ 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 90e0ec1..8279efa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all : lib data_recorder test -CFLAGS:=-Iinclude -fPIC -g -Os -Iredist -flto +CFLAGS:=-Iinclude -fPIC -g -Os -Iredist -flto -DUSE_OLD_DISAMBIGUATOR LDFLAGS:=-lpthread -lusb-1.0 -lz -lX11 -flto test : test.c lib/libsurvive.so redist/os_generic.o diff --git a/data_recorder.c b/data_recorder.c index cdcf4f5..4c5627f 100644 --- a/data_recorder.c +++ b/data_recorder.c @@ -40,7 +40,7 @@ int buffertimeto[32*3]; void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length ) { if( acode == -1 ) return; - +//return; int jumpoffset = sensor_id; if( strcmp( so->codename, "WM0" ) == 0 ) jumpoffset += 32; else if( strcmp( so->codename, "WM1" ) == 0 ) jumpoffset += 64; @@ -77,6 +77,7 @@ void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int void my_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id ) { +return; //if( so->codename[0] == 'H' ) if( 1 ) { diff --git a/include/survive.h b/include/survive.h index 889e24d..8ce5404 100644 --- a/include/survive.h +++ b/include/survive.h @@ -31,7 +31,7 @@ struct SurviveObject //Flood info, for calculating which laser is currently sweeping. int8_t oldcode; -#if 0 +#ifdef USE_OLD_DISAMBIGUATOR int16_t total_photos; int32_t last_photo_time; int32_t total_photo_time; diff --git a/src/disambiguator.c b/src/disambiguator.c index 8a5a993..f641834 100644 --- a/src/disambiguator.c +++ b/src/disambiguator.c @@ -56,10 +56,13 @@ pulse_type disambiguator_step( struct disambiguator * d, long time, int length) if (length < 2750) { return d->state == D_STATE_LOCKED ? P_SWEEP : P_UNKNOWN; } + //printf( "%d %d\n", time, length ); + //printf( "." ); + //time -= length/2; disambiguator_discard(d, time - 10000000); int idx = disambiguator_find_nearest(d, time - 400000, 100); - + if (time - d->last > 401000) { d->state = D_STATE_UNLOCKED; } diff --git a/src/survive.c b/src/survive.c index 73df29d..7ad2ae9 100644 --- a/src/survive.c +++ b/src/survive.c @@ -92,12 +92,12 @@ static int LoadConfig( struct SurviveContext * ctx, struct SurviveObject * so, i int i; int r = jsmn_parse(&p, ct0conf, len, t, sizeof(t)/sizeof(t[0])); if (r < 0) { - SV_ERROR("Failed to parse JSON in HMD configuration: %d\n", r); - return 0; + SV_INFO("Failed to parse JSON in HMD configuration: %d\n", r); + return -1; } if (r < 1 || t[0].type != JSMN_OBJECT) { - SV_ERROR("Object expected in HMD configuration\n"); - return 0; + SV_INFO("Object expected in HMD configuration\n"); + return -2; } for (i = 1; i < r; i++) { @@ -166,8 +166,8 @@ struct SurviveContext * survive_init() //Next, pull out the config stuff. if( LoadConfig( ctx, &ctx->headset, 1, 0, 0 ) ) goto fail_gracefully; - if( LoadConfig( ctx, &ctx->watchman[0], 2, 0, 1 ) ) goto fail_gracefully; - if( LoadConfig( ctx, &ctx->watchman[1], 3, 0, 1 ) ) goto fail_gracefully; + if( LoadConfig( ctx, &ctx->watchman[0], 2, 0, 1 ) ) { SV_INFO( "Watchman 0 config issue." ); } + if( LoadConfig( ctx, &ctx->watchman[1], 3, 0, 1 ) ) { SV_INFO( "Watchman 1 config issue." ); } /* int i; diff --git a/src/survive_data.c b/src/survive_data.c index cb3e8a2..6a1656b 100644 --- a/src/survive_data.c +++ b/src/survive_data.c @@ -41,7 +41,7 @@ static void handle_lightcap( struct SurviveObject * so, struct LightcapElement * if( le->type != 0xfe || le->length < 50 ) return; //le->timestamp += (le->length/2); - +#if 0 int32_t offset = le->timestamp - so->d->last; switch( disambiguator_step( so->d, le->timestamp, le->length ) ) { default: @@ -56,7 +56,8 @@ static void handle_lightcap( struct SurviveObject * so, struct LightcapElement * ct->lightproc( so, le->sensor_id, so->d->code >> 1, offset, le->timestamp, le->length ); break; } -#if 0 +#endif +#ifdef USE_OLD_DISAMBIGUATOR if( le->length > 2100 ) //Pulse longer indicates a sync pulse. { int32_t deltat = (uint32_t)le->timestamp - (uint32_t)so->last_photo_time; diff --git a/src/survive_usb.c b/src/survive_usb.c index 808236d..cf12280 100644 --- a/src/survive_usb.c +++ b/src/survive_usb.c @@ -384,7 +384,7 @@ int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, cfgbuff[0] = 0x10; if( ( ret = hid_get_feature_report_timeout( dev, iface, cfgbuff, sizeof( cfgbuff ) ) ) < 0 ) { - SV_ERROR( "Could not get survive config data for device %d:%d", devno, iface ); + SV_INFO( "Could not get survive config data for device %d:%d", devno, iface ); return -1; } @@ -395,7 +395,7 @@ int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, { if( (ret = hid_get_feature_report_timeout(dev, iface, cfgbuff, sizeof( cfgbuff ) ) ) < 0 ) { - SV_ERROR( "Could not read config data (after first packet) on device %d:%d (count: %d)\n", devno, iface, count ); + SV_INFO( "Could not read config data (after first packet) on device %d:%d (count: %d)\n", devno, iface, count ); return -2; } @@ -405,13 +405,13 @@ int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, if( size > 62 ) { - SV_ERROR( "Too much data (%d) on packet from config for device %d:%d (count: %d)", size, devno, iface, count ); + SV_INFO( "Too much data (%d) on packet from config for device %d:%d (count: %d)", size, devno, iface, count ); return -3; } if( count + size >= sizeof( compressed_data ) ) { - SV_ERROR( "Configuration length too long %d:%d (count: %d)", devno, iface, count ); + SV_INFO( "Configuration length too long %d:%d (count: %d)", devno, iface, count ); return -4; } @@ -421,7 +421,7 @@ int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, if( count == 0 ) { - SV_ERROR( "Empty configuration for %d:%d", devno, iface ); + SV_INFO( "Empty configuration for %d:%d", devno, iface ); return -5; } @@ -430,7 +430,7 @@ int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, int len = survive_simple_inflate( ctx, compressed_data, count, uncompressed_data, sizeof(uncompressed_data)-1 ); if( len <= 0 ) { - SV_ERROR( "Error: data for config descriptor %d:%d is bad.", devno, iface ); + SV_INFO( "Error: data for config descriptor %d:%d is bad.", devno, iface ); return -5; } -- cgit v1.2.3