help with using byte array

so i am reading in a array of 4 variables, the first and last are constant variables to be tested and the 2nd and 3rd are to be used in a motor function., my test function is not working and, the setmotor is somehow changing the constant variables

 if(aSerial.available()){
     aSerial.readBytes(a, 4 );


Serial.print("0: "); Serial.print(a[0]); Serial.print("  ");
Serial.print("1: "); Serial.print(a[1]); Serial.print("  ");
Serial.print("2: "); Serial.print(a[2]); Serial.print("  ");
Serial.print("3: "); Serial.print(a[3]); Serial.print("  ");
Serial.println(" ");

delay (600);

     if(test) { 
       setMotor(a[1], a[2]); //this is causing issues
       Serial.print("succes");
     }
     else {
      Serial.print("Fail");
     }
   }
  
  delay(1);
  
}

bool test() { //this isnt working
  if(a[0] == 255 & b[3] == 254 & a[1] < 239 & a[2] < 239) return true;
  else return false;
}

these are my results a0 and a3 should never change which is i believe is due to setmotor function

results

succes0: 198  1: 125  2: 125  3: 254   
succes0: 198  1: 125  2: 23  3: 254   
succes0: 198  1: 125  2: 53  3: 254   
succes0: 25  1: 125  2: 81  3: 254   
succes0: 198  1: 125  2: 99  3: 254   
succes0: 198  1: 125  2: 93  3: 254   
succes0: 25  1: 145  2: 83  3: 254   
succes0: 25  1: 160  2: 18  3: 254   
succes0: 198  1: 125  2: 125  3: 254   
succes0: 198  1: 19  2: 125  3: 254   
succes0: 25  1: 18  2: 154  3: 254   
succes0: 198  1: 125  2: 144  3: 254   
succes0: 255  1: 198  2: 125  3: 125   
succes0: 254  1: 25  2: 125  3: 25

i've spent hours and i cant figure out whats wrong

i've spent hours

I don't intend spending hours looking at your snippet.

 if(a[0] == 255 & b[3] == 254 & a[1] < 239 & a[2] < 239) return true;

You need && instead of &

cattledog:

 if(a[0] == 255 & b[3] == 254 & a[1] < 239 & a[2] < 239) return true;

You need && instead of &
&& - Arduino Reference

The overall result should be the same.

cattledog:

 if(a[0] == 255 & b[3] == 254 & a[1] < 239 & a[2] < 239) return true;

You need && instead of &
&& - Arduino Reference

i've treid that, it didn't change anything every array is still succesful,

i think one of my issue may be that im not buffering the serial read data properly, but i dont know how to do that, this is the first time ive used bluetooth to send data

ive used bluetooth to send data

You've got five minutes between posts.
Keep dribbling out details at this rate, and you could have an answer by March.

sorry that was my bad,

so i'm sending the array of 4 bytes via bluetooth, the 1st and last are are constant and middle are the important values as they will be driving the motor,

im trying to test that the array is correct by checking the the first and last values incase for some reason the array comes through incorrect nothing happens, the bool function is letting any array through, i don't know whats missing from the function or if its a problem with calling it in the loop.

  if(test) { What is that line doing?
Think carefully.

(Still can't see your code BTW)

nevermind, i solved it

AWOL:

  if(test) {

What is that line doing?
Think carefully.

(Still can't see your code BTW)

yeah yeah

 if(test()) {

could of just told me save me a few hours, but thanks, i've been struggling with that for the worse part of 7 hours

oniudra123:
yeah yeah

 if(test()) {

could of just told me save me a few hours, but thanks, i've been struggling with that for the worse part of 7 hours

You could have posted all your code.
For all I could have known, "test" could have been a boolean variable in scope in the first part of the incomplete code, and the "if (test)" could have been perfectly OK, both syntactically and semantically - you missed the opportunity presented by reply #1 entirely.
Your problem could have been elsewhere.