/* return string representation of fault code */ public static String GetFaultString(long fault) { if (fault > 0L) { StringBuffer sb = new StringBuffer(); if ((fault & TYPE_MASK) == TYPE_J1708) { // SID: "128/s123/1" // PID: "128/123/1" boolean active = DTOBDFault.DecodeActive(fault); int mid = DTOBDFault.DecodeSystem(fault); int fmi = DTOBDFault.DecodeFMI(fault); if (!active) { sb.append("["); } sb.append(mid); // MID sb.append("/"); if (DTOBDFault.IsJ1708_SID(fault)) { int sid = DTOBDFault.DecodePidSid(fault); sb.append("s").append(sid); // SID "128/s123/1" } else { int pid = DTOBDFault.DecodePidSid(fault); sb.append(pid); // PID "128/123/1" } sb.append("/"); sb.append(fmi); // FMI if (!active) { sb.append("]"); } return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_J1939) { // SPN: "128/1" boolean active = DTOBDFault.DecodeActive(fault); int spn = DTOBDFault.DecodeSystem(fault); int fmi = DTOBDFault.DecodeFMI(fault); sb.append(spn); // SPN sb.append("/"); sb.append(fmi); // FMI return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_OBDII) { // DTC: "P0071" [was "024C"] boolean active = DTOBDFault.DecodeActive(fault); int sysChar = DTOBDFault.DecodeSystem(fault); // System: powertrain int subSys = DTOBDFault.DecodeSPID(fault); // Mfg/Subsystem/Problem if (Character.isLetter((char) sysChar)) { sb.append((char) sysChar); } else { sb.append("U"); } if ((subSys & 0x8000) != 0) { sb.append("1"); } else { sb.append("0"); } String subSysStr = String.valueOf(1000 + ((subSys & 0xFFF) % 1000)); sb.append(subSysStr.substring(1)); return sb.toString(); } else { // unrecognized } } return ""; }
public static String GetFaultDescription(long fault, Locale locale) { if (fault != 0L) { String fmt = "000"; StringBuffer sb = new StringBuffer(); if ((fault & TYPE_MASK) == TYPE_J1708) { int mid = DTOBDFault.DecodeSystem(fault); // MID boolean isSid = DTOBDFault.IsJ1708_SID(fault); int pidSid = DTOBDFault.DecodePidSid(fault); // PID|SID "128/[s]123/1" int fmi = DTOBDFault.DecodeFMI(fault); // FMI Properties p = (j1587DescProvider != null) ? j1587DescProvider.getJ1587Descriptions(fault) : new Properties(); // MID sb.append( NAME_MID + "(" + StringTools.format(mid, fmt) + ") " + p.getProperty(NAME_MID_DESC, "") + "\n"); // PID/SID if (isSid) { sb.append( NAME_SID + "(" + StringTools.format(pidSid, fmt) + ") " + p.getProperty(NAME_SID_DESC, "") + "\n"); } else { sb.append( NAME_PID + "(" + StringTools.format(pidSid, fmt) + ") " + p.getProperty(NAME_PID_DESC, "") + "\n"); } // FMI sb.append( NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI_DESC, "")); return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_J1939) { int spn = DTOBDFault.DecodeSystem(fault); // SPN int fmi = DTOBDFault.DecodeFMI(fault); // FMI Properties p = new Properties(); // SPN sb.append( NAME_SPN + "(" + StringTools.format(spn, fmt) + ") " + p.getProperty(NAME_SPN, "") + "\n"); // FMI sb.append( NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI, "")); return sb.toString(); } else if ((fault & TYPE_MASK) == TYPE_OBDII) { String dtc = DTOBDFault.GetFaultString(fault); // DTC Properties p = new Properties(); // DTC sb.append(NAME_DTC + "(" + dtc + ") " + p.getProperty(NAME_DTC, "")); return sb.toString(); } } return ""; }