module SpheroUtilities

Public Instance Methods

add_checksum(full_bytes) click to toggle source
# File lib/rubysphero.rb, line 34
def add_checksum(full_bytes)
        to_chk_bytes = full_bytes.drop(2)
        full_bytes.push do_checksum(to_chk_bytes)
        return full_bytes
end
do_checksum(bytes) click to toggle source
# File lib/rubysphero.rb, line 21
def do_checksum(bytes)
        total=0
        bytes.each do | a_byte |
                total+=a_byte
        end # each
        logd "Checksum of these bytes: #{print_format_bytes(bytes)}"
        chk1= (total%256)
        chk2=  (chk1 ^ 0b11111111)
        logd "Checksum calculated: #{chk2.to_s(16)}"
        return chk2
        
end
print_format_bytes(bytes) click to toggle source