You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I hope it's ok to ask this question via an 'issue', not sure where else I could ask :)
I'm trying to understand how the checksum calculation works.
I did find the section in your code where i believe it is being calculated. But I can't replicate the checksums given in your api documentation, which must be correct because the commands work.
from your code:
# add payload and calculate checksum
set sum 1
foreach b $bytes {
lappend full_req $b
set sum [ expr $sum + [ scan $b %d ] ]
}
set sum [ expr $sum & 255 ]
lappend full_req $sum
Given this example from your documentation char-write-cmd 0x2b 0f0c170001010203040000000018ffff
My understanding is I have to take the part 0c1700010102030400000000 into account for the checksum calculation
I then loop over the individual bytes and add them to chksm and at the end I have to & 0xFF them, which should net me 0x18, however I'm getting 0x2F, with the following python example
data = bytearray.fromhex('0c1700010102030400000000')
chksm = 1
for d in data:
chksm += d
print( hex(chksm & 0xff) )
Would be great if you could shine some light on this. I've looked at multiple repos and I can't figure it out :/
edit: After some more attempts: I haven't actually encountered a command that doesn't work when I calculate the checksum excl. the length byte, aside from some examples in your api documentation (e.g. the one above). My guess atm. is that in those cases the checksum is simply not correct in the documentation :?
The text was updated successfully, but these errors were encountered:
Hi, I hope it's ok to ask this question via an 'issue', not sure where else I could ask :)
I'm trying to understand how the checksum calculation works.
I did find the section in your code where i believe it is being calculated. But I can't replicate the checksums given in your api documentation, which must be correct because the commands work.
from your code:
Given this example from your documentation
char-write-cmd 0x2b 0f0c170001010203040000000018ffff
My understanding is I have to take the part
0c1700010102030400000000
into account for the checksum calculationI then loop over the individual bytes and add them to
chksm
and at the end I have to& 0xFF
them, which should net me0x18
, however I'm getting0x2F
, with the following python exampleWould be great if you could shine some light on this. I've looked at multiple repos and I can't figure it out :/
edit: After some more attempts: I haven't actually encountered a command that doesn't work when I calculate the checksum excl. the length byte, aside from some examples in your api documentation (e.g. the one above). My guess atm. is that in those cases the checksum is simply not correct in the documentation :?
The text was updated successfully, but these errors were encountered: