How to calculate the checksum in C++?

Programmed in QT(C++) exchange with the device via serial port.
The device accepts data on the Protocol of ASTM 1381-95. Since I'm new to C++, then came the questions.
How to calculate the checksum of the sent packet?
If I make a request with a device and get this packet:
``````1H|\^&|||ACL9000|||||||P|1|2020
0210111653
87
2Q|1|ALL||||||||O
C4
3L|1|N
06``````

The Protocol describes the message schema:
`<STX>FN text<ETX>C1 C2<CR> <LF>`
where C1 C2 checksum of the package. Respectively, 87, C4, 06 is the checksum, I think.
Help to count them.
6.3.3.1 The checksum is initialized to zero with thecharacter. The first character used in computing the checksum is the frame number. Each character in the message text isadded to the checksum (modulo 256). The computation for the checksum does not include the checksum characters,or the trailingand.6.3.3.2 The checksum is an integer represented by eight bits, it can be considered as two groups of four bits. The groups of four bits are converted to the ASCII characters of the hex a decimal representation. The two ASCII characters a retransmitted as the checksum, with the most significant character first.6.3.3.3 For example, a checksum of 122 can be represented as 01111010 in binary or 7A in hexadecimal. The checksum is transmitted as the ASCII character 7 followed by the character A
April 7th 20 at 15:36
April 7th 20 at 15:38
Solution
6.3.3.1 The checksum is initialized to zero with thecharacter.

XS wanted to say. We need a picture of the pdf standard.
The first character used in computing the checksum is the frame number. Each character in the message text isadded to the checksum (modulo 256). The computation for the checksum does not include the checksum characters,or the trailingand.

Like
``````char frameNumber = ....;
char crc = frameNumber;
for (int i = 0; i < messageSize; ++i)
{
crc += message[i]
}``````

We need to experiment.
Well, to translate the calculated checksum in ASCII representation, as it is written.
ATP much!!! - Kyle.Harris commented on April 7th 20 at 15:41

Find more questions by tags Qt