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
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

View File

@ -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())