mzyil / gpstime Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/gpstime
Automatically exported from code.google.com/p/gpstime
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.