From 768ff42c1a6a66991f8691ad7e61448af8f235c6 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 31 Jan 2021 16:51:31 +0100 Subject: [PATCH] Initial flash is working again --- tools/initialFlash.sh | 4 ++-- tools/luatool.py | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/initialFlash.sh b/tools/initialFlash.sh index b1d5efc..67240a8 100755 --- a/tools/initialFlash.sh +++ b/tools/initialFlash.sh @@ -34,7 +34,7 @@ fi # Format filesystem first echo "Format the complete ESP" -$LUATOOL -p $DEVICE -w -b $BAUD +python3 $LUATOOL -p $DEVICE -w -b $BAUD if [ $? -ne 0 ]; then echo "STOOOOP" exit 1 @@ -59,7 +59,7 @@ for f in $FILES; do exit 1 fi echo "------------- $f ------------" - $LUATOOL -p $DEVICE -f $f -b $BAUD -t $f + python3 $LUATOOL -p $DEVICE -f $f -b $BAUD -t $f if [ $? -ne 0 ]; then echo "STOOOOP" exit 1 diff --git a/tools/luatool.py b/tools/luatool.py index 6358855..5bfb296 100755 --- a/tools/luatool.py +++ b/tools/luatool.py @@ -16,6 +16,9 @@ # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin # Street, Fifth Floor, Boston, MA 02110-1301 USA. +# version 0.6.4 based version +# Version 0.8.0 upgraded to python3 + import sys import serial @@ -25,7 +28,7 @@ import argparse from os.path import basename -version = "0.6.4" +version = "0.8.0" class TransportError(Exception): @@ -55,11 +58,12 @@ class AbstractTransport: line = '' char = '' i = -1 - while char != chr(62): # '>' + while (len(char) == 0) or (ord(char) != 62): # '>' char = self.read(1) + #print(ord(char)) if char == '': raise Exception('No proper answer from MCU') - if char == chr(13) or char == chr(10): # LF or CR + if ord(char) == 13 or ord(char) == 10: # LF or CR if line != '': line = line.strip() if line+'\r' == expected: @@ -78,8 +82,8 @@ class AbstractTransport: raise Exception('Error sending data to MCU\r\n\r\n') line = '' else: - line += char - if char == chr(62) and expected[i] == char: + line += char.decode("utf-8") + if ord(char) == 62 and expected[i] == char: char = '' i += 1 @@ -105,7 +109,7 @@ class SerialTransport(AbstractTransport): if len(data) > 0: sys.stdout.write("\r\n->") sys.stdout.write(data.split("\r")[0]) - self.serial.write(data) + self.serial.write(str.encode(data)) sleep(self.delay) if check > 0: self.performcheck(data) @@ -142,7 +146,7 @@ class TcpSocketTransport(AbstractTransport): if len(data) > 0: sys.stdout.write("\r\n->") sys.stdout.write(data.split("\r")[0]) - self.socket.sendall(data) + self.socket.sendall(str.encode(data)) if check > 0: self.performcheck(data) else: @@ -218,10 +222,10 @@ if __name__ == '__main__': fn = "" while True: char = transport.read(1) - if char == '' or char == chr(62): + if char == '' or ord(char) == 62: break if char not in ['\r', '\n']: - fn += char + fn += char.decode("utf-8") else: if fn: file_list.append(fn.strip())