import threading 
import os
import obd
from random import random
from pathlib import Path


        

conn = obd.OBD()
connect = obd.Async(fast=False)


speed=""
fueli=""
tem =""

def get_temp(t):
    
    if not t.is_null():
        tem=str(t.value)
    if t.is_null():
        tem=str(0)
def get_fuel(f):
    
    if not f.is_null():
        fueli=str(f.value)
    if f.is_null():
        fueli= str(0)



def get_speed(s):
    
    if not s.is_null():
        speed = str(s.value)
    if s.is_null():
        speed = str(0)

connect.watch(obd.commands.INTAKE_TEMP,callback=get_temp)
connect.watch(obd.commands.FUEL_LEVEL,callback=get_fuel)
connect.watch(obd.commands.SPEED,callback=get_speed)


while True:
    tempz = open("temp.txt","w+")
    fuel1 = open("fuel.txt","w+")
    speed1 = open("speed.txt","w+")

    speed1.write(speed)
    tempz.write(tem)
    fuel1.write(fueli)
   
    print(speed)


    

import threading 
import os
import obd
from random import random
from pathlib import Path


        

conn = obd.OBD()
connect = obd.Async(fast=False)


speed=""
fueli=""
tem =""

def get_temp(t):
    
    if not t.is_null():
        tem=str(t.value)
    if t.is_null():
        tem=str(0)
def get_fuel(f):
    
    if not f.is_null():
        fueli=str(f.value)
    if f.is_null():
        fueli= str(0)



def get_speed(s):
    
    if not s.is_null():
        speed = str(s.value)
    if s.is_null():
        speed = str(0)

connect.watch(obd.commands.INTAKE_TEMP,callback=get_temp)
connect.watch(obd.commands.FUEL_LEVEL,callback=get_fuel)
connect.watch(obd.commands.SPEED,callback=get_speed)


while True:
    tempz = open("temp.txt","w+")
    fuel1 = open("fuel.txt","w+")
    speed1 = open("speed.txt","w+")

    speed1.write(speed)
    tempz.write(tem)
    fuel1.write(fueli)
   
    print(speed)


    
