Example #1
0
 def serial(self):
     """S300 serial number"""
     indexes_1 = {
         constants.S3003_ID: constants.S3003_SERIAL1,
     }
     indexes_2 = {
         constants.S3003_ID: constants.S3003_SERIAL2,
     }
     return (
         256 * get_value_from_ecu(self.version, indexes_2, self.data4, 0)
     ) + get_value_from_ecu(self.version, indexes_1, self.data4, 0)
Example #2
0
    def firmware(self):
        """Firmware version"""
        indexes_1 = {
            constants.S3003_ID: constants.S3003_FIRM1,
        }
        indexes_2 = {
            constants.S3003_ID: constants.S3003_FIRM2,
        }

        return "{}.{:02d}".format(
            get_value_from_ecu(self.version, indexes_1, self.data4),
            get_value_from_ecu(self.version, indexes_2, self.data4),
        )
Example #3
0
 def map(self):
     """Manifold absolute pressure"""
     indexes_1 = {
         constants.S3003_ID: constants.S3003_MAP1,
     }
     indexes_2 = {
         constants.S3003_ID: constants.S3003_MAP2,
     }
     data_from_s300 = (
         256 * get_value_from_ecu(self.version, indexes_2, self.data6)
     ) + get_value_from_ecu(self.version, indexes_1, self.data6)
     map_bar = data_from_s300 / 100.0
     map_mbar = map_bar * 1000
     map_psi = Formula.bar_to_psi(map_bar)
     return {"bar": map_bar, "mbar": map_mbar, "psi": map_psi}
Example #4
0
 def rpm(self):
     """
     Revs per minute
     return unit: revs per minute
     """
     indexes_1 = {
         constants.S3003_ID: constants.S3003_RPM1,
     }
     indexes_2 = {
         constants.S3003_ID: constants.S3003_RPM2,
     }
     return int(
         (256 * get_value_from_ecu(self.version, indexes_2, self.data6))
         + get_value_from_ecu(self.version, indexes_1, self.data6)
     )
Example #5
0
 def bksw(self):
     """Brake switch"""
     mask = 0x02
     indexes = {
         constants.S3003_ID: constants.S3003_BKSW,
     }
     return bool(get_value_from_ecu(self.version, indexes, self.data6) & mask)
Example #6
0
 def scs(self):
     """Service connector"""
     mask = 0x10
     indexes = {
         constants.S3003_ID: constants.S3003_SCS,
     }
     return bool(get_value_from_ecu(self.version, indexes, self.data6) & mask)
Example #7
0
 def gear(self):
     """Gear"""
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_GEAR,
         constants.KPRO4_ID: constants.KPRO4_GEAR,
     }
     return get_value_from_ecu(self.version, indexes, self.data0)
Example #8
0
 def mil(self):
     """Malfunction indicator light also known as check engine light"""
     indexes = {
         constants.S3003_ID: constants.S3003_MIL,
     }
     mask = 0x20
     return bool(get_value_from_ecu(self.version, indexes, self.data6) & mask)
Example #9
0
 def fanc(self):
     """Fan switch"""
     mask = 0x80
     indexes = {
         constants.S3003_ID: constants.S3003_FANC,
     }
     return bool(get_value_from_ecu(self.version, indexes, self.data6) & mask)
Example #10
0
 def flt(self):
     """Fuel temperature
     TODO: RETURN {"celsius": 0, "fahrenheit": 0} if fails
     """
     indexes = {constants.KPRO4_ID: constants.KPRO4_FLT}
     flt_celsius = get_value_from_ecu(self.version, indexes, self.data3)
     flt_fahrenheit = Formula.celsius_to_fahrenheit(flt_celsius)
     return {"celsius": flt_celsius, "fahrenheit": flt_fahrenheit}
Example #11
0
 def eth(self):
     """
     Ethanol content
     return unit: per cent
     """
     indexes = {
         constants.S3003_ID: constants.S3003_ETH,
     }
     return get_value_from_ecu(self.version, indexes, self.data5)
