I was able to take a sentence $PMTK604*30 (The info to be evaluated is between the $ and *) and do the checksum at the end that shows why it should be 30 as shown.
I was successful because I broke up the work into baby steps where I could see each part work. Also, I was just trying to make it work with this sentence not for every NMEA sentence. I did this just as a learning device.
Now, I'd like help learning how to use repeat and other ways of combining my steps.
Button called strip_characters
Code: Select all
on mouseUp
put the text of field "nmea_sentence" into thisVariable
replace "$" with "*" in thisVariable
set the itemdelimiter to "*"
get item 2 of thisVariable
put it into field "nmea_core"
end mouseUp
Code: Select all
on mouseUp
get char 1 of field "nmea_core"
put it into field "first"
get char 2 of field "nmea_core"
put it into field "2nd"
get char 3 of field "nmea_core"
put it into field "3rd"
get char 4 of field "nmea_core"
put it into field "4th"
get char 5 of field "nmea_core"
put it into field "5th"
get char 6 of field "nmea_core"
put it into field "6th"
get char 7 of field "nmea_core"
put it into field "7th"
end mouseUp
Code: Select all
on mouseUp
put charToNum (field "first") into field "dec1"
put charToNum (field "2nd") into field "dec2"
put charToNum (field "3rd") into field "dec3"
put charToNum (field "4th") into field "dec4"
put charToNum (field "5th") into field "dec5"
put charToNum (field "6th") into field "dec6"
put charToNum (field "7th") into field "dec7"
end mouseUp
Code: Select all
on mouseUp
put (field "dec1" bitXor field "dec2") into v1Dec
put v1Dec into field "total1"
put (field "total1" bitXor field "dec3") into v2Dec
put v2Dec into field "total2"
put (field "total2" bitXor field "dec4") into v3Dec
put v3Dec into field "total3"
put (field "total3" bitXor field "dec5") into v4Dec
put v4Dec into field "total4"
put (field "total4" bitXor field "dec6") into v5Dec
put v5Dec into field "total5"
put (field "total5" bitXor field "dec7") into v6Dec
put v6Dec into field "total6"
end mouseUp
Code: Select all
on mouseUp
put baseConvert(field "total6", 10,16) into field "Hex_Total"
end mouseUp
Eric