Skip to content

Instantly share code, notes, and snippets.

@cjdell
Last active February 23, 2024 01:17
Show Gist options
  • Save cjdell/20e25f74092b0d39c32be8292e5be28a to your computer and use it in GitHub Desktop.
Save cjdell/20e25f74092b0d39c32be8292e5be28a to your computer and use it in GitHub Desktop.
Chevy Volt / Opel Ampera SHVCS DTC Clearing
/* This is an experimental script which I used to successfully clear the "Service High Voltage Charging System" message which can occur due to a loss of isolation.
* Previously I had to pay frequently to access the expensive SPS programming system to clear this code whilst attempting to resolve the underlying cause.
* This script was generated by a tool I developed to analyse J2534 log files.
* This could work for other cars but I can't comment on success. Please do not run this unless you understand the consequences!
* I intend to convert to a version that will work with ELM327 once I learn how these work.
* The program requires the J2534-Sharp library as a dependency.
* https://github.com/BrianHumlicek/J2534-Sharp
*/
using System;
using System.Linq;
using System.Text;
using System.Threading;
using SAE.J2534;
namespace J5234Examples
{
class Program
{
static void Main(string[] args)
{
Device device1;
Channel channel1;
// Change this line is using something different to the VXDIAG VCX Nano!
string DllFileName = APIFactory.GetAPIinfo().First(api => api.Name.Contains("VXDIAG")).Filename;
API API = APIFactory.GetAPI(DllFileName);
Console.WriteLine("PTOpen");
device1 = API.GetDevice();
Console.WriteLine("PTReadVersion");
Console.WriteLine(device1.FirmwareVersion);
Console.WriteLine("PTConnect");
// 6 = ISO15765
channel1 = device1.GetChannel((Protocol)6, (Baud)500000, 0);
Console.WriteLine("PTIoctl");
// 32768 = CAN_MIXED_FORMAT
channel1.SetConfig(new[] { new SConfig((Parameter)32768, 1) });
Console.WriteLine("Pause");
Console.WriteLine("Sleep(2000)\n");
Thread.Sleep(2000);
Console.WriteLine("PTWriteMsgs");
Console.WriteLine(">>> 00 00 07 e4 27 01");
// 64 = ISO15765_FRAME_PAD
channel1.SendMessages(new[] { new Message(new byte[] { 0x00, 0x00, 0x07, 0xe4, 0x27, 0x01 }, (TxFlag)64) });
Thread.Sleep(2000);
Console.WriteLine("PTWriteMsgs");
Console.WriteLine(">>> 00 00 07 e4 27 02 75 6c");
// 64 = ISO15765_FRAME_PAD
channel1.SendMessages(new[] { new Message(new byte[] { 0x00, 0x00, 0x07, 0xe4, 0x27, 0x02, 0x75, 0x6c }, (TxFlag)64) });
Thread.Sleep(2000);
Console.WriteLine("PTWriteMsgs");
Console.WriteLine(">>> 00 00 07 e4 ae fc 02 00 00 46 00");
// 64 = ISO15765_FRAME_PAD
channel1.SendMessages(new[] { new Message(new byte[] { 0x00, 0x00, 0x07, 0xe4, 0xae, 0xfc, 0x02, 0x00, 0x00, 0x46, 0x00 }, (TxFlag)64) });
Thread.Sleep(2000);
Console.WriteLine("PTWriteMsgs");
Console.WriteLine(">>> 00 00 07 e4 ae fc 02 00 00 49 00");
// 64 = ISO15765_FRAME_PAD
channel1.SendMessages(new[] { new Message(new byte[] { 0x00, 0x00, 0x07, 0xe4, 0xae, 0xfc, 0x02, 0x00, 0x00, 0x49, 0x00 }, (TxFlag)64) });
Thread.Sleep(2000);
Console.WriteLine("PTDisconnect");
channel1.Dispose();
Console.WriteLine("PTClose");
device1.Dispose();
}
}
}
@clutchies
Copy link

Which tool do I need to input this code?

@torentino
Copy link

Hello cjdell,

I am also very much interested in your program, can you tell more?
regards

@porteusconf
Copy link

porteusconf commented Jan 20, 2024

Seems to be in c-sharp (aka c#) language as the filename ends in .cs extension. Perhaps meant to be developed with visual studio on windows. Not sure about the J2534 library but might be something like this: https://github.com/BrianHumlicek/J2534-Sharp. I need to clear those codes so I may experiment with this and post back here. Actually these are just wild guesses... I could be completely wrong about any/all of the above ;-) In past I've used the pirated GM dts2 software provided by the makers of vx-diag obd2 dongle, but that software is flagged as having trojan viruses by windows. This gist is talking to a vx-diag dongle (in line 25) so I am guessing the purpose was to have a way to clear the codes without having to use the pirated software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment