Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_checksum mtk_msg
- matchdata = /^\$(.+)\*/.match(mtk_msg)
- result = 0x00
- matchdata[1].chars.each do |c|
- result ^= c.ord
- end
- result
- end
- #
- # assert_equal(31, get_checksum('$PMTK605*'))
- # assert_equal(4, get_checksum('$PMTK226,3,30*'))
- loop do
- result = get_checksum(gets)
- puts "#{result} \t 0x#{result.to_s(16)}"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement