Hello,
I have a problem woth calculating the accurate oh an 8 bit CheckSum for an
A-GPS data fie by skytraq...
in Linux/posix the right checksum is calculated for the array of bytes like this:
//for bytearray ephdata[]
csum is the checksum over all bytes of file
csumb is the checksum over the first 10000 bytes of the file
// checksum
unsigned char csuma, csumb = 0;
for (i = 0; i < 0x10000; i++)
csumb += ephdata;
csuma = csumb;
for (; i < ephbytes; i++)
csuma += ephdata;
I've try'd to make that way in b4a - but with all variants I could not get the accurate checksum value.
Here is one of my b4a-examples:
Dim bc, bcB As Byte
Dim c, cB As Int
'c=0:cB=0
For i=0 To buffer.Length-1
'c=c+(Bit.ParseInt(buffer(i),16)+255)
bc=Bit.xor(bc,buffer(i)+255)
If i<=9999 Then bcB=Bit.Xor(bcB,buffer(i)+255)
'cB=cB+(Bit.ParseInt(buffer(i),16)+255)
Next
c=bc Mod 256
cB=bcB Mod 256
The hardware manufacturer of the device, for that I want to use the checksum says:
'The checksums are the 8-bit exclusive OR of the data, to be transmitted'...
Any Idea???
regards
bitstra
I have a problem woth calculating the accurate oh an 8 bit CheckSum for an
A-GPS data fie by skytraq...
in Linux/posix the right checksum is calculated for the array of bytes like this:
//for bytearray ephdata[]
csum is the checksum over all bytes of file
csumb is the checksum over the first 10000 bytes of the file
// checksum
unsigned char csuma, csumb = 0;
for (i = 0; i < 0x10000; i++)
csumb += ephdata;
csuma = csumb;
for (; i < ephbytes; i++)
csuma += ephdata;
I've try'd to make that way in b4a - but with all variants I could not get the accurate checksum value.
Here is one of my b4a-examples:
Dim bc, bcB As Byte
Dim c, cB As Int
'c=0:cB=0
For i=0 To buffer.Length-1
'c=c+(Bit.ParseInt(buffer(i),16)+255)
bc=Bit.xor(bc,buffer(i)+255)
If i<=9999 Then bcB=Bit.Xor(bcB,buffer(i)+255)
'cB=cB+(Bit.ParseInt(buffer(i),16)+255)
Next
c=bc Mod 256
cB=bcB Mod 256
The hardware manufacturer of the device, for that I want to use the checksum says:
'The checksums are the 8-bit exclusive OR of the data, to be transmitted'...
Any Idea???
regards
bitstra