Example #12
0
 def flr(self):
     """Fuel relay"""
     mask = 0x40
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_FLR,
         constants.KPRO4_ID: constants.KPRO4_FLR,
     }
     return bool(
         get_value_from_ecu(self.version, indexes, self.data0) & mask)
Example #13
0
 def rvslck(self):
     """Reverse gear lock"""
     mask = 0x01
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_RVSLCK,
         constants.KPRO4_ID: constants.KPRO4_RVSLCK,
     }
     return bool(
         get_value_from_ecu(self.version, indexes, self.data0) & mask)
Example #14
0
 def eps(self):
     """Electric power steering"""
     mask = 0x20
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_EPS,
         constants.KPRO4_ID: constants.KPRO4_EPS,
     }
     return bool(
         get_value_from_ecu(self.version, indexes, self.data0) & mask)
Example #15
0
 def bat(self):
     """
     Battery voltage
     return unit: volts
     """
     indexes = {
         constants.S3003_ID: constants.S3003_BAT,
     }
     return get_value_from_ecu(self.version, indexes, self.data6) * 0.1 - 0.5
Example #16
0
 def accl(self):
     """A/C clutch"""
     mask = 0x08
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_ACCL,
         constants.KPRO4_ID: constants.KPRO4_ACCL,
     }
     return bool(
         get_value_from_ecu(self.version, indexes, self.data0) & mask)
Example #17
0
 def acsw(self):
     """A/C switch"""
     mask = 0x04
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_ACSW,
         constants.KPRO4_ID: constants.KPRO4_ACSW,
     }
     return bool(
         get_value_from_ecu(self.version, indexes, self.data0) & mask)
Example #18
0
 def o2(self):
     """Oxygen sensor"""
     indexes_1 = {
         constants.KPRO23_ID: constants.KPRO23_AFR1,
         constants.KPRO4_ID: constants.KPRO4_AFR1,
     }
     indexes_2 = {
         constants.KPRO23_ID: constants.KPRO23_AFR2,
         constants.KPRO4_ID: constants.KPRO4_AFR2,
     }
     try:
         o2_lambda = 32768.0 / (
             256 * get_value_from_ecu(self.version, indexes_2, self.data0) +
             get_value_from_ecu(self.version, indexes_1, self.data0))
     except ZeroDivisionError:  # something happen collecting the value then return 0
         return {"afr": 0, "lambda": 0}
     o2_afr = o2_lambda * 14.7
     return {"afr": o2_afr, "lambda": o2_lambda}
Example #19
0
 def vss(self):
     """Vehicle speed sensor"""
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_VSS,
         constants.KPRO4_ID: constants.KPRO4_VSS,
     }
     vss_kmh = get_value_from_ecu(self.version, indexes, self.data0)
     vss_mph = Formula.kmh_to_mph(vss_kmh)
     return {"kmh": vss_kmh, "mph": int(vss_mph)}
Example #20
0
 def ecu_type(self):
     """Model of ECU"""
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_ECU_TYPE,
         constants.KPRO4_ID: constants.KPRO4_ECU_TYPE,
     }
     data_from_kpro = get_value_from_ecu(self.version, indexes, self.data4)
     if data_from_kpro == 3:  # TODO the rest of ecu types
         return "RSX - PRB"
     return "unknown"
Example #21
0
 def o2(self):
     """Oxygen sensor"""
     indexes_1 = {
         constants.S3003_ID: constants.S3003_AFR,
     }
     o2_lambda = (
         get_value_from_ecu(self.version, indexes_1, self.data6) - 1.1588
     ) / 126.35
     o2_afr = o2_lambda * 14.7
     return {"afr": o2_afr, "lambda": o2_lambda}
Example #22
0
 def mil(self):
     """Malfunction indicator light also known as check engine light"""
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_MIL,
         constants.KPRO4_ID: constants.KPRO4_MIL,
     }
     if self.version == constants.KPRO23_ID:
         data_from_kpro = get_value_from_ecu(self.version, indexes,
                                             self.data0)
         if data_from_kpro == 9:
             return True
         return False
     elif self.version == constants.KPRO4_ID:
         data_from_kpro = get_value_from_ecu(self.version, indexes,
                                             self.data3)
         if data_from_kpro >= 36:
             return True
         return False
     return False
