Quantex GmbH
Your region: Europe

PassThruSetProgrammingVoltage v4.04 v5.0

Setting the programming voltage

Last updated:

Description

Sets the programming voltage on the specified pin of the J1962 (OBD-II) connector. It is used to program ECUs that require an elevated voltage on a particular pin during the reprogramming procedure.

long PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage)
Important: This function is not supported by the ScanDoc adapter. The call always returns ERR_NOT_SUPPORTED.

Parameters

Return error codes

Code Description Possible causes and solutions
STATUS_NOERROR Function completed successfully
ERR_DEVICE_NOT_CONNECTED No connection to the adapter
  • The adapter is turned off or out of range
  • Solution: check the adapter power and the network/BLE connection
ERR_NOT_SUPPORTED The function is not supported
  • The ScanDoc adapter does not provide a programming voltage output
  • Solution: use an adapter with hardware support for programming voltage
ERR_INVALID_DEVICE_ID Invalid device identifier
  • DeviceID was not obtained through PassThruOpen, or the device has been closed
  • Solution: make sure PassThruOpen completed successfully and the device is not closed
ERR_PIN_INVALID Invalid pin number
  • An unsupported pin number was specified, or the pin is already in use
  • Solution: use valid pin numbers (0, 6, 11-15)
ERR_FAILED Undefined error
  • Internal error in the library or adapter
  • Solution: call PassThruGetLastError() to get a description

Examples

C/C++

#include "j2534_dll.hpp"

unsigned long DeviceID;  // Obtained from PassThruOpen
long ret;

// Set 12V on pin 15
ret = PassThruSetProgrammingVoltage(DeviceID, 15, 12000);
if (ret == STATUS_NOERROR)
{
    printf("Programming voltage set: 12V on pin 15\n");
}
else if (ret == ERR_NOT_SUPPORTED)
{
    printf("The adapter does not support programming voltage\n");
}
else
{
    char error[256];
    PassThruGetLastError(error);
    printf("Error: %s\n", error);
}

// Turn off the programming voltage
ret = PassThruSetProgrammingVoltage(DeviceID, 15, VOLTAGE_OFF);

Kotlin (Android)

// deviceID obtained earlier from ptOpen
val result = j2534.ptSetProgrammingVoltage(deviceID, pin = 15, voltage = 12000u)
when (result.status) {
    STATUS_NOERROR -> Log.i("J2534", "Programming voltage set")
    ERR_NOT_SUPPORTED -> Log.w("J2534", "The function is not supported by the adapter")
    else -> Log.e("J2534", "Error: ${result.errorDescription}")
}

// Turn off the voltage
j2534.ptSetProgrammingVoltage(deviceID, pin = 15, voltage = VOLTAGE_OFF)

Python

from ctypes import *

VOLTAGE_OFF = 0xFFFFFFFF
SHORT_TO_GROUND = 0xFFFFFFFE

# Set 12V on pin 15
ret = j2534.PassThruSetProgrammingVoltage(device_id, 15, 12000)
if ret == 0:  # STATUS_NOERROR
    print("Programming voltage set: 12V")
elif ret == 0x01:  # ERR_NOT_SUPPORTED
    print("The adapter does not support programming voltage")
else:
    error = create_string_buffer(256)
    j2534.PassThruGetLastError(error)
    print(f"Error: {error.value.decode()}")

# Turn off the voltage
j2534.PassThruSetProgrammingVoltage(device_id, 15, VOLTAGE_OFF)

C#

const uint VOLTAGE_OFF = 0xFFFFFFFF;
const uint SHORT_TO_GROUND = 0xFFFFFFFE;

// Set 12V on pin 15
int ret = J2534.PassThruSetProgrammingVoltage(deviceId, 15, 12000);
if (ret == 0)
{
    Console.WriteLine("Programming voltage set: 12V");
}
else if (ret == 0x01) // ERR_NOT_SUPPORTED
{
    Console.WriteLine("The adapter does not support programming voltage");
}
else
{
    var error = new StringBuilder(256);
    J2534.PassThruGetLastError(error);
    Console.WriteLine($"Error: {error}");
}

// Turn off the voltage
J2534.PassThruSetProgrammingVoltage(deviceId, 15, VOLTAGE_OFF);