Initial flash is working again

This commit is contained in:
Ollo 2021-01-31 16:51:31 +01:00
parent 0e8fc88646
commit 768ff42c1a
2 changed files with 15 additions and 11 deletions

View File

@ -34,7 +34,7 @@ fi
# Format filesystem first # Format filesystem first
echo "Format the complete ESP" echo "Format the complete ESP"
$LUATOOL -p $DEVICE -w -b $BAUD python3 $LUATOOL -p $DEVICE -w -b $BAUD
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "STOOOOP" echo "STOOOOP"
exit 1 exit 1
@ -59,7 +59,7 @@ for f in $FILES; do
exit 1 exit 1
fi fi
echo "------------- $f ------------" 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 if [ $? -ne 0 ]; then
echo "STOOOOP" echo "STOOOOP"
exit 1 exit 1

View File

@ -16,6 +16,9 @@
# You should have received a copy of the GNU General Public License along with # 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 # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301 USA. # Street, Fifth Floor, Boston, MA 02110-1301 USA.
# version 0.6.4 based version
# Version 0.8.0 upgraded to python3
import sys import sys
import serial import serial
@ -25,7 +28,7 @@ import argparse
from os.path import basename from os.path import basename
version = "0.6.4" version = "0.8.0"
class TransportError(Exception): class TransportError(Exception):
@ -55,11 +58,12 @@ class AbstractTransport:
line = '' line = ''
char = '' char = ''
i = -1 i = -1
while char != chr(62): # '>' while (len(char) == 0) or (ord(char) != 62): # '>'
char = self.read(1) char = self.read(1)
#print(ord(char))
if char == '': if char == '':
raise Exception('No proper answer from MCU') 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 != '': if line != '':
line = line.strip() line = line.strip()
if line+'\r' == expected: if line+'\r' == expected:
@ -78,8 +82,8 @@ class AbstractTransport:
raise Exception('Error sending data to MCU\r\n\r\n') raise Exception('Error sending data to MCU\r\n\r\n')
line = '' line = ''
else: else:
line += char line += char.decode("utf-8")
if char == chr(62) and expected[i] == char: if ord(char) == 62 and expected[i] == char:
char = '' char = ''
i += 1 i += 1
@ -105,7 +109,7 @@ class SerialTransport(AbstractTransport):
if len(data) > 0: if len(data) > 0:
sys.stdout.write("\r\n->") sys.stdout.write("\r\n->")
sys.stdout.write(data.split("\r")[0]) sys.stdout.write(data.split("\r")[0])
self.serial.write(data) self.serial.write(str.encode(data))
sleep(self.delay) sleep(self.delay)
if check > 0: if check > 0:
self.performcheck(data) self.performcheck(data)
@ -142,7 +146,7 @@ class TcpSocketTransport(AbstractTransport):
if len(data) > 0: if len(data) > 0:
sys.stdout.write("\r\n->") sys.stdout.write("\r\n->")
sys.stdout.write(data.split("\r")[0]) sys.stdout.write(data.split("\r")[0])
self.socket.sendall(data) self.socket.sendall(str.encode(data))
if check > 0: if check > 0:
self.performcheck(data) self.performcheck(data)
else: else:
@ -218,10 +222,10 @@ if __name__ == '__main__':
fn = "" fn = ""
while True: while True:
char = transport.read(1) char = transport.read(1)
if char == '' or char == chr(62): if char == '' or ord(char) == 62:
break break
if char not in ['\r', '\n']: if char not in ['\r', '\n']:
fn += char fn += char.decode("utf-8")
else: else:
if fn: if fn:
file_list.append(fn.strip()) file_list.append(fn.strip())