Giter Site home page Giter Site logo

gpstime's People

Contributors

mzyil avatar

Watchers

 avatar

gpstime's Issues

The steps to use this gpstime file.

Hi, I want to use this gpstime to set the time of the Raspberry Pi. But the 
question is I don't how to use this file. I am sorry I am a totally new guy to 
Linux. Can you tell me how to use this file to realize the time setting step by 
step? Thank you very much. The RPI uses the Debian system. 

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 2 Feb 2014 at 4:05

My code doesn't see a fix on the first run - but it does the second time it's run?

Novice programmer using gpstime to set my RPi clock...
After boot and after GPS module has a valid fix, I run my python script with 
some customization of the base code. The script doesn't recognize a valid fix 
from the GPS the first time it runs. I immediately run it again and it does see 
a valid fix and it reads the time. Is there something obvious that I'm doing 
wrong? Is something getting initialized or started on the first run that 
succeeds on the second run?
Thanks for any advice,
Shawn

Python Code (formatting, indents may be mangled)>>>>>>>>>>>>>>>>>>>>>>

import os
import sys
import time
from datetime import datetime
from gps import *
import logging
import logging.handlers

global tryfix
tryfix = 0  

####Start Logging
LOG_FILENAME = "/mnt/flash/logfile.txt"
my_logger = logging.getLogger("MyLogger")
my_logger.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(
        LOG_FILENAME, maxBytes=50000, backupCount=5)
my_logger.addHandler(handler)
my_logger.debug((datetime.now().strftime("%Y-%m-%d_%H%M%S")) + " - Attempted to 
set time from GPS")

try:
    gpsd = gps(mode=WATCH_ENABLE)
except:
    my_logger.debug((datetime.now().strftime("%Y-%m-%d_%H%M%S")) + " - No GPS Device Found")
    sys.exit()
while tryfix<6:
    gpsd.next()
    time.sleep(0.5)
    if gpsd.utc != None and gpsd.utc != '':
       gpstime = gpsd.utc[0:4] + gpsd.utc[5:7] + gpsd.utc[8:10] + ' ' + gpsd.utc[11:19]
       os.system('sudo date -u --set="%s"' % gpstime)
       my_logger.debug((datetime.now().strftime("%Y-%m-%d_%H%M%S")) + " - Time set from GPS")
       sys.exit()
    tryfix = tryfix + 1
    time.sleep(0.5)

my_logger.debug((datetime.now().strftime("%Y-%m-%d_%H%M%S")) + " - No GPS fix, 
time was not set")

Original issue reported on code.google.com by [email protected] on 18 Jun 2015 at 9:28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.