def structure_to_dict(structure):
    """Convert a ctypes.Structure to a dict"""
    out = {}
    for key, _ in structure._fields_:  # pylint: disable=protected-access
        out[key] = getattr(structure, key)
    return out