com.github.pires.obd.commands.engine.RPMCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of obd-java-api Show documentation
Show all versions of obd-java-api Show documentation
OBD Java API compatible with ELM327.
package com.github.pires.obd.commands.engine;
import com.github.pires.obd.commands.ObdCommand;
import com.github.pires.obd.enums.AvailableCommandNames;
/**
* Displays the current engine revolutions per minute (RPM).
*/
public class RPMCommand extends ObdCommand {
private int rpm = -1;
/**
* Default ctor.
*/
public RPMCommand() {
super("01 0C");
}
/**
* Copy ctor.
*
* @param other a {@link RPMCommand} object.
*/
public RPMCommand(RPMCommand other) {
super(other);
}
@Override
protected void performCalculations() {
// ignore first two bytes [41 0C] of the response((A*256)+B)/4
rpm = (buffer.get(2) * 256 + buffer.get(3)) / 4;
}
/**
* @return the engine RPM per minute
*/
@Override
public String getFormattedResult() {
return String.format("%d%s", rpm, getResultUnit());
}
@Override
public String getCalculatedResult() {
return String.valueOf(rpm);
}
@Override
public String getResultUnit() {
return "RPM";
}
@Override
public String getName() {
return AvailableCommandNames.ENGINE_RPM.getValue();
}
/**
* @return a int.
*/
public int getRPM() {
return rpm;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy