Morning all,
Can anyone help me with this ?
I'm trying to calculate a received (8 bit bytes) packet checksum.
Below is some code that takes the 2nd byte of the packet (which is the length packet).
My protocol disallows bit 7 to be hi (that means something else). so the received checksum is a 6 bit sum of the received bytes.
The AND-ing of checksum isn't working, anyone know why ? - thanks in advance
x=Buffer(1) 'packet length
Dim y As Int = 0 'dim & zero temp variables
Dim checksum as long = 0
For y = 1 To x-1 'Range is byte 1 to packet length-1 (last byte is CSum)
checksum=checksum+(Buffer(y)) 'Add up bytes
Next
Bit.And(checksum,127) 'Strip bits 7 upwards !!!!!!!!!!! - not working
strtemp=Bit.ToHexString(checksum) 'make checksum displayable as a hex number
monitor.Text=monitor.Text & "Checksum - " & strtemp & CRLF 'display checksum - & value
Can anyone help me with this ?
I'm trying to calculate a received (8 bit bytes) packet checksum.
Below is some code that takes the 2nd byte of the packet (which is the length packet).
My protocol disallows bit 7 to be hi (that means something else). so the received checksum is a 6 bit sum of the received bytes.
The AND-ing of checksum isn't working, anyone know why ? - thanks in advance
x=Buffer(1) 'packet length
Dim y As Int = 0 'dim & zero temp variables
Dim checksum as long = 0
For y = 1 To x-1 'Range is byte 1 to packet length-1 (last byte is CSum)
checksum=checksum+(Buffer(y)) 'Add up bytes
Next
Bit.And(checksum,127) 'Strip bits 7 upwards !!!!!!!!!!! - not working
strtemp=Bit.ToHexString(checksum) 'make checksum displayable as a hex number
monitor.Text=monitor.Text & "Checksum - " & strtemp & CRLF 'display checksum - & value