def __init__(self, win): self.set_option(0) self.win = win self.running = False self.result = {} self.elm = elm.Elm() self.elm.register_observer(self.refresh_status, 'status') self.elm.register_observer(self.refresh_progress, 'progress') self.elm.register_observer(self.refresh_log, 'logger') self.refresh_status(self.elm)
def main(): port = sys.argv[1] adapter = elm.Elm(port) obd = obdii.Obdii(adapter) while True: rpm = obd.get_current_engine_rpm() ect = obd.get_current_ect() print("RPM: %d rpm, ECT: %d C" % (rpm, ect)) time.sleep(1)
def main(): port = sys.argv[1] adapter = elm.Elm(port) data = {} adapter.send_control_command('H1') for pid in range(0, 0xe0): response = adapter.send('01%2.2x' % pid) data['%2.2x' % pid] = response print(json.dumps(data, sort_keys=True, indent=4))
def main(): port = sys.argv[1] interval = len(sys.argv) > 2 and float(sys.argv[2]) or 1.0 adapter = elm.Elm(port) obd = obdii.Obdii(adapter) print 'UNIX time, Intake Temperature, Intake Pressure, Engine load, Engine RPM, Vehicle Speed, Coolant Temperature' while True: tmp = obd.get_current_intake_air_temp() prs = obd.get_current_intake_air_pressure() eld = obd.get_current_engine_load() rpm = obd.get_current_engine_rpm() spd = obd.get_vehicle_speed() ect = obd.get_current_ect() print "%.6f, %d, %d, %d, %d, %d, %d" % (time.time(), tmp, prs, eld, rpm, spd, ect) time.sleep(interval)
def setup_method(self, method): self.mock = MockElm327() self.elm = elm.Elm(self.mock)
app = Flask(__name__) class ObdiiSim(obdii.Obdii): def get_current_engine_rpm(self): return random.randint(600, 4000) def get_throttle_position(self): return random.randint(0, 100) def get_vehicle_speed(self): return random.randint(0, 120) elm_interface = elm.Elm(test_elm.MockElm327()) #interface = obdii.Obdii(elm_interface) interface = ObdiiSim(elm_interface) @app.route("/") def home(): return render_template('home.html') @app.route('/api/engine/speed') def engine_speed(): x = interface.get_current_engine_rpm() return json.jsonify(rpm=x)