UNPKG

rxjs-obd

Version:

RxJS Implementation for OBD (On Board Diagnostics) of vehicles via ELM 327 connections.

46 lines 1.28 kB
import { OBDOuterSubscriber } from '../model/OBDOuterSubscriber'; export function fuelTankLevel() { return function (source) { return source.lift(new FuelTankLevelOperator()); }; } class FuelTankLevelOperator { call(subscriber, source) { return source.subscribe(new FuelTankLevelSubscriber(subscriber)); } } class FuelTankLevelSubscriber extends OBDOuterSubscriber { constructor(destination) { super(destination); } /** * Return the frequency of execution of this command. * @return that this command must be executed every 5 pulses. */ pulse() { return 5; } /** * Return the string representation of the OBD Read command. * @returns the string representation of the OBD Read command */ command() { return '01 2F 1\r'; } /** * Return the name of the OBD Field on OBD Data object. * @returns the name of the OBD Field on OBD Data object. */ field() { return 'fuelTankLevel'; } /** * Parse the OBD response. * @param bytes the response read from OBD. * @returns the parsed response. */ parse(bytes) { return parseInt(bytes[2], 16) * 100 / 255; } } //# sourceMappingURL=fuelTankLevel.js.map