def METHOD_NAME(self, port_num, lpmode):
    # Check for invalid port_num
    if port_num < self.port_start or port_num > self.port_end:
        return False
    try:
        reg_file = open("/sys/class/cpld-qsfp28/port-"+str(port_num+1)+"/lpmode", "r+")
    except IOError as e:
        print("Error: unable to open file: %s" % str(e))
        return False
    reg_value = int(reg_file.readline().rstrip())
    # LPMode is active high; set or clear the bit accordingly
    if lpmode is True:
        reg_value = 1
    else:
        reg_value = 0
    reg_file.write(hex(reg_value))
    reg_file.close()
    return True