so I am trying to send some bytes with hex values to setup my microcontroller on the other side of Serial Port. The thing is I am not quite sure how to properly do it and in what format to send them. For example I need to send two bytes and their hex values are 57 and B0. When I try to send it as a char array and I read it back I always get the ASCII Hex values of those characters like 53 and then 55 for the value 57. So I wanted to format the hex value as a byte and send both of them at the same time from byte array but I am not getting anything when reading the response. After formatting it to byte, the MessageBox is showing it's decimal value and I don't know if it supposed to be like that. I am providing my code below.
Info_Byte_Dec += Protocol_Set + Protocol_Unit + Protocol_Write + Protocol_Settings; //stores decimal value
Data_Byte_Dec = Mode * Protocol_Mode_Offset + ODR * Protocol_ODR_Offset + Scale; //stores decimal value
Info_Byte_Hex = Info_Byte_Dec.ToString("X"); //convert to hex value
Data_Byte_Hex = Data_Byte_Dec.ToString("X"); //convert to hex value
string Merged = $"{Info_Byte_Hex} {Data_Byte_Hex}";
MessageBox.Show("Merged1: " + Merged);
byte[] Mergedbytes = Merged.Split(' ').Select(s => Convert.ToByte(s, 16)).ToArray();
MessageBox.Show("Merged2: " + Mergedbytes[0] + Mergedbytes[1]);
port.Write(Mergedbytes, 0, 2);
I am not sure whether I should just send the decimal value 87, or I should format it to 57 hex value, or even to 0x57.
0x57. But the problem is when I try to send it that way, I am not getting the right values and I don't know why.