No announcement yet.

logging suddenly stops

  • Filter
  • Time
  • Show
Clear All
new posts

  • logging suddenly stops

    Hi, its me again!

    I'm starting obdgpslogger on boot through /etc/conf.d/local.start (google says the ubuntu equivalent is /etc/rc.local).

    There is actually no problem there, it happily logs everything (save for the gps, which is once again giving me problems -- gpsd problems, not obdgpslogger) until I start ssh-ing into the computer and doing things.

    Looking at the OBDLink device, I see that the RX/TX LEDS stop blinking when I'm doing things (ssh login, su login). This led me trying out the serial log of obdgpslogger, and its attached below. I'm not familiar with how the serial connection on obd works exactly, but I think the device sends a command/query but never gets a response, leaving obdgpslogger waiting indefinitely for the response.

    Here are the last few lines to save you from opening the file



    Attached Files

  • #2
    I suspect you may need the -m option to make it daemonise; rc.local shouldn't contain anything that blocks, which obdgpslogger is effectively doing if you don't daemonise it. I don't know why it's exiting; it may be that init notices something is wrong [ie, rc.local blocked] only after you try to do something else on the system.

    If you're having gps problems, it may be because what you really need is to be sure that obdgpslogger starts *after* gpsd connects to the device; At the moment, obdgpslogger only makes one attempt to connect to gpsd. I'm planning on changing this so that it keeps trying occasionally if it couldn't get a connection first time around.

    In the meantime, I resolved this with a little script called that waits a few seconds before launching obdgpslogger; it basically pauses execution for a few seconds, to give gpsd a chance to start. That's not ideal, and a much much better solution is to fix obdgpslogger to reconnect once in a while [as above]. The script is is doc/ in svn, called That script does some other stuff that you can probably mostly take out. I put some other thoughts in the same doc dir, in the file auto_launch

    Assuming that your system is using udev, I strongly suggest using udev to launch obdgpslogger instead of rc.local. It works the same way on bootup, but obdgpslogger's launch is tied to the actual usb device rather than the system startup. Sure, udev is irritatingly opaque to configure, but it'll also still work if the device ordering changes or you hotplug your USB devices. The docs linked above provide a few samples on how best to configure udev to work for you.

    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim


    • #3
      The gpsd problem is actually unrelated, I think upgrading to gpsd 2.90 would solve this, as I tried it earlier in with my laptop. I'll try it tomorrow on the carpc. I'll just have to remember to recompile obdgpslogger or else it wouldn't work (right?).

      I was actually thinking of getting it to run in the background, but I couldn't find how. I didn't spend that much time looking, just an obdgpslogger --help. I just checked the man page now and it's there.

      I'll also have to look into udev a lot more. My searching mostly pointed to udev being the better option but it wasn't working for me then. I'll try switching to udev the next time I work on this.

      Thanks! Really helpful to get better input regarding this.


      • #4
        Yeah, 2.90 is a different tool using a different API. You'll need to re-build from scratch [including re-running cmake; I suggest rm -rf the build dir and starting again from scratch].

        I still haven't actually been able to *try* gpsd 2.90, so the code may be incorrect. Please let me know [eg, strange lockups or crashes, or just never logging gps data]

        Gary (-;
        OBDGPSLogger, for logging OBDII and/or GPS data
        OBDSim, an OBDII/ELM327 software simulator
        mp3car forums: obdgpslogger, obdsim


        • #5
          I just read on udev, and its pretty cool. Definitely switching to this later. I'll probably set a rule for my phone too or usb drives to copy out the most recent databases(I plan to create a new one per day) to it automatically as I don't have any other interface yet to my carpc other than an ad-hoc network and ssh.


          • #6
            I haven't had the time to fiddle with gpsd and obdgps logger again yet, but my last attempt went something like this:

            I started gpsd 2.90 manually, then checked cgps to see if it's working fine. I see that it is indeed working, and move on to obdgpslogger.
            It starts fine, I see the lights on the obdLink blink, and the output indicates it found the obd device and gpsd. It says Creating new trip... but it stops there. obdLink LEDs stop blinking, and only one row is in the table.

            I haven't fully tested this so I may just be missing something. This time, I remembered to:
            unmerge then re-emerge gpsd properly
            remove all obdgpslogger files from /usr/local/bin
            remove the build directory
            run cmake then ccmake to change the devices to /dev/obd and /dev/gps
            make && make install
            then ran the proper commands


            • #7
              It's almost certainly locking in the gpsd_poll call. I saw that once before, but can't remember how I changed it. *strangled sound*

              Oh, also, I committed a change to obdgpslogger last night where every five seconds [or so], it'll attempt to create a connection to gpsd if it didn't get connected at launchtime. That may resolve some of your cold boot problems. Note that that won't help if gpsd "goes away", though.

              Gary (-;
              OBDGPSLogger, for logging OBDII and/or GPS data
              OBDSim, an OBDII/ELM327 software simulator
              mp3car forums: obdgpslogger, obdsim


              • #8
                I forgot to put in a step there that I did...
                iptables --flush

                that got me stuck for quite a while a few days ago. I forgot to put accept on the loopback device. I just flushed to make sure its not the firewall.

                I'll try that update tomorrow and maybe dig into the code too!


                • #9
                  I'm not sure if its gpsd that's causing my problems, but here's what I tried when I was checking on this.

                  I pretty much extracted the gps related code from obdgpslogger and came up with this:

                  note: I don't usually use C, so if there's anything wrong here, let me know.
                    #include <stdlib.h>
                  #include <gps.h>
                  static struct gps_data_t *gpsdata;
                  int main(int argc, char * argv[]){
                    int mustexit = 0;
                    double lat,lon;
                    printf("Starting gps client\n");
                    gpsdata = gps_open("", "2947");
                    if(gpsdata == NULL){
                      printf("Error: Unable to connect\n");
                      mustexit = 1;
                      printf("Connection established\n");
                            gps_stream(gpsdata, WATCH_ENABLE, NULL);
                    if(gpsdata->fix.mode < MODE_2D){
                      printf("location available\n");
                      lon = gpsdata->fix.longitude;
                      lat = gpsdata->fix.latitude;
                    printf("lat: %f\n",(float)lat);
                    printf("lon: %f\n",(float)lon);
                    return 0;
                  I then tested it out with gpsfake running on a test log I found from the gpsd svn. Approximately 1 out of 20 times, I get to the end of the code(but the numbers are always "nan"). Most of the time though, it'll stop at "connection established", and my cpu utilization would skyrocket because of the client.

                  I tried to look for a guide on how to use the C library properly, but I couldn't find any.

                  I tested this out on three systems, all running gentoo, gpsd 2.90, two are 64bit, 1 is 32bit. I'm guessing this is a gpsd problem?


                  • #10
                    So the root cause of this was that gps_poll blocks. There's a POLL_NONBLOCK option, but I was advised not to use it for now by the gpsd maintainer.

                    Borrowing from cgps, I've put a select in there so that it'll only call gps_poll when there's data waiting to be read.

                    At the moment, it's still broken: no data appears to be waiting most of the time, and then suddenly it starts polling after a minute or so - but no fix is ever attained. I'm highly confused.

                    But at least if you svn update right now, it no longer starts and then blocks immediately - it won't log gps, but it will log obdii.

                    I'm still working on this!

                    Gary (-;
                    OBDGPSLogger, for logging OBDII and/or GPS data
                    OBDSim, an OBDII/ELM327 software simulator
                    mp3car forums: obdgpslogger, obdsim


                    • #11
                      All fixed, now.

                      Turns out that WATCH_NEWSTYLE isn't the default, and isn't described on the relevant page, but you need it if you want it the whole thing to work on the current gpsd releases.

                      Anyways. SVN update, see if it's working for you now. Should be good!

                      Gary (-;
                      OBDGPSLogger, for logging OBDII and/or GPS data
                      OBDSim, an OBDII/ELM327 software simulator
                      mp3car forums: obdgpslogger, obdsim


                      • #12
                        Thanks! I'll try this when I get more free time, I've been busy lately doing other things.


                        • #13
                          Hi, I'm back!

                          I seem to have narrowed down my current problem of not being able to run the logger on bootup. I've set up the udev and expected it to work.

                          gpsd works properly on bootup, and having my obdgpslogger udev based on that, I hoped that would be the end of it. Turns out I was wrong, the logger doesn't start at all.

                          I've narrowed down the problem to running the logger as a daemon (-m). Right after running /usr/local/bin/obdgpslogger -m (or with -s /dev/obd) , I am thrown back at bash, as expected, but running ps aux | grep obd doesn't show anything other than the grep obd.

                          Log file doesn't exist either. in /etc/obdgpslogger I have set the baudrate, obddevice, optimisations, logfile, etc. (I'll have to check the exact parameters in the morning) I copied the names from src/conf/obdconfigfile.c and also run testobdconfig, It showed the correct parameters.

                          Any ideas?


                          • #14
                            forgot to mention, the thing works perfectly if I run it without -m and I set all the parameters at run time, I'll have to test out running it without parameters though.


                            • #15
                              One specific problem I had with udev was guaranteeing that things were being run in the right order. Off the top of my head, I'll guess that when your gps udev entry causes obdgpslogger to start, the OBDII dongle isn't available yet. udev deliberately doesn't make guarantees like this, and that's a Good Thing (TM) - but it's something we have to work around.

                              What I do is launch obdgpslogger from udev via the OBDII dongle, not the gps one. In my car, to guarantee that all the stuff necessary happens in the right order, I actually have a shell script that's used when you hotplug the OBDII device, that forks and then waits a few seconds before launching. It's in doc/ This way, I have reasonable trust that the other USB devices have been found before things actually start executing.

                              Note that that script does a couple things you may not need. It has a MEDIA_MOUNTPOINT variable; the script tries to mount that, and exits if it fails. Then it prepends the PATH to run obdgpslogger from that mount first, and points to a config file on there too. I have a sheevaplug in my car that I can't interact with; to update obdgpslogger or to reconfigure it, I just grab my external drive, plug it in to a different computer inside, and rebuild obdgpslogger there.

                              For config stuff, there's a dot-obdgpslogger(5) manpage [online here] that might be useful [to save you having to read the source :-)].

                              Gary (-;
                              OBDGPSLogger, for logging OBDII and/or GPS data
                              OBDSim, an OBDII/ELM327 software simulator
                              mp3car forums: obdgpslogger, obdsim