Reply To: 4 separate on/off switches on same parameter address?

Home Forums General Programming 4 separate on/off switches on same parameter address? Reply To: 4 separate on/off switches on same parameter address?

#73012
dnaldoog
Participant
  • Topics: 4
  • Replies: 480
  • Total: 484
  • ★★

Hi Human Fly – I realised it was an old post, but I thought just in case you were wilting away all this time 🙂

Well, the
cs=myChecksumFunction(sumOfa) is (pseudo) code for calculating the checksum. The function myChecksumFunction(sumOfa) would actually look ‘something’ like:
myChecksumFunction(0x12, 0x04, 0x00, 0x0c, sumOfa)

myChecksumFunction=function(...)
    local total=0
    local result=0
    for i,v in ipairs(arg) do
        total=total+v --addup all the numbers
        if(total > 127) then
            total=total - 128
        end
    end
    result=128-total
	if result== 128 then result = 0 end -- If the result is 128 then substitute a value of 0
    return result
end --function
---------------------------------------------------------
  • This reply was modified 4 years, 4 months ago by dnaldoog. Reason: minor correction if result == 128
Ctrlr