Class: OBDIIMode

OBDIIMode

Provides methods for creating PIDs and properties for accessing PIDs.

PIDs are accessible as properties of this object, named after the PID.


Members


<readonly> mode :number

Gets the mode number.

Type:
  • number
Since:
  • 0.1 (WAT 1.1)

<readonly> standardMode :bool

Gets whether this mode is a standard mode or a proprietary mode. Proprietary modes are not treated differently by the plugin, this property is for use by the application.

Type:
  • bool
Since:
  • 0.1 (WAT 1.1)

Methods


createNumberPID(id, pid, numBytes, scale, offset, bigEndian, isSigned [, name])

Creates a new PID that interprets the PID bytes as a number. Numbers are written and read as integers, but using scale and offset, they can be converted to floating point.

If a name is specified, this PID will become accessible via the mode object.

NOTE: As with obdII.OBDIIPIDs#createMode, PIDs should be deleted with deletePID when no longer used to avoid memory leaks.

Parameters:
Name Type Argument Default Description
id number

The ID used to access the PID on the bus, usually the address of the ECU.

pid number

The PID number. Some PID numbers are defined as part of the OBD-II standard.

numBytes number

The number of bytes in the number. Supported sizes are 1, 2, 4, and 8.

scale number

The scale to use to convert to a float: value = (raw * scale) + offset.

offset number

The offset to apply when converting to a float.

bigEndian bool

True if the number is in big endian format, false for little endian.

isSigned bool

True if the number is a twos-compliment signed number.

name string <optional>
""

The name of the PID. If specified the PID will be accessible from the mode object.

Since:
  • 0.3 (WAT 1.3)
Returns:
Type
obdII.OBDIIPID

createRawPID(id, pid, numBytes [, name])

Creates a new PID that exposes the raw bytes. This is used when data cannot be represented using a string or number. The raw bytes will need to be interpreted by the application instead. The data type of the PID is Array..

If a name is specified, this PID will become accessible via the mode object.

NOTE: As with obdII.OBDIIPIDs#createMode, PIDs should be deleted with deletePID when no longer used to avoid memory leaks.

Parameters:
Name Type Argument Default Description
id number

The ID used to access the PID on the bus, usually the address of the ECU.

pid number

The PID number. Some PID numbers are defined as part of the OBD-II standard.

numBytes number

The number of bytes in the PID.

name string <optional>
""

The name of the PID. If specified the PID will be accessible from the mode object.

Since:
  • 0.3 (WAT 1.3)
Returns:
Type
obdII.OBDIIPID

createStringPID(id, pid, length [, name])

Creates a new PID that interprets the PID bytes as a string.

If a name is specified, this PID will become accessible via the mode object.

NOTE: As with obdII.OBDIIPIDs#createMode, PIDs should be deleted with deletePID when no longer used to avoid memory leaks.

Parameters:
Name Type Argument Default Description
id number

The ID used to access the PID on the bus, usually the address of the ECU.

pid number

The PID number. Some PID numbers are defined as part of the OBD-II standard.

length number

The maximum number of bytes in the string. Note that strings are NULL terminated, so if a NULL byte is encountered in the data, the length of the string will be less than this maximum length.

name string <optional>
""

The name of the PID. If specified the PID will be accessible from the mode object.

Since:
  • 0.3 (WAT 1.3)
Returns:
Type
obdII.OBDIIPID

deletePID(mode)

Deletes a PID that was created using a PID constructor. The PID must not be accessed after it has been deleted.

Parameters:
Name Type Description
mode obdII.OBDIIPID

PID to delete.

Since:
  • 0.3 (WAT 1.3)