diff --git a/bin/buildtime.py b/bin/buildtime.py index 2a667de..eafe16f 100755 --- a/bin/buildtime.py +++ b/bin/buildtime.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 ## This is a quick and dirty script for placing the build time into diff --git a/bin/goodwatch-txt2cp.py b/bin/goodwatch-txt2cp.py index 97369da..c32626d 100755 --- a/bin/goodwatch-txt2cp.py +++ b/bin/goodwatch-txt2cp.py @@ -1,10 +1,10 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 ## This quick and dirty tool converts a textfile of frequencies and ## names into a GoodWatch codeplug, for storage in information flash ## at 0x1800. Use cc430-bsl.py to write the codeplug to flash. -import sys, argparse; +import sys, argparse, codecs; def freqbytes(freq): @@ -20,8 +20,8 @@ def ihexcrc(hexline): """Calculates an Intel Hex CRC of a line.""" #%print("Calculating CRC of %s."%hexline); CRC=0; - for b in hexline: - CRC=CRC+ord(b); + for b in bytes(hexline): + CRC=CRC+int(b); CRC=CRC^0xFF; CRC=CRC+1; return CRC&0xFF; @@ -43,7 +43,7 @@ def handleline(line): words=line.split(); freq=float(words[0]); name=words[1]; - namehex=name.encode('hex'); + namehex=codecs.encode(bytes(name, 'utf-8'), 'hex').decode('utf-8'); assert(len(name)<=8); while len(namehex)<16: namehex='20'+namehex; @@ -54,7 +54,7 @@ def handleline(line): line="%02x%04x00%02x%02x%02x%02x%s" %( LEN, codeplugadr, FLAGS, FREQ2,FREQ1,FREQ0, namehex ); - CRC=ihexcrc(line.decode("hex")); + CRC=ihexcrc(codecs.decode(bytes(line, 'utf-8'), 'hex')); codeplugadr=codeplugadr+12; return ":%s%02x\n" % (line, CRC); diff --git a/bin/goodwatch-txt2cpstr.py b/bin/goodwatch-txt2cpstr.py index 9e4edc3..d972c08 100755 --- a/bin/goodwatch-txt2cpstr.py +++ b/bin/goodwatch-txt2cpstr.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 ## This quick and dirty tool converts a textfile of frequencies and ## names into a GoodWatch codeplug, for storage in the firmware image. @@ -6,7 +6,7 @@ ## 0x1800, but this caused problems with mspdebug's tilib driver, ## which can't seem to unlock info flash. -import sys, argparse; +import sys, argparse, codecs; def freqbytes(freq): @@ -35,7 +35,7 @@ def handleline(line): words=line.split(); freq=float(words[0]); name=words[1]; - namehex=name.encode('hex'); + namehex=codecs.encode(bytes(name, 'utf-8'), 'hex').decode('utf-8'); assert(len(name)<=8); while len(namehex)<16: namehex='20'+namehex; @@ -43,7 +43,7 @@ def handleline(line): (FREQ2, FREQ1, FREQ0) = freqbytes(freq); hexline="\"\\x%02x\\x%02x\\x%02x\\x%02x\" \"%s\"" % ( - FLAGS, FREQ2,FREQ1,FREQ0, namehex.decode("hex") + FLAGS, FREQ2,FREQ1,FREQ0, name ); line="%s //%s \n" %(