import time import getpass import RPi.GPIO as GPIO import setgps10hz import os import numpy as np from gpscontroller import * startloggingonstartup = True #script will auto log on startup if true switchpin = 37 # switch gpio input. pulled down to activate ledpin = 33 #led plus output os.system('clear') #clear terminal, optional setgps10hz.main() print("starting GPSD") os.system("gpsd /dev/ttyACM0") print("scanning for OBD serial") from obd_utils import scanSerial GPIO.setmode(GPIO.BOARD) GPIO.setup(switchpin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(ledpin, GPIO.OUT) # LED output High = on GPIO.output(ledpin, GPIO.LOW) gpsc = GpsController() gpsc.start()
def log_data(): output_string = ",".join(str(value) for value in sense_data) batch_data.append(output_string) def timed_log(): while run: if logging == True: log_data() time.sleep(DELAY) ## Main Program hello() setgps10hz.main() #sends command to GPS to force 10hz for ublox hardware #global gpsd #bring it in scope gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info run = True running = False logging_event = True logstate = False logging = LOG_AT_START #show_state(logging) batch_data = [] #for new filenames each command #filename = "log/"+"Log-"+str(datetime.now())+".csv" #file_setup(filename)