Example #23
0
 def vss(self):
     """Vehicle speed sensor"""
     indexes_1 = {
         constants.S3003_ID: constants.S3003_VSS1,
     }
     indexes_2 = {
         constants.S3003_ID: constants.S3003_VSS2,
     }
     try:
         vss_kmh = int(
             227125
             / (
                 256 * get_value_from_ecu(self.version, indexes_2, self.data6)
                 + get_value_from_ecu(self.version, indexes_1, self.data6)
             )
         )
     except ZeroDivisionError:
         vss_kmh = 0
     vss_mph = Formula.kmh_to_mph(vss_kmh)
     return {"kmh": vss_kmh, "mph": int(vss_mph)}
Example #24
0
 def iat(self):
     """Intake air temperature"""
     indexes = {
         constants.S3003_ID: constants.S3003_IAT,
     }
     data_from_s300 = get_value_from_ecu(
         self.version, indexes, self.data6, {"celsius": 0, "fahrenheit": 0}
     )
     if isinstance(data_from_s300, int):
         return Formula.kpro_temp(data_from_s300)
     else:
         return data_from_s300
Example #25
0
    def ign(self):
        """Ignition status"""
        indexes = {
            constants.KPRO23_ID: constants.KPRO23_IGN,
            constants.KPRO4_ID: constants.KPRO4_IGN,
        }
        data_from_kpro = get_value_from_ecu(self.version, indexes, self.data4,
                                            0)

        if data_from_kpro == 1:
            return True
        return False
Example #26
0
 def ect(self):
     """Engine coolant temperature"""
     indexes = {
         constants.S3003_ID: constants.S3003_ECT,
     }
     data_from_kpro = get_value_from_ecu(
         self.version, indexes, self.data6, {"celsius": 0, "fahrenheit": 0}
     )
     if isinstance(data_from_kpro, int):
         return Formula.kpro_temp(data_from_kpro)
     else:
         return data_from_kpro
Example #27
0
 def tps(self):
     """
     Throttle position sensor
     return unit: 0-100%
     """
     indexes = {
         constants.S3003_ID: constants.S3003_TPS,
     }
     return int(
         interp(
             get_value_from_ecu(self.version, indexes, self.data6),
             [25, 255],
             [0, 115],
         )
     )
Example #28
0
 def tps(self):
     """
     Throttle position sensor
     return unit: 0-100%
     """
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_TPS,
         constants.KPRO4_ID: constants.KPRO4_TPS,
     }
     return int(
         interp(
             get_value_from_ecu(self.version, indexes, self.data0),
             [21, 229],
             [0, 100],
         ))
Example #29
0
 def cam(self):
     """
     VTC cam angle
     return units: degrees
     """
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_CAM,
         constants.KPRO4_ID: constants.KPRO4_CAM,
     }
     data_from_kpro = get_value_from_ecu(self.version, indexes, self.data0,
                                         None)
     if data_from_kpro is not None:
         return (data_from_kpro - 40) * 0.5
     else:
         return 0
Example #30
0
 def map(self):
     """Manifold absolute pressure"""
     indexes = {
         constants.KPRO23_ID: constants.KPRO23_MAP,
         constants.KPRO4_ID: constants.KPRO4_MAP,
     }
     data_from_kpro = get_value_from_ecu(self.version, indexes, self.data0,
                                         {
                                             "bar": 0,
                                             "mbar": 0,
                                             "psi": 0
                                         })
     if isinstance(data_from_kpro, int):
         map_bar = data_from_kpro / 100.0
         map_mbar = map_bar * 1000
         map_psi = Formula.bar_to_psi(map_bar)
         return {"bar": map_bar, "mbar": map_mbar, "psi": map_psi}
     return data_from_kpro