I've been researching this everywhere and all the LRC implementation seems to not giving me the right answer. After spending few days on it, I decided to put my code here to see if anyone else can spot the problem.
Here's the code (C#)
//Input Data = "31303030315E315E31303030325E315E31303030375E39395E31303032325E36353631335E"
//LRC Answer = "30"
private static string LRC(string Data)
{
int checksum = 0;
foreach (char c in GetStringFromHex(Data))
{
checksum ^= Convert.ToByte(c);
}
string hex = checksum.ToString("X2");
Console.WriteLine("Calculated LRC = " + hex);
return hex;
}
//Supporting Function used in LRC function
private static string GetStringFromHex(string s)
{