Setting the programming voltage
Last updated:
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)
| Code | Description | Possible causes and solutions |
|---|---|---|
| STATUS_NOERROR | Function completed successfully | — |
| ERR_DEVICE_NOT_CONNECTED | No connection to the adapter |
|
| ERR_NOT_SUPPORTED | The function is not supported |
|
| ERR_INVALID_DEVICE_ID | Invalid device identifier |
|
| ERR_PIN_INVALID | Invalid pin number |
|
| ERR_FAILED | Undefined error |
|
#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);
// 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)
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)
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);