Documentation
¶
Overview ¶
Package elmobd provides communication with cars OBD-II system using ELM327 based USB-devices.
Using this library and a ELM327-based USB-device you can communicate with your cars on-board diagnostics system to read sensor data. Reading trouble codes and resetting them is not yet implemented.
All assumptions this library makes are based on the official Elm Electronics datasheet of the ELM327 IC: https://www.elmelectronics.com/wp-content/uploads/2017/01/ELM327DS.pdf
After that introduction - Welcome! I hope you'll find this library useful and its documentation easy to digest. If that's not the case, please create a GitHub-issue: https://github.com/rzetterberg/elmobd/issues
You'll note that this package has the majority its types and functions exported. The reason for that is that there are many different commands you can send to a ELM327 device, and this library will never we able to define all commands, so most functionality is exported so that you can easily extend it.
You'll also note that there are A LOT of types. The reason for this is each command that can be sent to the ELM327 device is defined as it's own type. The approach I wanted to take with this library was to get as much type safety as possible.
With that said, as an end user of this library you'll only need to know about two kinds types: the Device type and types that implement the OBDCommand interface.
The Device type represents an active connection with an ELM327 device. You plug in your device into your computer, get the path to the device and initlize a new device:
package main
import (
"flag"
"fmt"
"github.com/rzetterberg/elmobd"
)
func main() {
serialPath := flag.String(
"serial",
"/dev/ttyUSB0",
"Path to the serial device to use",
)
flag.Parse()
dev, err := elmobd.NewDevice(*serialPath, false)
if err != nil {
fmt.Println("Failed to create new device", err)
return
}
}
This library is design to be as high level as possible, you shouldn't need to handle baud rates, setting protocols or anything like that. After the Device has been initialized you can just start sending commands.
The function you will be using the most is the Device.RunOBDCommand, which accepts a command, sends the command to the device, waits for a response, parses the response and gives it back to you. Which means this command is blocking execution until it has been finished. The default timeout is currently set to 5 seconds.
The RunOBDCommand accepts a single argument, a type that implements the OBDCommand interface. That interface has a couple of functions that needs to exist in order to be able to generate the low-level request for the device and parse the low-level response. Basically you send in an empty OBDCommand and get back a OBDCommand with the processed value retrieved from the device.
Suppose that after checking the device connection (in our example above) we would like to retrieve the vehicles speed. There's a type called VehicleSpeed that implements the OBDCommand interface that we can use. We start by creating a new VehicleSpeed using its constructor NewVehicleSpeed that we then give to RunOBDCommand:
speed, err := dev.RunOBDCommand(elmobd.NewVehicleSpeed())
if err != nil {
fmt.Println("Failed to get vehicle speed", err)
return
}
fmt.Printf("Vehicle speed: %d km/h\n", speed.Value)
At the moment there are around 15 sensor commands defined in this library. They are all defined in the file commands.go of the library (https://github.com/rzetterberg/elmobd/blob/master/commands.go). If you look in the end of that file you'll find an internal static variable with all the sensor commands called sensorCommands.
That's the basics of this library - you create a device connection and then run commands. Documentation of more advanced use-cases is in the works, so don't worry! If there's something that you wish would be documented, or something that is not clear in the current documentation, please create a GitHub-issue.
Index ¶
- type BaseCommand
- type CoolantTemperature
- type Device
- func (dev *Device) CheckSupportedCommands() (*SupportedCommands, error)
- func (dev *Device) DirectDeviceCommand(directCmd string) (string, error)
- func (dev *Device) GetVersion() (string, error)
- func (dev *Device) RunManyOBDCommands(commands []OBDCommand) ([]OBDCommand, error)
- func (dev *Device) RunOBDCommand(cmd OBDCommand) (OBDCommand, error)
- func (dev *Device) SetAutomaticProtocol() error
- type DistSinceDTCClear
- type EngineLoad
- type EngineRPM
- type FloatCommand
- type FreezeFrame
- type Fuel
- type FuelPressure
- type FuelSystemStatus
- type IntCommand
- type IntakeAirTemperature
- type IntakeManifoldPressure
- type LongFuelTrim1
- type LongFuelTrim2
- type MafAirFlowRate
- type MockDevice
- type MockResult
- type MonitorStatus
- type OBDCommand
- type OBDParameterID
- type OBDStandards
- type Part1Supported
- type Part2Supported
- type Part3Supported
- type Part4Supported
- type Part5Supported
- type RawDevice
- type RawResult
- type RealDevice
- type RealResult
- type Result
- type RuntimeSinceStart
- type ShortFuelTrim1
- type ShortFuelTrim2
- type SupportedCommands
- type ThrottlePosition
- type TimingAdvance
- type UIntCommand
- type VehicleSpeed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseCommand ¶
type BaseCommand struct {
// contains filtered or unexported fields
}
BaseCommand is a simple struct with the 3 members that all OBDCommands will have in common.
func (*BaseCommand) DataWidth ¶
func (cmd *BaseCommand) DataWidth() byte
DataWidth retrieves the amount of bytes the command expects from the ELM327 devices.
func (*BaseCommand) Key ¶
func (cmd *BaseCommand) Key() string
Key retrieves the unique literal key of the command, used when exporting commands.
func (*BaseCommand) ModeID ¶
func (cmd *BaseCommand) ModeID() byte
ModeID retrieves the mode ID of the command.
func (*BaseCommand) ParameterID ¶
func (cmd *BaseCommand) ParameterID() OBDParameterID
ParameterID retrieves the Parameter ID (also called PID) of the command.
func (*BaseCommand) ToCommand ¶
func (cmd *BaseCommand) ToCommand() string
ToCommand retrieves the raw command that can be sent to the ELM327 device.
The command is sent without spaces between the parts, the amount of data lines is added to the end of the command to speed up the communication. See page 33 of the ELM327 data sheet for details on why we do this.
type CoolantTemperature ¶
type CoolantTemperature struct {
BaseCommand
IntCommand
}
CoolantTemperature represents a command that checks the engine coolant temperature in Celsius.
Min: -40 Max: 215
func NewCoolantTemperature ¶
func NewCoolantTemperature() *CoolantTemperature
NewCoolantTemperature creates a new CoolantTemperature with the right parameters.
func (*CoolantTemperature) SetValue ¶
func (cmd *CoolantTemperature) SetValue(result *Result) error
SetValue processes the byte array value into the right integer value.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents the connection to a ELM327 device. This is the data type you use to run commands on the connected ELM327 device, see NewDevice for creating a Device and RunOBDCommand for running commands.
func NewDevice ¶
NewDevice constructs a Device by initilizing the serial connection and setting the protocol to talk with the car to "automatic".
func NewTestDevice ¶
NewTestDevice constructs a Device which is using a mocked RawDevice.
func (*Device) CheckSupportedCommands ¶
func (dev *Device) CheckSupportedCommands() (*SupportedCommands, error)
CheckSupportedCommands check which commands are supported (PID 1 to PID 160) by the car connected to the ELM327 device.
Since a single command can only contain 32-bits of information 5 commands are run in series by this function to get the whole 160-bits of information.
Returns error if the first command (PID 1 to 20) fails, the rest of the 5 commands are ignored if they fail.
func (*Device) DirectDeviceCommand ¶
DirectDeviceCommand executes the raw command passed to the ELM chipset
func (*Device) GetVersion ¶
GetVersion gets the version of the connected ELM327 device. The latest version being v2.2.
func (*Device) RunManyOBDCommands ¶
func (dev *Device) RunManyOBDCommands(commands []OBDCommand) ([]OBDCommand, error)
RunManyOBDCommands is a helper function to run multiple commands in series.
func (*Device) RunOBDCommand ¶
func (dev *Device) RunOBDCommand(cmd OBDCommand) (OBDCommand, error)
RunOBDCommand runs the given OBDCommand on the connected ELM327 device and populates the OBDCommand with the parsed output from the device.
func (*Device) SetAutomaticProtocol ¶
SetAutomaticProtocol tells the ELM327 device to automatically discover what protocol to talk to the car with. How the protocol is chhosen is something that the ELM327 does internally. If you're interested in how this works you can look in the data sheet linked in the beginning of the package description.
type DistSinceDTCClear ¶
type DistSinceDTCClear struct {
BaseCommand
UIntCommand
}
DistSinceDTCClear represents a command that checks distance since last DTC clear
Min: 0 Max: 65535
func NewDistSinceDTCClear ¶
func NewDistSinceDTCClear() *DistSinceDTCClear
NewDistSinceDTCClear creates a new commend distance since DTC clear with the correct parameters.
func (*DistSinceDTCClear) SetValue ¶
func (cmd *DistSinceDTCClear) SetValue(result *Result) error
SetValue processes the byte array value into the right uint value.
type EngineLoad ¶
type EngineLoad struct {
BaseCommand
FloatCommand
}
EngineLoad represents a command that checks the engine load in percent
Min: 0.0 Max: 1.0
func NewEngineLoad ¶
func NewEngineLoad() *EngineLoad
NewEngineLoad creates a new EngineLoad with the correct parameters.
func (*EngineLoad) SetValue ¶
func (cmd *EngineLoad) SetValue(result *Result) error
SetValue processes the byte array value into the right float value.
type EngineRPM ¶
type EngineRPM struct {
BaseCommand
FloatCommand
}
EngineRPM represents a command that checks eEngine revolutions per minute.
Min: 0.0 Max: 16383.75
func NewEngineRPM ¶
func NewEngineRPM() *EngineRPM
NewEngineRPM creates a new EngineRPM with the right parameters.
type FloatCommand ¶
type FloatCommand struct {
Value float32
}
FloatCommand is just a shortcut for commands that retrieve floating point values from the ELM327 device.
func (*FloatCommand) ValueAsLit ¶
func (cmd *FloatCommand) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation.
type FreezeFrame ¶
type FreezeFrame struct {
BaseCommand
FrameData string
}
FreezeFrame represents a command that checks the DTC that caused required freeze frame data storage
Min 0x0000 Max 0xFFFF
func NewFreezeFrame ¶
func NewFreezeFrame() *FreezeFrame
NewFreezeFrame creates a new command that contains DTC freeze frame stored data
func (*FreezeFrame) SetValue ¶
func (cmd *FreezeFrame) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
func (*FreezeFrame) ValueAsLit ¶
func (cmd *FreezeFrame) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation.
type Fuel ¶
type Fuel struct {
BaseCommand
FloatCommand
}
Fuel represents a command that checks the fuel quantity in percent
Min: 0.0 Max: 1.0
type FuelPressure ¶
type FuelPressure struct {
BaseCommand
UIntCommand
}
FuelPressure represents a command that checks the fuel pressure in kPa.
Min: 0 Max: 765
func NewFuelPressure ¶
func NewFuelPressure() *FuelPressure
NewFuelPressure creates a new FuelPressure with the right parameters.
func (*FuelPressure) SetValue ¶
func (cmd *FuelPressure) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type FuelSystemStatus ¶
type FuelSystemStatus struct {
BaseCommand
FuelSystem1 string
FuelSystem2 string
}
FuelSystemStatus represents a command that reports the fuel system status
func (*FuelSystemStatus) SetValue ¶
func (cmd *FuelSystemStatus) SetValue(result *Result) error
SetValue processes the byte array value in the right values
func (*FuelSystemStatus) ValueAsLit ¶
func (cmd *FuelSystemStatus) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation
type IntCommand ¶
type IntCommand struct {
Value int
}
IntCommand is just a shortcut for commands that retrieve integer values from the ELM327 device.
func (*IntCommand) ValueAsLit ¶
func (cmd *IntCommand) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation.
type IntakeAirTemperature ¶
type IntakeAirTemperature struct {
BaseCommand
IntCommand
}
IntakeAirTemperature represents a command that checks the intake air temperature in Celsius.
Min: -40 Max: 215
func NewIntakeAirTemperature ¶
func NewIntakeAirTemperature() *IntakeAirTemperature
NewIntakeAirTemperature creates a new IntakeAirTemperature with the right parameters.
func (*IntakeAirTemperature) SetValue ¶
func (cmd *IntakeAirTemperature) SetValue(result *Result) error
SetValue processes the byte array value into the right integer value.
type IntakeManifoldPressure ¶
type IntakeManifoldPressure struct {
BaseCommand
UIntCommand
}
IntakeManifoldPressure represents a command that checks the intake manifold pressure in kPa.
Min: 0 Max: 255
func NewIntakeManifoldPressure ¶
func NewIntakeManifoldPressure() *IntakeManifoldPressure
NewIntakeManifoldPressure creates a new IntakeManifoldPressure with the right parameters.
func (*IntakeManifoldPressure) SetValue ¶
func (cmd *IntakeManifoldPressure) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type LongFuelTrim1 ¶
type LongFuelTrim1 struct {
// contains filtered or unexported fields
}
LongFuelTrim1 represents a command that checks the long term fuel trim for bank 1.
func NewLongFuelTrim1 ¶
func NewLongFuelTrim1() *LongFuelTrim1
NewLongFuelTrim1 creates a new LongFuelTrim1 with the right parameters.
type LongFuelTrim2 ¶
type LongFuelTrim2 struct {
// contains filtered or unexported fields
}
LongFuelTrim2 represents a command that checks the long term fuel trim for bank 2.
func NewLongFuelTrim2 ¶
func NewLongFuelTrim2() *LongFuelTrim2
NewLongFuelTrim2 creates a new LongFuelTrim2 with the right parameters.
type MafAirFlowRate ¶
type MafAirFlowRate struct {
BaseCommand
FloatCommand
}
MafAirFlowRate represents a command that checks the mass Air Flow sensor flow rate grams/second.
Min: 0 Max: 655.35
More information about MAF: https://en.wikipedia.org/wiki/Mass_flow_sensor
func NewMafAirFlowRate ¶
func NewMafAirFlowRate() *MafAirFlowRate
NewMafAirFlowRate creates a new MafAirFlowRate with the right parameters.
func (*MafAirFlowRate) SetValue ¶
func (cmd *MafAirFlowRate) SetValue(result *Result) error
SetValue processes the byte array value into the right float value.
type MockDevice ¶
type MockDevice struct {
}
MockDevice represent a mocked serial connection
func (*MockDevice) RunCommand ¶
func (dev *MockDevice) RunCommand(command string) RawResult
RunCommand mocks the given AT/OBD command by just returning a result for the mocked outputs set earlier.
type MockResult ¶
type MockResult struct {
// contains filtered or unexported fields
}
MockResult represents the raw text output of running a raw command, including information used in debugging to show what input caused what error, how long the command took, etc.
func (*MockResult) Failed ¶
func (res *MockResult) Failed() bool
Failed checks if the result is successful or not
func (*MockResult) FormatOverview ¶
func (res *MockResult) FormatOverview() string
FormatOverview formats a result as an overview of what command was run and how long it took.
func (*MockResult) GetError ¶
func (res *MockResult) GetError() error
GetError returns the results current error
func (*MockResult) GetOutputs ¶
func (res *MockResult) GetOutputs() []string
GetOutputs returns the outputs of the result
type MonitorStatus ¶
type MonitorStatus struct {
BaseCommand
MilActive bool
DtcAmount byte
}
MonitorStatus represents a command that checks the status since DTCs were cleared last time. This includes the MIL status and the amount of DTCs.
func NewMonitorStatus ¶
func NewMonitorStatus() *MonitorStatus
NewMonitorStatus creates a new MonitorStatus.
func (*MonitorStatus) SetValue ¶
func (cmd *MonitorStatus) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
func (*MonitorStatus) ValueAsLit ¶
func (cmd *MonitorStatus) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation.
type OBDCommand ¶
type OBDCommand interface {
ModeID() byte
ParameterID() OBDParameterID
DataWidth() byte
Key() string
SetValue(*Result) error
ValueAsLit() string
ToCommand() string
}
OBDCommand is an interface that all OBD commands needs to implement to be able to be used with the Device.
func GetSensorCommands ¶
func GetSensorCommands() []OBDCommand
GetSensorCommands returns all the defined commands that are not commands that check command availability on the connected car.
type OBDParameterID ¶
type OBDParameterID byte
OBDParameterID is an alias to give meaning to this particular byte.
type OBDStandards ¶
type OBDStandards struct {
BaseCommand
UIntCommand
}
OBDStandards represents a command that checks the OBD standards this vehicle conforms to as a single decimal value:
- 1 OBD-II as defined by the CARB - 2 OBD as defined by the EPA - 3 OBD and OBD-II - 4 OBD-I - 5 Not OBD compliant - 6 EOBD (Europe) - 7 EOBD and OBD-II - 8 EOBD and OBD - 9 EOBD, OBD and OBD II - 10 JOBD (Japan) - 11 JOBD and OBD II - 12 JOBD and EOBD - 13 JOBD, EOBD, and OBD II - 14 Reserved - 15 Reserved - 16 Reserved - 17 Engine Manufacturer Diagnostics (EMD) - 18 Engine Manufacturer Diagnostics Enhanced (EMD+) - 19 Heavy Duty On-Board Diagnostics (Child/Partial) (HD OBD-C) - 20 Heavy Duty On-Board Diagnostics (HD OBD) - 21 World Wide Harmonized OBD (WWH OBD) - 22 Reserved - 23 Heavy Duty Euro OBD Stage I without NOx control (HD EOBD-I) - 24 Heavy Duty Euro OBD Stage I with NOx control (HD EOBD-I N) - 25 Heavy Duty Euro OBD Stage II without NOx control (HD EOBD-II) - 26 Heavy Duty Euro OBD Stage II with NOx control (HD EOBD-II N) - 27 Reserved - 28 Brazil OBD Phase 1 (OBDBr-1) - 29 Brazil OBD Phase 2 (OBDBr-2) - 30 Korean OBD (KOBD) - 31 India OBD I (IOBD I) - 32 India OBD II (IOBD II) - 33 Heavy Duty Euro OBD Stage VI (HD EOBD-IV) - 34-250 Reserved - 251-255 Not available for assignment (SAE J1939 special meaning)
func NewOBDStandards ¶
func NewOBDStandards() *OBDStandards
NewOBDStandards creates a new OBDStandards with the right parameters.
func (*OBDStandards) SetValue ¶
func (cmd *OBDStandards) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type Part1Supported ¶
type Part1Supported struct {
BaseCommand
UIntCommand
}
Part1Supported represents a command that checks the supported PIDs 0 to 20
func NewPart1Supported ¶
func NewPart1Supported() *Part1Supported
NewPart1Supported creates a new Part1Supported.
func (*Part1Supported) SetValue ¶
func (cmd *Part1Supported) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type Part2Supported ¶
type Part2Supported struct {
BaseCommand
UIntCommand
}
Part2Supported represents a command that checks the supported PIDs 21 to 40.
func NewPart2Supported ¶
func NewPart2Supported() *Part2Supported
NewPart2Supported creates a new Part2Supported with the right parameters.
func (*Part2Supported) SetValue ¶
func (cmd *Part2Supported) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type Part3Supported ¶
type Part3Supported struct {
BaseCommand
UIntCommand
}
Part3Supported represents a command that checks the supported PIDs 41 to 60.
func NewPart3Supported ¶
func NewPart3Supported() *Part3Supported
NewPart3Supported creates a new Part3Supported with the right parameters.
func (*Part3Supported) SetValue ¶
func (cmd *Part3Supported) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type Part4Supported ¶
type Part4Supported struct {
BaseCommand
UIntCommand
}
Part4Supported represents a command that checks the supported PIDs 61 to 80.
func NewPart4Supported ¶
func NewPart4Supported() *Part4Supported
NewPart4Supported creates a new Part4Supported with the right parameters.
func (*Part4Supported) SetValue ¶
func (cmd *Part4Supported) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type Part5Supported ¶
type Part5Supported struct {
BaseCommand
UIntCommand
}
Part5Supported represents a command that checks the supported PIDs 81 to A0.
func NewPart5Supported ¶
func NewPart5Supported() *Part5Supported
NewPart5Supported creates a new Part5Supported with the right parameters..
func (*Part5Supported) SetValue ¶
func (cmd *Part5Supported) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type RawDevice ¶
RawDevice represent the low level device, which can either be the real implementation or a mock implementation used for testing.
type RawResult ¶
type RawResult interface {
Failed() bool
GetError() error
GetOutputs() []string
FormatOverview() string
}
RawResult represents the raw text output of running a raw command, including information used in debugging to show what input caused what error, how long the command took, etc.
type RealDevice ¶
type RealDevice struct {
// contains filtered or unexported fields
}
RealDevice represent the low level serial connection.
func NewRealDevice ¶
func NewRealDevice(devicePath string) (*RealDevice, error)
NewRealDevice creates a new low-level ELM327 device manager by connecting to the device at given path.
After a connection has been established the device is reset, and a minimum of 800 ms blocking wait will occur. This makes sure the device does not have any custom settings that could make this library handle the device incorrectly.
func (*RealDevice) Reset ¶
func (dev *RealDevice) Reset() error
Reset restarts the device, resets all the settings to factory defaults and makes sure it actually is a ELM327 device we are talking to.
In case this doesn't work, you should turn off/on the device.
func (*RealDevice) RunCommand ¶
func (dev *RealDevice) RunCommand(command string) RawResult
RunCommand runs the given AT/OBD command by sending it to the device and waiting for the output. There are no restrictions on what commands you can run with this function, so be careful.
WARNING: Do not turn off echoing, because the underlying write function relies on echo being on so that it can compare the input command and the echo from the device.
For more information about AT/OBD commands, see: https://en.wikipedia.org/wiki/Hayes_command_set https://en.wikipedia.org/wiki/OBD-II_PIDs
type RealResult ¶
type RealResult struct {
// contains filtered or unexported fields
}
RealResult represents the raw text output of running a raw command, including information used in debugging to show what input caused what error, how long the command took, etc.
func (*RealResult) Failed ¶
func (res *RealResult) Failed() bool
Failed checks if the result is successful or not
func (*RealResult) FormatOverview ¶
func (res *RealResult) FormatOverview() string
FormatOverview formats a result as an overview of what command was run and how long it took.
func (*RealResult) GetError ¶
func (res *RealResult) GetError() error
GetError returns the results current error
func (*RealResult) GetOutputs ¶
func (res *RealResult) GetOutputs() []string
GetOutputs returns the outputs of the result
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result represents the results from running a command on the ELM327 device, encoded as a byte array. When you run a command on the ELM327 device the response is a space-separated string of hex bytes, which looks something like this:
41 0C 1A F8
The first 2 bytes are control bytes, while the rest of the bytes represent the actual result. So this data type contains an array of those bytes in binary.
This data type is only used internally to produce the processed value of the run OBDCommand, so the end user will never use this data type.
func NewResult ¶
NewResult constructrs a Result by taking care of parsing the hex bytes into binary representation.
func (*Result) PayloadAsByte ¶
PayloadAsByte is a helper for getting payload as byte.
func (*Result) PayloadAsUInt16 ¶
PayloadAsUInt16 is a helper for getting payload as uint16.
func (*Result) PayloadAsUInt32 ¶
PayloadAsUInt32 is a helper for getting payload as uint32.
func (*Result) PayloadAsUInt64 ¶
PayloadAsUInt64 is a helper for getting payload as uint64.
func (*Result) Validate ¶
func (res *Result) Validate(cmd OBDCommand) error
Validate checks that the result is for the given OBDCommand by: - Comparing the bytes received and the expected amount of bytes to receive - Comparing the received mode ID and the expected mode ID - Comparing the received parameter ID and the expected parameter ID
type RuntimeSinceStart ¶
type RuntimeSinceStart struct {
BaseCommand
UIntCommand
}
RuntimeSinceStart represents a command that checks the run time since engine start.
Min: 0 Max: 65535
func NewRuntimeSinceStart ¶
func NewRuntimeSinceStart() *RuntimeSinceStart
NewRuntimeSinceStart creates a new RuntimeSinceStart with the right parameters.
func (*RuntimeSinceStart) SetValue ¶
func (cmd *RuntimeSinceStart) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.
type ShortFuelTrim1 ¶
type ShortFuelTrim1 struct {
// contains filtered or unexported fields
}
ShortFuelTrim1 represents a command that checks the short term fuel trim for bank 1.
func NewShortFuelTrim1 ¶
func NewShortFuelTrim1() *ShortFuelTrim1
NewShortFuelTrim1 creates a new ShortFuelTrim1 with the right parameters.
type ShortFuelTrim2 ¶
type ShortFuelTrim2 struct {
// contains filtered or unexported fields
}
ShortFuelTrim2 represents a command that checks the short term fuel trim for bank 2.
func NewShortFuelTrim2 ¶
func NewShortFuelTrim2() *ShortFuelTrim2
NewShortFuelTrim2 creates a new ShortFuelTrim2 with the right parameters.
type SupportedCommands ¶
type SupportedCommands struct {
// contains filtered or unexported fields
}
SupportedCommands represents the lookup table for which commands (PID 1 to PID 160) that are supported by the car connected to the ELM327 device.
func (*SupportedCommands) FilterSupported ¶
func (sc *SupportedCommands) FilterSupported(commands []OBDCommand) []OBDCommand
FilterSupported filters out the OBDCommands that are supported.
func (*SupportedCommands) IsSupported ¶
func (sc *SupportedCommands) IsSupported(cmd OBDCommand) bool
IsSupported checks if the given OBDCommand is supported.
It does this by comparing the PID of the OBDCommand against the lookup table.
type ThrottlePosition ¶
type ThrottlePosition struct {
BaseCommand
FloatCommand
}
ThrottlePosition represents a command that checks the throttle position in percentage.
Min: 0.0 Max: 100.0
func NewThrottlePosition ¶
func NewThrottlePosition() *ThrottlePosition
NewThrottlePosition creates a new ThrottlePosition with the right parameters.
func (*ThrottlePosition) SetValue ¶
func (cmd *ThrottlePosition) SetValue(result *Result) error
SetValue processes the byte array value into the right float value.
type TimingAdvance ¶
type TimingAdvance struct {
BaseCommand
FloatCommand
}
TimingAdvance represents a command that checks the timing advance in degrees before TDC.
Min: -64 Max: 63.5
For more info about TDC: https://en.wikipedia.org/wiki/Dead_centre_(engineering)
func NewTimingAdvance ¶
func NewTimingAdvance() *TimingAdvance
NewTimingAdvance creates a new TimingAdvance with the right parameters.
func (*TimingAdvance) SetValue ¶
func (cmd *TimingAdvance) SetValue(result *Result) error
SetValue processes the byte array value into the right float value.
type UIntCommand ¶
type UIntCommand struct {
Value uint32
}
UIntCommand is just a shortcut for commands that retrieve unsigned integer values from the ELM327 device.
func (*UIntCommand) ValueAsLit ¶
func (cmd *UIntCommand) ValueAsLit() string
ValueAsLit retrieves the value as a literal representation.
type VehicleSpeed ¶
type VehicleSpeed struct {
BaseCommand
UIntCommand
}
VehicleSpeed represents a command that checks the vehicle speed in km/h.
Min: 0 Max: 255
func NewVehicleSpeed ¶
func NewVehicleSpeed() *VehicleSpeed
NewVehicleSpeed creates a new VehicleSpeed with the right parameters
func (*VehicleSpeed) SetValue ¶
func (cmd *VehicleSpeed) SetValue(result *Result) error
SetValue processes the byte array value into the right unsigned integer value.