On 05/04/12 16:19, Dave Taht wrote:
I note that I have been tracking the latest gpsds closely (with the new api)

A problem is that it requires that scons support be added to the
mainline openwrt build.

Got patches for all that, could use some more testing...

Hi Dave,

I'm interesting as well to see gpsd updated to the latest stable version, would you mind to share your patches? I'll be happy to give them a try!

Chris



On Thu, Apr 5, 2012 at 3:02 AM, Viktar Palstsiuk
<[email protected]>  wrote:
Signed-off-by: Viktar Palstsiuk<[email protected]>
---
  lang/luagps/Makefile                               |   50 ++++++++++++++++
  .../001-add_compatibility_with_old_gpsd_api.patch  |   62 ++++++++++++++++++++
  2 files changed, 112 insertions(+), 0 deletions(-)
  create mode 100644 lang/luagps/Makefile
  create mode 100644 
lang/luagps/patches/001-add_compatibility_with_old_gpsd_api.patch

diff --git a/lang/luagps/Makefile b/lang/luagps/Makefile
new file mode 100644
index 0000000..268e826
--- /dev/null
+++ b/lang/luagps/Makefile
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luagps
+PKG_REV:=2d3dd6b1cc7b87891af19857bfedd2e1845d2e3b
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_REV).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/jdegges/lua-gps.git
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luagps
+  SUBMENU:=Lua
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=Lua bindings for libgps
+  URL:=https://github.com/jdegges/lua-gps
+  DEPENDS:=+lua +gpsd
+endef
+
+define Package/luagps/description
+  Lua bindings for libgps.
+endef
+
+define Build/Configure
+endef
+
+TARGET_CFLAGS += $(FPIC) -shared -g -W -Wall -I$(STAGING_DIR)/usr/include/
+TARGET_LDFLAGS += -lgps
+
+define Build/Compile
+       $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(PKG_BUILD_DIR)/lgps.c 
-o $(PKG_BUILD_DIR)/gps.so
+endef
+
+define Package/luagps/install
+       $(INSTALL_DIR) $(1)/usr/lib/lua
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/gps.so $(1)/usr/lib/lua/
+endef
+
+$(eval $(call BuildPackage,luagps))
diff --git a/lang/luagps/patches/001-add_compatibility_with_old_gpsd_api.patch 
b/lang/luagps/patches/001-add_compatibility_with_old_gpsd_api.patch
new file mode 100644
index 0000000..63a7f3d
--- /dev/null
+++ b/lang/luagps/patches/001-add_compatibility_with_old_gpsd_api.patch
@@ -0,0 +1,62 @@
+--- a/lgps.c   2012-04-05 11:19:27.000000000 +0300
++++ b/lgps.c   2012-04-05 12:28:17.000000000 +0300
+@@ -30,7 +30,6 @@
+ static int
+ lgps_open (lua_State *L)
+ {
+-  int top = lua_gettop (L);
+   struct gps_data_t *ud = NULL;
+   const char *server = luaL_checkstring (L, 1);
+   const char *port = luaL_checkstring (L, 2);
+@@ -39,8 +38,13 @@
+   if (NULL == ud)
+     print_error ("out of memory");
+
++#if (GPSD_API_MAJOR_VERSION>  4)
+   if (0 != gps_open (server, port, ud))
+     print_error ("no gpsd running or network error: %d, %s", errno, 
gps_errstr (errno));
++#else
++  if (0 != gps_open_r (server, port, ud))
++    print_error ("no gpsd running or network error: %d, %s", errno, 
gps_errstr (errno));
++#endif
+
+   luaL_getmetatable (L, MT_GPS);
+   lua_setmetatable (L, -2);
+@@ -86,9 +90,13 @@
+ lgps_waiting (lua_State *L)
+ {
+   struct gps_data_t *ud = luaL_checkudata (L, 1, MT_GPS);
+-  lua_Integer timeout = luaL_checkinteger (L, 2);
+
++#if (GPSD_API_MAJOR_VERSION>  4)
++  lua_Integer timeout = luaL_checkinteger (L, 2);
+   lua_pushboolean (L, gps_waiting (ud, timeout));
++#else
++  lua_pushboolean (L, gps_waiting (ud));
++#endif
+
+   return 1;
+ }
+@@ -108,7 +116,12 @@
+   int count;
+   int i;
+
++#if (GPSD_API_MAJOR_VERSION>  4)
+   count = gps_read (ud);
++#else
++  count = gps_poll (ud) + 1;
++#endif
++
+   if (count<= 0)
+     print_error ("either no data or error reading data");
+
+@@ -247,7 +260,9 @@
+   SET_CONST_INT (WATCH_RARE);
+   SET_CONST_INT (WATCH_RAW);
+   SET_CONST_INT (WATCH_SCALED);
++#if (GPSD_API_MAJOR_VERSION>  4)
+   SET_CONST_INT (WATCH_TIMING);
++#endif
+   SET_CONST_INT (WATCH_DEVICE);
+   SET_CONST_INT (WATCH_NEWSTYLE);
+   SET_CONST_INT (WATCH_OLDSTYLE);
--
1.7.9.1

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel





--
Christian Gagneraud,
Embedded systems engineer.
Techworks Marine
1 Harbour road
Dun Laoghaire
Co. Dublin
Ireland
Tel: + 353 (0) 1 236 5990
Web: http://www.techworks.ie/
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to