Here is HEX string: 57 F1 0F 9A A8 B7 00 08 0B 19 10 00 00 00 00 00 11 0B 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
A8 and B7 is a checksum that i need to calculate
In C it calculated like that (100% worked):
void ByteStream_ComputeCS(void)
{
int i;
DWORD cs = 0;
for (i = 0; i < ByteStream[2] + 3; i++)
{
if (i != 2) cs += *((WORD*)ByteStream + i);
}
cs = (cs & 0xFFFF) + (cs >> 16);
ByteStream[4] = (BYTE)cs;
ByteStream[5] = (BYTE)(cs >> 8);
}
Im trying to do it like that:
data = bytearray.fromhex('57 F1 0F 9A 00 00 00 08 0B 19 10 00 00 00 00 00 11 0B 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
c_sum = sum(data)
I just replace checksum with 0 - in C its just dont sum
if (i != 2) cs += *((WORD*)ByteStream + i);
But i get 0x25e. And cant get it to A8 and B7. What I'm doing wrong?