Good day all.
I am working on a project where when I my PI sends GPS coordinates received to a webservice. If the PI is rebooted, a cron runs and calls my python script to start the gpsd service and start sending my coordinates to my server again.
What I have done so far
So far, my Pi receives coords, and I have done the scriipt to return coordinates to my server. It's basically the code used in this link http://www.danmandle.com/blog/getting-g ... th-python/
but I have edited it to post a request instead of writing to the console and edited the sleep timer so it is called once every 60 seconds. So pretty much everything is "more less" the same".
Problem
My problem is, when the Pi reboots, this cron job isnt run or fails silently, I have changed the reboot job to another script which does a simple request to my web service and even that does not work. So my pi doesnt begin uploading GPS data until i explicitly open a terminal and run the script myself.
More Information
In the efforts of full disclosure,
I am using the Ultimate GPS Hat from Adafruit which needs this code
Code: Select all
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sockso I have placed this in rc.local.
If this code is not run the gpsd doesn't receive coords and nothing is uploaded. I dont know if this is a reason for my cron job not being run or something. However, I doubt this before because I created this simple script
Command
Code: Select all
@reboot python /home/pi/uprequest.py Code: Select all
#! /bin/bash
import requests
payload={'dogic':"8",'lat':'122','lon':'30'}
r= requests.post("http://my-link.com/trackingPI/uploadLoc.php",data=payload)I have a plan B in mind, where I remove the 60 seconds timer from the script and I call it once every minute in a cron job (since im sure that works) instead of having it to call in reboot. However, when I remove the timer, instead of just returning me one result and end, it returns like 50 when i run it once and sometimes 5 in the very same second.
I feel this way is safer cause if something goes wrong and the script isnt called in one minute it is still called in the second instance, vs if it is only called once on reboot and something goes wrong. it is never called again.
I realize that this may be two questions in one however just trying to find a working method so, any help getting this done would be appreciated
Thank you.