Editing Mer/Documentation/N810 GPS

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
-
{{Mer}}
 
-
 
== Notes ==
== Notes ==
*These directions are confirmed to work on Mer 0.12.
*These directions are confirmed to work on Mer 0.12.
Line 11: Line 9:
== Directions ==
== Directions ==
-
=== Step 1: Install the necessary files ===
+
1. Install the following packages from the Maemo Updates repository (you can install them on Maemo, then copy the packages from the apt cache):
-
Install the following packages from the Maemo Updates repository (you can install them on Maemo, then copy the packages from the apt cache):
+
  libsupld1
  libsupld1
  osso-gpsd
  osso-gpsd
Line 19: Line 16:
  gpsdriver
  gpsdriver
-
=== Step 2: Tweak /etc/init.d/libgpsbt ===
+
2. Edit /etc/init.d/libgpsbt and change all instances of "user:users" to "YOURUSERNAME:users" There should be 2 instances you need to change.
-
Edit /etc/init.d/libgpsbt and change all instances of "user:users" to "YOURUSERNAME:users" There should be 2 instances you need to change.
+
-
=== Step 3: Change ownership ===
+
3. Run:
-
Run:
+
  chown -R YOURUSERNAME:users /var/lib/gps
  chown -R YOURUSERNAME:users /var/lib/gps
-
=== Step 4: Make the necessary files ===
+
4. Make the following files:
-
Make the following files:
+
/etc/default/gps5300driver.conf:
/etc/default/gps5300driver.conf:
Line 99: Line 93:
  esac
  esac
-
=== Step 5: Copy gpsdriver ===
+
5. Run
-
Make a copy of gpsdriver to prevent confusion
+
  cp /usr/sbin/gpsdriver /usr/sbin/gps5300driver
  cp /usr/sbin/gpsdriver /usr/sbin/gps5300driver
-
=== Step 6: Install libgps5300faker.so ===
+
6. Put libgps5300faker.so in /usr/lib (Not posted anywhere yet):
-
First of all, install the necessary packages (they may be removed later, this may be an excessive list or an incomplete list. Basically keep installing stuff until it stops complaining):
+
  cp /path/to/libgps5300faker.so /usr/lib
-
  apt-get install build-essential m4 automake autoconf
+
-
Make the following files somewhere (they may be removed later):
+
7. Reboot:
-
 
+
-
preload_init.c
+
-
/*
+
-
  * Copyright 2009 Luke Dashjr <luke_n8x0_gps5300driver@dashjr.org>
+
-
  * Licensed for redistribution as-is;
+
-
  * contact me if you want something more permissive
+
-
  */
+
-
+
-
#define _GNU_SOURCE
+
-
+
-
#include <dlfcn.h>
+
-
#include <stdlib.h>
+
-
#include <string.h>
+
-
#include <sys/types.h>
+
-
#include <sys/socket.h>
+
-
#include <sys/un.h>
+
-
#include <unistd.h>
+
-
+
-
static struct sockaddr_un ctrl_sau = {
+
-
AF_UNIX,
+
-
"/var/lib/gps/gps_driver_ctrl\0",
+
-
};
+
-
#define CTRL_SCK_PATH ctrl_sau.sun_path
+
-
+
-
static int ctrl_sck = -1;
+
-
+
-
typedef int (*bind_t)(int, const struct sockaddr*, socklen_t);
+
-
+
-
int
+
-
bind(int sockfd, const struct sockaddr*addr, socklen_t addrlen) {
+
-
static bind_t real = NULL;
+
-
if (!real)
+
-
real = dlsym(RTLD_NEXT, "bind");
+
-
+
-
int rv = real(sockfd, addr, addrlen);
+
-
+
-
if (
+
-
    addr &&
+
-
    addr->sa_family == AF_FILE &&
+
-
    !strcmp(CTRL_SCK_PATH,
+
-
            ((struct sockaddr_un*)addr)->sun_path
+
-
          ) &&
+
-
    getenv("GPS5300_SELFINIT") &&
+
-
    1
+
-
)
+
-
ctrl_sck = sockfd;
+
-
+
-
return rv;
+
-
}
+
-
+
-
typedef int (*listen_t)(int, int);
+
-
+
-
int
+
-
listen(int sockfd, int backlog) {
+
-
static listen_t real = NULL;
+
-
if (!real)
+
-
real = dlsym(RTLD_NEXT, "listen");
+
-
+
-
int rv = real(sockfd, backlog);
+
-
+
-
if (sockfd == ctrl_sck && !fork())
+
-
{
+
-
// Child process :)
+
-
+
-
int sck;
+
-
char initcmd[] = "P 3\n";
+
-
+
-
sck = socket(PF_FILE, SOCK_STREAM, 0);
+
-
if (sck < 0)
+
-
exit(1);
+
-
if (connect(sck, &ctrl_sau, sizeof ctrl_sau))
+
-
exit(1);
+
-
write(sck, initcmd, sizeof initcmd);
+
-
close(sck);
+
-
+
-
exit(0);
+
-
}
+
-
+
-
return rv;
+
-
}
+
-
 
+
-
preload.c:
+
-
  /*
+
-
  * Copyright 2009 Luke Dashjr <luke_n8x0_gps5300driver@dashjr.org>
+
-
  * Licensed for redistribution as-is;
+
-
  * contact me if you want something more permissive
+
-
  */
+
-
+
-
#define _GNU_SOURCE
+
-
+
-
#include <dlfcn.h>
+
-
#include <pwd.h>
+
-
#include <stdlib.h>
+
-
#include <string.h>
+
-
#include <sys/types.h>
+
-
+
-
typedef struct passwd* (*getpwnam_t)(const char*);
+
-
+
-
struct passwd *
+
-
getpwnam(const char *name) {
+
-
static getpwnam_t real = NULL;
+
-
if (!real)
+
-
real = dlsym(RTLD_NEXT, "getpwnam");
+
-
+
-
if (!strcmp(name, "user"))
+
-
{
+
-
const char*username = getenv("GPS5300_USER");
+
-
if (username)
+
-
name = username;
+
-
}
+
-
+
-
return real(name);
+
-
}
+
-
+
-
 
+
-
Compile them:
+
-
cd /path/to/source/files/
+
-
gcc -shared -fPIC -ldl preload.c preload_init.c -o libgps5300faker.so
+
-
 
+
-
Put libgps5300faker.so in /usr/lib (assuming you're still in the same directory):
+
-
cp libgps5300faker.so /usr/lib
+
-
 
+
-
=== Step 7: Reboot ===
+
-
Reboot:
+
  reboot
  reboot
-
=== Step 8: Prepare to use the GPS ===
+
8. Get ready to use the GPS:
-
Get ready to use the GPS:
+
  /etc/init.d/libgpsbt restart
  /etc/init.d/libgpsbt restart
  /etc/init.d/gpsdriver restart
  /etc/init.d/gpsdriver restart
  /etc/init.d/gps5300driver restart
  /etc/init.d/gps5300driver restart
-
=== Step 9: Start GPSD ===
+
9. Start GPSD:
-
Start GPSD:
+
  gpsd -n -N -D2 /dev/pgps
  gpsd -n -N -D2 /dev/pgps
Line 253: Line 119:
You have a lock and are ready to use your GPS (I've also gotten other messages indicating the GPS is ready. Basically anything new/other than what it routinely spits out should be a good indicator).
You have a lock and are ready to use your GPS (I've also gotten other messages indicating the GPS is ready. Basically anything new/other than what it routinely spits out should be a good indicator).
-
 
-
[[Category:N8x0]]
 
-
[[Category:GPS]]
 

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: