I need to run mode 0x100 and send hex message
this is the mode100 function I have created (which is working )
public static byte Mode100(byte[] p)
{
byte lcs = 0;
foreach (byte b in p)
{
lcs += b;
}
return lcs;
}
this is what I'm trying to send
byte[] msg = { 0X06, 0XA2, 0XD2, 0X06, 0XD3, 0X11, 0XD4, 0X65, 0X6F };
var Mode100Dec = Mode100(msg);//value in int
string Mode100hex = Mode100Dec.ToString("X"); //value in hex 0-F
byte [] Mode100Byte = Encoding.Default.GetBytes(Mode100hex);//value in dec ascci of hex
var hexString = BitConverter.ToString(Mode100Byte); //value in hex of ascii
for this example the the Mode100 function return me 12(Dec) which is C(Hex)
but how do I convert it to byte[] so I can send 0x0C ?
because now it change me the "C" to 67 Dec \ 42 Hex which is wrong .....
I have look this post
How do you convert a byte array to a hexadecimal string, and vice versa?
but it didn't help me to get the answer I need