I am having trouble understanding Hexadecimal bytes. When a manual states Header ID in hex-ascii as 7Fh, that means 0111 1111 right? Which converts to 127 in decimal according to online hex-decimal converters.
string dataString;
//cout << dataString << endl;
//the output of dataString starts with "7F0304"
struct SENSOR_O
{
fLeader fixedLeader;
vLeader varLeader;
vel velocity;
pos position;
bTrack bottomTrack;
bool error;
std::string error_msg;
};
SENSOR_O datafields;
datafields = ParseData(dataString)
my class::SENSOR_O myclass::ParseData(const std::string &data)
{
const unsigned char *memblock;
ifstream::pos_type size;
ifstream test;
vector<double> dataSum;
int headerID = 125;
int startID = 0;
memblock = reinterpret_cast<const unsigned char *>(data.data());
cout << data[0] << data[1] << data[2] << data[3] << endl;
cout << "check value: "<< memblock[startID] << ", " << memblock[startID+1]<< endl;
cout << "double check value: " << double(memblock[startID]) << ", " << double(memblock[startID+1]) << endl;
cout << "7F should give me 127. Yes? Added total is: " << double(memblock[startID]) + double(memblock[startID+1]) << ends;
}
The output I see is
7F03
7, F
55, 70
7F should give me 127. Yes? Added total is: 125
What have I done wrong here?