Hi all found a little explanation for a checksum online and replicated it
To possible use it for sending data between the 2 Dorji drf1278dm I have to test if there is any coruption
So I wrote a test rig
the thing is that the values that I preload for b4 to b10 alter after passing through the sub routines
I can not understand why as all that occurs is 1 word value holds the total value of them and b20 to b26 should just be an equal to
can anyone see any were I have mis understood the program as normal
regards john
To possible use it for sending data between the 2 Dorji drf1278dm I have to test if there is any coruption
So I wrote a test rig
the thing is that the values that I preload for b4 to b10 alter after passing through the sub routines
I can not understand why as all that occurs is 1 word value holds the total value of them and b20 to b26 should just be an equal to
Code:
;Bytes total 1,151
; 1,151 / 256 = 4.496 (round to 4)
; 4 x 256 = 1,024
; 1,151 - 1,024 = 127 checksum
;the checksum to try out fron the net
symbol checksum=w1
symbol total=w2
symbol bytes=w6
symbol rbytes=w15;received byte
symbol rtotal=w16;received
symbol rchecksum=w17
b4=23:b5=36:b6=78:b7=96:b8=109:b9=15:b10=43;load some value for transmission
;would be the transmission via dorji
do
sertxd("sent data ",#b4," ",#b5," ",#b6," ",#b7," ",#b8," ",#b9," ",#b10,cr,lf)
bytes=bytes+b4
bytes=bytes+b5
bytes=bytes+b6
bytes=bytes+b7
bytes=bytes+b8
bytes=bytes+b9
bytes=bytes+b10;
;bytes=1151
sertxd("bytes = ",#bytes,cr,lf)
total=bytes/256
sertxd("total/256 = ",#total,cr,lf)
total=total*256
sertxd("total*256 = ",#total,cr,lf)
sertxd("bytes = ",#bytes," total = ",#total,cr,lf)
checksum=bytes-total
sertxd("checksum = ",#checksum,cr,lf)
gosub tell
gosub increase
pause 2000
loop
tell: ;recieved transmission
b20=b4:b21=b5:b22=b6:b23=b7:b24=b8:b25=b9:b26=b10
sertxd("received data ",#b20," ",#b21," ",#b22," ",#b23," ",#b24," ",#b25," ",#b26,cr,lf);?? why are value diffrent b20 to b26 sould reflect b4 to b10 values
rbytes=rbytes+b20
rbytes=rbytes+b21
rbytes=rbytes+b22
rbytes=rbytes+b23
rbytes=rbytes+b24
rbytes=rbytes+b25
rbytes=rbytes+b26
sertxd("rbytes = ",#rbytes,cr,lf)
rtotal=rbytes/256
sertxd("rtotal/256 = ",#rtotal,cr,lf)
rtotal=rtotal*256
sertxd("rtotal*256 = ",#rtotal,cr,lf)
sertxd("rbytes = ",#rbytes," rtotal = ",#rtotal,cr,lf)
rchecksum=rbytes-rtotal
sertxd("rchecksum = ",#rchecksum,cr,lf)
return
increase:;alter values for transmission
b4=b4+10
b5=b5+10
b6=b6+10
b7=b7+10
b7=b7+19
b8=b8+11
b9=b9+10
b10=b10+10
return
regards john