def h2i(hexstr):
    """
    Convert hex-formated string to its corresponding value.
    """
    if hexstr:
        assert(type(hexstr) == str)
        hexstr = hexstr.replace(' ', '') # remove any spaces in the hex string
        return int(hexstr, 16)