From 56379bb49339a51d81f6db12b8f1bb3e859bacd5 Mon Sep 17 00:00:00 2001 From: steffen Date: Tue, 28 May 2013 19:47:03 +0000 Subject: [PATCH] gps seems to work on android now. --- ChangeLog | 3 +++ android/jni/android_gfx.c | 16 ++++++++-------- android/jni/main.c | 5 ++++- .../src/de/gulpe/sposmroute/spOSMrNActivity.java | 4 ++-- base/config.c | 8 ++++++-- base/system.c | 4 ++-- base/system.h | 3 ++- main/gps.c | 2 +- main/gps.h | 2 +- 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a505d5d..4731f1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ Version 0.0.2: name changed to spOSMroute, since on there had been another OSMroute already. ============================================================================= +(2013-05-28): +- fixed: on android devices gps seems to work now fine. + (2013-05-15): - fixed: areas will be split into peaces if there is an angle above 180°. needed for displaying on GLES supported devices.. diff --git a/android/jni/android_gfx.c b/android/jni/android_gfx.c index a45fccb..4fd2202 100644 --- a/android/jni/android_gfx.c +++ b/android/jni/android_gfx.c @@ -266,14 +266,14 @@ void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_styl glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon); glDrawArrays (GL_TRIANGLE_FAN, 0, pcnt); - if (style.width < 1.0) style.width = 1.0; - glLineWidth (style.width); - - glUseProgram (engine.gles_prgobject); - glUniform1i (engine.gles_txenabled, 0); - glUniform4fv(engine.gles_color, 1, style.c.c.array); - glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon); - glDrawArrays (GL_LINE_LOOP, 0, pcnt); +// if (style.width < 1.0) style.width = 1.0; +// glLineWidth (style.width); +// +// glUseProgram (engine.gles_prgobject); +// glUniform1i (engine.gles_txenabled, 0); +// glUniform4fv(engine.gles_color, 1, style.c.c.array); +// glVertexAttribPointer (engine.gles_pos, 3, GL_FLOAT, GL_FALSE, 0, polygon); +// glDrawArrays (GL_LINE_LOOP, 0, pcnt); }; diff --git a/android/jni/main.c b/android/jni/main.c index a22ba6c..bbec75f 100644 --- a/android/jni/main.c +++ b/android/jni/main.c @@ -363,6 +363,7 @@ int gps_android_device_open () { }; void gps_android_device_close () { + d_printf ("gps_android_device_close:"); ANativeActivity* activity = engine.app->activity; JavaVM* jvm = engine.app->activity->vm; JNIEnv* env = NULL; @@ -388,6 +389,8 @@ int gps_android_device_read (char *ptr, int ptrsize) { jstring jstr; const char *str; + d_printf ("gps_android_device_read:"); + (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_6); jint res = (*jvm)->AttachCurrentThread(jvm, &env, NULL); if (res == JNI_ERR) { @@ -410,8 +413,8 @@ int gps_android_device_read (char *ptr, int ptrsize) { } else ptr[0] = 0; (*env)->ReleaseStringUTFChars(env, jstr, str); - (*jvm)->DetachCurrentThread(jvm); + return strlen (ptr); }; diff --git a/android/src/de/gulpe/sposmroute/spOSMrNActivity.java b/android/src/de/gulpe/sposmroute/spOSMrNActivity.java index 89aa157..08b9b52 100644 --- a/android/src/de/gulpe/sposmroute/spOSMrNActivity.java +++ b/android/src/de/gulpe/sposmroute/spOSMrNActivity.java @@ -27,7 +27,7 @@ public class spOSMrNActivity extends NativeActivity { if (started) { nmealine = nmealine + nmea; } -// Log.i(TAG, "GPSData (cur nmea:"+nmealine+")"); + // Log.i(TAG, "GPSData (cur nmea:"+nmealine+")"); } }); @@ -56,7 +56,7 @@ public class spOSMrNActivity extends NativeActivity { // get gps data fill one line into gpsline public void GPSDataGetLine() { -// Log.i(TAG, "GPSDataGetLine called"); + // Log.i(TAG, "GPSDataGetLine called sending:'"+nmealine+"'"); gpsline = nmealine; nmealine = ""; } diff --git a/base/config.c b/base/config.c index 4edf82c..b854a32 100644 --- a/base/config.c +++ b/base/config.c @@ -68,10 +68,14 @@ void config_init () { /* Android version will not need config and log path.. */ #if defined(ANDROID) strcpy (cfg.appdatapath, "android/assets"); - if (engine.app->activity->internalDataPath == NULL) + if (engine.app->activity->internalDataPath == NULL) { strncpy (cfg.configpath, "/data/data/de.gulpe.sposmroute/", LEN_FILENAME); - else + strncpy (cfg.logpath, "/data/data/de.gulpe.sposmroute/", LEN_FILENAME); + } + else { strncpy (cfg.configpath, engine.app->activity->internalDataPath, LEN_FILENAME); + strncpy (cfg.logpath, engine.app->activity->internalDataPath, LEN_FILENAME); + } /* std::string dataPath(internalPath); // internalDataPath points directly to the files/ directory std::string configFile = dataPath + "/app_config.xml"; diff --git a/base/system.c b/base/system.c index eceab3b..7e663ad 100644 --- a/base/system.c +++ b/base/system.c @@ -92,7 +92,7 @@ int execwait (struct s_execcall *p) { #endif -#ifndef ANDROID +// #ifndef ANDROID void d_printf (char *fmt,...) { va_list args; char text1[1024]; @@ -128,7 +128,7 @@ void d_printf (char *fmt,...) { close (f); } }; -#endif +// #endif void d_print_init() { diff --git a/base/system.h b/base/system.h index 3a8fb25..ae0428b 100644 --- a/base/system.h +++ b/base/system.h @@ -90,7 +90,8 @@ extern int cmpd (double d1, double d2); #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__)) -#define d_printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) +// #define d_printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__)) +extern void d_printf (char *fmt,...); #else extern void d_printf (char *fmt,...); diff --git a/main/gps.c b/main/gps.c index af28679..1a6e866 100644 --- a/main/gps.c +++ b/main/gps.c @@ -660,6 +660,7 @@ struct gps_data *gps_loop () { else dataread = -1; if (dataread < 0) { + d_printf ("gps_loop data read < 0"); gps_stop(); gpsstatus = -1; return NULL; @@ -667,7 +668,6 @@ struct gps_data *gps_loop () { else if (dataread+gpsdatalen > GPS_INBUFSIZE) { d_printf ("%s:%d gps_loop: ERROR datapos(%d) > GPS_INBUFSIZE(%d)", __FILE__, __LINE__, gpsdatalen + dataread, GPS_INBUFSIZE); gpsdatalen = GPS_INBUFSIZE; - gps_stop (); } else gpsdatalen += dataread; diff --git a/main/gps.h b/main/gps.h index 7c5daf2..38ad5b8 100644 --- a/main/gps.h +++ b/main/gps.h @@ -37,7 +37,7 @@ #define GPS_DEVICELEN 256 #define GPS_ROUTEPOILEN 128 -#define GPS_INBUFSIZE 1024 +#define GPS_INBUFSIZE 2048 #define GPS_LINELEN 100 #define GPS_MAXSAT 32