Can't make bool func work correct

Hello guys. I am writing a serial console on Arduino. Here is the my code

#define ledctl 13

String BoardModel = " UNO";
String Owner = " Owner";
String AsciiArt = " duino ~>";
String OwnerPasswd = "passwd";
bool ledstatus = 0;
bool asRoot = false;

void setup() {
pinMode(ledctl, OUTPUT); 

Serial.println("Consoleduino v.1.3.1");
Serial.println("(c) Ilya Bilyk 2018");

void loop() {
//Serial.println("duino ~>");

if(Serial.available() > 0) {
  String query = Serial.readString();
  if(query == "help"){helpmsg();}
  else if(query == "fetch"){fetchmsg();}
  else if(query == "pinctl" || query == "pinctl 1" || query == "pinctl 0"){f_pinctl(f_pinctlCheck(query));}
  else if(query == "hollywood"){hollywood();}
  else if(query == "su"){asRoot = permissionCheck();}
  else if(query == "exit"){exitRoot(query);}
  Serial.println(query+": no such command; try help");}


void helpmsg(){
  Serial.println("Consoleduino help");
  Serial.println("help    print this msg");
  Serial.println("fetch   show system info");
  Serial.println("pinctl (1/2)   control led on pin 13; usage pinctl 1 or pinctl 0 ");
  Serial.println("For feedback use Telegram(@dwarq7), Instagram(@ilya_quicksort) or;");
void fetchmsg(){
  Serial.println("Board:" + BoardModel);
  Serial.println("Owner:" + Owner);
void f_pinctl(bool status){
  ledstatus = status;
  digitalWrite(ledctl, ledstatus);
bool f_pinctlCheck(String fquery){
  if (fquery == "pinctl 1"){return true;}
  else if (fquery == "pinctl 0"){return false;}
  else if (fquery == "pinctl"){Serial.println("Not enough args; try help;"); 
void hollywood(){
  String hwq;
  Serial.println("You have found Hollywood!");
  while(true){if(Serial.available() > 0) {
    hwq = Serial.readString();
    if (hwq == "exit"){break;}

bool permissionCheck(){
  String passwdToCheck;
  bool accept;
    Serial.print("Password for"+Owner+": ");
    if(Serial.available() > 0){
    passwdToCheck = Serial.readString();
    accept = passwdCheck(passwdToCheck);
    if(accept == true) return true;
    else return false;

bool passwdCheck(String passwd) {
  if (passwd == OwnerPasswd) return true;
  else {Serial.println("wrong password");return false;}

void exitRoot(String fquery){
  if (asRoot == true && fquery == "exit"){asRoot == false;}

My code works incorrect:
when i write "su" to serial port it asks for passwd, i write passwd but it rolls me back with words unknown command; try help

The Arduino is much faster than you realize and Serial is much slower. Inside the password checker, you only check for Serial.available() once. Even if you typed "supasswd" the "p" of the password has not arrived by the time you start looking for it. You need to wait many milliseconds, which is like several days for an Arduino.

Imagine like there is 60 seconds for the person to type the password. For that 60 seconds you keep checking the serial input and processing characters as they arrive. If you get nothing, then back to the main menu. If you get something, see if it is a valid password.

You are doing the serial input in several places for different purposes. You must consolidate it into one single function that reads the serial input. Then, depending on what you are expecting, that input can be passed to the different functions that process the input in different ways. This means you must remember what "mode" you are in.

I also see a lot of use of the big-S String class. It is likely to cause memory problems in the future. If you can drop it now, you should do so.