def decrypt_dtc_code(code):
 dtc = []
 current = code
 for i in range(0, 3):
  if (len(current) < 4):
   raise ('Tried to decode bad DTC: %s' % code)
  tc = obd_sensors.hex_to_int(current[0])
  tc = (tc >> 2)
  if (tc == 0):
   type = 'P'
  elif (tc == 1):
   type = 'C'
  elif (tc == 2):
   type = 'B'
  elif (tc == 3):
   type = 'U'
  else:
   raise tc
  dig1 = str((obd_sensors.hex_to_int(current[0]) & 3))
  dig2 = str(obd_sensors.hex_to_int(current[1]))
  dig3 = str(obd_sensors.hex_to_int(current[2]))
  dig4 = str(obd_sensors.hex_to_int(current[3]))
  dtc.append(((((type + dig1) + dig2) + dig3) + dig4))
  current = current[4:]
 return dtc

def decrypt_dtc_code ( code ) : dtc = [ ] current = code for i in range ( 0 , 3 ) : if ( len ( current ) < 4 ) : raise ( 'Tried to decode bad DTC: %s' % code ) tc = obd_sensors . hex_to_int ( current [ 0 ] ) tc = ( tc >> 2 ) if ( tc == 0 ) : type = 'P' elif ( tc == 1 ) : type = 'C' elif ( tc == 2 ) : type = 'B' elif ( tc == 3 ) : type = 'U' else : raise tc dig1 = str ( ( obd_sensors . hex_to_int ( current [ 0 ] ) & 3 ) ) dig2 = str ( obd_sensors . hex_to_int ( current [ 1 ] ) ) dig3 = str ( obd_sensors . hex_to_int ( current [ 2 ] ) ) dig4 = str ( obd_sensors . hex_to_int ( current [ 3 ] ) ) dtc . append ( ( ( ( ( type + dig1 ) + dig2 ) + dig3 ) + dig4 ) ) current = current [ 4 : ] return dtc
returns the 5-digit dtc code from hex encoding .