C
CMCTS
Guest
I am having a strange issue that i cannot figure out.
I need to take a int and convert it to hex.
i have tried it a few ways and although the hex string appears identical the result on remote end is different.
//This works perfect assuming a code is 1234567
string test = "\x02\x87\xD6\x12i\x0D"; //working code ID 1234567
Console.WriteLine("Test String: {0}", test);
string result2 = userMangementService.SendData(test);
//How remote class sees the string
[02h][87h][D6h][12h]i
//This does not work
int code = int.Parse(Rx); //assuming code input is 1234567
string lsb = (code & 0xFF).ToString("X2");
string mb = ((code >> 8) & 0xFF).ToString("X2");
string msb = ((code >> 16) & 0xFF).ToString("X2");
string sendCommand2 = string.Format(@"\x02\x{0}\x{1}\x{2}i\x0D", lsb , mb , msb);
string result2 = userMangementService.SendData(sendCommand2);
//How remote class sees the string
\x02\x87\xD6\x12i\x0D
the input code could change but i tried to use 1234567 as a generic test so i could compare the strings.
Any help would be great.
Continue reading...
I need to take a int and convert it to hex.
i have tried it a few ways and although the hex string appears identical the result on remote end is different.
//This works perfect assuming a code is 1234567
string test = "\x02\x87\xD6\x12i\x0D"; //working code ID 1234567
Console.WriteLine("Test String: {0}", test);
string result2 = userMangementService.SendData(test);
//How remote class sees the string
[02h][87h][D6h][12h]i
//This does not work
int code = int.Parse(Rx); //assuming code input is 1234567
string lsb = (code & 0xFF).ToString("X2");
string mb = ((code >> 8) & 0xFF).ToString("X2");
string msb = ((code >> 16) & 0xFF).ToString("X2");
string sendCommand2 = string.Format(@"\x02\x{0}\x{1}\x{2}i\x0D", lsb , mb , msb);
string result2 = userMangementService.SendData(sendCommand2);
//How remote class sees the string
\x02\x87\xD6\x12i\x0D
the input code could change but i tried to use 1234567 as a generic test so i could compare the strings.
Any help would be great.
Continue reading...