Device-ELM327
view release on metacpan or search on metacpan
lib/Device/ELM327.pm view on Meta::CPAN
my $obd = Device::ELM327->new("", $debug_level);
The module can replay previously captured debugging information:
my $obd = Device_ELM327->new(undef, $debug_level, $replay_filename);
To produce a file containing replayable data simply set $debug_level to
1 or higher and pipe the output to a text file:
perl test.pl>test_output.txt
=cut
sub new
{
my ($class, $port_details, $debug_level, $replay_filename) = @_;
my $self = bless { }, $class;
$self->{'version'} = $VERSION;
$self->{'debug_level'} = 0;
if (defined($debug_level))
{
$self->{'debug_level'} = $debug_level;
}
$self->{'ELM_type'} = "NONE";
$self->{'bus_type'} = "unknown";
$self->{'replay_file'} = 0;
$self->{'replay_response'} = ();
$self->{'last_command'} = 0;
$self->{'last_sub_command'} = 0;
$self->{'response'} = (); # Array of strings, one per line of the response.
$self->{'response_length'} = 0; # Total number of characters in the response.
$self->{'results'} = {};
$self->{'number_of_results'} = 0;
$self->{'command_addresses'} = [];
$self->{'command_results'} = [];
$self->{'trouble_codes'} = [];
# ~4.5 second delay (.0001*301*(300/2))
$self->{'rr_tries'} = 300;
$self->{'rr_retry_delay'} = .0001;
# Status codes
$self->{'status_meanings'} = {
"ok" => "No errors detected",
"Zero length response" => "No data was returned by the ECU",
"NO DATA" => "A 'NO DATA' response was returned by the ELM",
"STOPPED" => "A 'STOPPED' response was returned by the ELM",
"Port not ok" => "The connection to the ELM module failed",
"Negative response" => "The vehicle returned a negative response",
"Unsupported name" => "The vehicle does not support this value",
"Unrecognised name" => "ELM327.pm does not recognise this value",
"General Reject" => "Service was rejected. ECU did not specify the reason",
"Service Not Supported" => "The ECU does not support the requested service",
"Sub Function Not Supported - Invalid Format" => "The ECU does not support the arguments of the request message or the format of the argument bytes do not match the prescribed format for the service",
"Busy - Repeat Request" => "The ECU is temporarily too busy to perform the requested operation",
"Conditions Not Correct or Request Sequence Error" => "ECU prerequisite conditions not met. Have commands been issued in the correct order?",
"Request Correctly Received - Response Pending" => "Correct command and parameters received, but ECU is busy. Response will follow.",
};
# Negative response codes (received with a 7F Negative Response Service Identifier)
$self->{'negative_response_codes'} = {
"0" => "ok",
"10" => "General Reject",
"11" => "Service Not Supported",
"12" => "Sub Function Not Supported - Invalid Format",
"21" => "Busy - Repeat Request",
"22" => "Conditions Not Correct or Request Sequence Error",
"78" => "Request Correctly Received - Response Pending",
};
# ISO Standard Test Id's for use with function 6.
$self->{'Standardized_Test_IDs'} = {
"0" => {name => "ISO/SAE reserved"},
"1" => {name => "Rich to lean sensor threshold voltage (constant)"},
"2" => {name => "Lean to rich sensor threshold voltage (constant)"},
"3" => {name => "Low sensor voltage for switch time calculation (constant)"},
"4" => {name => "High sensor voltage for switch time calculation (constant)"},
"5" => {name => "Rich to lean sensor switch time (calculated)"},
"6" => {name => "Lean to rich sensor switch time (calculated)"},
"7" => {name => "Minimum sensor voltage for test cycle (calculated)"},
"8" => {name => "Maximum sensor voltage for test cycle (calculated)"},
"9" => {name => "Time between sensor transitions (calculated)"},
"10" => {name => "Sensor period (calculated)"},
"11" => {name => "Exponential Weighted Moving Average misfire counts for last ten driving cycles"},
"12" => {name => "Misfire counts for last/current driving cycles"},
"13" => {name => "Reserved for future standardization"},
};
# ISO Unit and scaling identifiers
$self->{'unit_and_scaling_identifiers'} = {
"1" => {description => "Raw Value", modifier =>"+0", unit => ""},
"2" => {description => "Raw Value", modifier =>"/10", unit => ""},
"3" => {description => "Raw Value", modifier =>"/100", unit => ""},
"4" => {description => "Raw Value", modifier =>"/100", unit => ""},
"5" => {description => "Raw Value", modifier =>"*0.0000305", unit => ""},
"6" => {description => "Raw Value", modifier =>"*0.000305", unit => ""},
"7" => {description => "rotational frequency", modifier =>"/4", unit => "rpm"},
"8" => {description => "Speed", modifier =>"/100", unit => "km/h"},
"9" => {description => "Speed", modifier =>"+0", unit => "km/h"},
"10" => {description => "Voltage", modifier =>"*0.000122", unit => "V"},
"11" => {description => "Voltage", modifier =>"/1000", unit => "V"},
"12" => {description => "Voltage", modifier =>"/100", unit => "V"},
"13" => {description => "Current", modifier =>"*0.00390625", unit => "mA"},
"14" => {description => "Current", modifier =>"*0.001", unit => "mA"},
"15" => {description => "Current", modifier =>"*0.01", unit => "mA"},
"16" => {description => "Time", modifier =>"+0", unit => "ms"},
"17" => {description => "Time", modifier =>"/10", unit => "s"},
"18" => {description => "Time", modifier =>"+0", unit => "s"},
"19" => {description => "Resistance", modifier =>"/1000", unit => "Ohm"},
"20" => {description => "Resistance", modifier =>"/1000", unit => "kOhm"},
"21" => {description => "Resistance", modifier =>"+0", unit => "kOhm"},
"22" => {description => "Temperature", modifier =>"/10-40", unit => "°C"},
"23" => {description => "Pressure (Gauge)", modifier =>"*0.01", unit => "kPa"},
"24" => {description => "Pressure (Air pressure)", modifier =>"*0.0117", unit => "kPa"},
( run in 2.990 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )