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:
        lpmode_val_device_file = self.BASE_VAL_PATH.format(
            port_num + self.LP_GPIO_BASE)
        val_file = open(lpmode_val_device_file, "w")
    except IOError as e:
        print("Error: unable to open file: %s" % str(e))
        return False
    val_file.write("1" if lpmode is True else "0")
    val_file.close()
    return True