def METHOD_NAME(self, port_num, lpmode):
    # Check for invalid port_num
    if port_num < self.port_start or port_num > self.port_end - 1:
        return False
    try:
        reg_file = open("/sys/devices/platform/delta-ag9032v2a-swpld1.0/qsfp_lpmode", "r+")
    except IOError as e:
        print("Error: unable to open file: %s" % str(e))
        return False
    content = reg_file.readline().rstrip()
    # content is a string containing the hex representation of the register
    reg_value = int(content, 16)
    # Mask off the bit corresponding to our port
    mask = (1 << (self.port_end - port_num) - 1)
    # LPMode is active high; set or clear the bit accordingly
    if lpmode is True:
        reg_value = reg_value | mask
    else:
        reg_value = reg_value & ~mask
    # Convert our register value back to a hex string and write back
    content = hex(reg_value)
    reg_file.seek(0)
    reg_file.write(content)
    reg_file.close()
    return True