module Rplidar::Util

Binary encoding, decoding, checksum methods.

Public Instance Methods

binary_to_ints(string, format = 'C*') click to toggle source
# File lib/rplidar/util.rb, line 12
def binary_to_ints(string, format = 'C*')
  string.unpack(format)
end
checksum(string) click to toggle source
# File lib/rplidar/util.rb, line 4
def checksum(string)
  binary_to_ints(string).reduce(:^)
end
ints_to_binary(array, format = 'C*') click to toggle source
# File lib/rplidar/util.rb, line 8
def ints_to_binary(array, format = 'C*')
  [array].flatten.pack(format)
end