Dreaded Y with two dots over it

So I got my slave to send “yes” to my master. If I set my master to request only three bytes everything is smooth- but if I request the max- I believe six bytes even with this code it won’t work
"

while(Wire.available()){
char c = Wire.read();
Serial.print(c);
}
Serial.println(", I can hear you");
delay(500);

even if I place a condition like while(0<Wire.available()) I still get those Y things. How can I avoid this in the future where I may not know how many bytes to request or if the slave sends less than what’s requested?

What a very apt user name. You've posted a snippet of a bigger code. Is the bigger code secret or something? When you get around to posting it, use code tags.

How can I avoid this in the future where I may not know how many bytes to request or if the slave sends less than what's requested?

The function that is called when the slave replies KNOWS how much data the slave replied with. Trying to read more than that is not too bright. Claiming to not know how much data is available to read isn't, either.

AWOL:
What a very apt user name.
You’ve posted a snippet of a bigger code.
Is the bigger code secret or something?
When you get around to posting it, use code tags.

AWOL:
What a very apt user name.
You’ve posted a snippet of a bigger code.
Is the bigger code secret or something?
When you get around to posting it, use code tags.

My apologies. I didn’t want to post the code for reader’s convenience but it’s probably for the best and thankfully no too long.

//  Master writes to Slave1 (1) to employ LCD

#include <Wire.h>

int m=1; // Button on Master
int lcd=0; // LCD (slave)
void setup(){
  Serial.begin(9600);
  Wire.begin(); // Address optional for Master
}

void loop(){
  
  Wire.beginTransmission(1); 
  Wire.write(m); // State of Button
  Wire.endTransmission();
  delay(500);
  
  Wire.requestFrom(1,3); // Request 3 bytes from Slave1
   Serial.print(m);
  while(Wire.available()){
    char c = Wire.read();
    Serial.print(c);
  }
  Serial.println(", I can hear you");
  delay(500);
  
  
}

So this is the code for my Maser device. For completeness I’ll include the slave.

// slave1 recieves signal from Master to output lcd

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

int t=0;
int m=0;

void setup(){
  Serial.begin(9600);
  Wire.begin(1); // Address of slave is 1
  Wire.onRequest(requestEvent); // Send yes
  Wire.onReceive(receiveEvent); // Get m=1 
  lcd.begin();
  lcd.backlight();
}

void loop(){
  if(m==2){
       lcd.setCursor(0, 0);
 	lcd.print("it works ");
  }
  delay(500);
  
}

void requestEvent(){
  Wire.write("Yes");
}

void receiveEvent(int howMany){
  
  while(Wire.available()){
   t = Wire.read();
    Serial.print(t);
  }
  
      m=2;
      
}

The "funny y" or ÿ is ascii character 255 or more appropriately -1.

Can you post the serial monitor result of your tests?

The "funny y" or ÿ is ascii character 255 or more appropriately -1.

Maybe it is the fact that the hex value is 0xFF (all bits = 1) that is significant.

Don