yes thats what i was thinking but the checksum is 2 bytes and the amount of bytes between STX and ETX is 1+6+6+6 = 19 witch is not divisible by 2.
so that means i am not understanding what they want me to do.
Edit:
it does not mater how i get it, i can post the code i have at the moment but it is really simple. i do not have a sample of the output, but if you really need it i can write some code to get it.
/*
??????????????????????????????????????????????????????????????
|STX|Status|Net Weight|Gross Weight|Peak Weight|ETX|Check|EOT|
??????????????????????????????????????????????????????????????
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
1 = Start of transmission, 1 Byte
2 = Status of scale, 1 Byte
3 = Net weight of the scale, 6 Bytes
4 = Gross weight of scale, 6 Bytes
5 = Peak weight of scale, 6 bits
6 = End of text, 1 byte
7 = Checksum is the ASCII encoding of the two hexadecimal digits, 2 byte
8 = End of transmission, 1byte
Checksum = 2 ASCII control characters calculated considering the characters between STX and ETX excluded.
The control value is obtained by executing the operation of XOR (or exclusive) of the 8-bit ASCII codes of
the characters considered. The result is a character that is expressed in hexadecimal with 2 digits that can
take values from "O" to "9" and "A" to "F".
*/
enum ScaleStatus
{
STABLE = 'S', // Stable weight
MOVING = 'M', // Moving weight
OVER = 'O', // Over capacity
UNKOWN = 'E' // Can not be detected
};
const byte STX = 0; //1
const byte Status = 1; //1
const byte Net = 2; //6
const byte Gross = 8; //6
const byte Peak = 14; //6
const byte ETX = 20; //1
const byte Checksum = 21; //2
const byte EOT = 23; //1
void ProcessTimeString(char* ScaleString)
{
if (ScaleString[EOT] != '\0' && ScaleString[EOT + 1] == '\0') //should be 24 chars
{
//checksum
//status
m_Status = (ScaleStatus)ScaleString[Status];
char tmp[6]; // 6 last char is end of string, 5 because i am ignoring the 100liko digit
//net
memset(tmp, '0/', 6);
memcpy(tmp, ScaleString + Net + 1, 5);
m_Weight = atoi(tmp);
//gross
memset(tmp, '0/', 6);
memcpy(tmp, ScaleString + Gross + 1, 5);
m_GrossWeight = atoi(tmp);
//peak
memset(tmp, '0/', 6);
memcpy(tmp, ScaleString + Peak + 1, 5);
m_PeakWeight = atoi(tmp);
}
}