aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Lohr <lohr85@gmail.com>2016-12-11 00:51:24 -0500
committerCharles Lohr <lohr85@gmail.com>2016-12-11 00:51:24 -0500
commit9ebc61bbd93fc58088d2379d6c9b5f2cb21db40b (patch)
tree705ceedf1230f70c8dfe43617aa8523d2e8ba883 /src
parent44d7e56bf6a419104fee5dd2aedc26e00e543d69 (diff)
downloadlibsurvive-9ebc61bbd93fc58088d2379d6c9b5f2cb21db40b.tar.gz
libsurvive-9ebc61bbd93fc58088d2379d6c9b5f2cb21db40b.tar.bz2
Tweak to change the way some things were logged and fix the interpreting data.
Diffstat (limited to 'src')
-rw-r--r--src/survive.c22
-rw-r--r--src/survive_process.c4
2 files changed, 18 insertions, 8 deletions
diff --git a/src/survive.c b/src/survive.c
index b5c8012..edcbb86 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -10,8 +10,8 @@
#include <zlib.h>
static int jsoneq(const char *json, jsmntok_t *tok, const char *s) {
- if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
- strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+ if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
+ strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
return 0;
}
return -1;
@@ -44,6 +44,7 @@ struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, co
return 0;
}
+
#if 1
//Next, pull out the config stuff.
{
@@ -51,6 +52,7 @@ struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, co
int len = survive_get_config( &ct0conf, ctx, 1, 0 );
if( len > 0 )
{
+
//From JSMN example.
jsmn_parser p;
jsmntok_t t[4096];
@@ -65,12 +67,20 @@ struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, co
SV_ERROR("Object expected in HMD configuration\n");
return 0;
}
+
for (i = 1; i < r; i++) {
+ jsmntok_t * tk = &t[i];
+
+ char ctxo[100];
+ int ilen = tk->end - tk->start;
+ if( ilen > 99 ) ilen = 99;
+ memcpy(ctxo, ct0conf + tk->start, ilen);
+ ctxo[ilen] = 0;
+// printf( "%d / %d / %d / %d %s %d\n", tk->type, tk->start, tk->end, tk->size, ctxo, jsoneq(ct0conf, &t[i], "modelPoints") );
+
if (jsoneq(ct0conf, &t[i], "modelPoints") == 0) {
int k;
- jsmntok_t * tk = &t[i+1];
- //printf( "%d / %d / %d / %d\n", tk->type, tk->start, tk->end, tk->size );
- int pts = tk->size;
+ int pts = t[i+1].size;
ctx->headset.nr_locations = 0;
ctx->headset.sensor_locations = malloc( sizeof( *ctx->headset.sensor_locations) * 32 * 3 );
@@ -78,7 +88,6 @@ struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, co
for( k = 0; k < pts; k++ )
{
tk = &t[i+2+k*4];
- //printf( "++%d / %d / %d / %d\n", tk->type, tk->start, tk->end, tk->size );
float vals[3];
int m;
@@ -98,6 +107,7 @@ struct SurviveContext * survive_init( void(*ff)( struct SurviveContext * ctx, co
memcpy( ctt, ct0conf + tk->start, elemlen );
ctt[elemlen] = 0;
float f = atof( ctt );
+ //printf( "%f%c", f, (m==2)?'\n':',' );
int id = ctx->headset.nr_locations*3+m;
ctx->headset.sensor_locations[id] = f;
}
diff --git a/src/survive_process.c b/src/survive_process.c
index 139ae2f..d705f8f 100644
--- a/src/survive_process.c
+++ b/src/survive_process.c
@@ -14,7 +14,7 @@ void survive_light_process( struct SurviveObject * so, int sensor_id, int acode,
if( acode == 0 || acode == 2 ) //data = 0
{
- printf( "L, X, %s, %d, %d, %d, %d\n", so->codename, timecode, sensor_id, acode, timeinsweep );
+// printf( "L, X, %s, %d, %d, %d, %d\n", so->codename, timecode, sensor_id, acode, timeinsweep );
bufferpts[sensor_id*2+0] = (timeinsweep-170000)/100;
buffertimeto[sensor_id] = 0;
//printf( "X: %d\n",bufferpts[sensor_id*2+0] );
@@ -22,7 +22,7 @@ void survive_light_process( struct SurviveObject * so, int sensor_id, int acode,
}
if( acode == 1 || acode == 3 ) //data = 1
{
- printf( "L, Y, %s, %d, %d, %d, %d\n", so->codename, timecode, sensor_id, acode, timeinsweep );
+// printf( "L, Y, %s, %d, %d, %d, %d\n", so->codename, timecode, sensor_id, acode, timeinsweep );
bufferpts[sensor_id*2+1] = 480-(timeinsweep-140000)/100;
//printf( "Y: %d\n",bufferpts[sensor_id*2+1] );
buffertimeto[sensor_id] = 0;