Serial.print(Serial.read(),HEX) gives an ascii output

Hello,
I’m trying to have a basic communication between 2 Xbee’s. a sensor connected to the router Xbee communication wireless to the coordinator Xbee which is connected to an arduino uno. I’m trying to print the data received using this code.

void setup()
{ Serial.begin(9600);
}

void loop()
{ if (Serial.available()>21)
{ for(int i=0;i<22;i++)
{ Serial.print(Serial.read(),HEX);
Serial.print(" , ");
}
Serial.println();
}
}

But my serial monitor output is in ascii. How can I get it in HEX.

Post some example input you type in serial monitor and the output you see. Also post the output you wanted to get.

Please use code tags when you post a sketch, or when you post output of serial monitor.

what do you expect from printing byte formatted as hex?
every print function gives ascii output. write functions send bytes.

How could it send in hex and not be ascii? If you want to send raw data it would have to be binary data.