From 10bc72bc96255a97cfd52329d3e8cc90b1af948f Mon Sep 17 00:00:00 2001
From: Neil Gershenfeld <gersh@cba.mit.edu>
Date: Thu, 6 Jul 2023 07:48:57 -0400
Subject: [PATCH] wip

---
 upy.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/upy.py b/upy.py
index 3b0365f..1abbe3a 100755
--- a/upy.py
+++ b/upy.py
@@ -31,6 +31,7 @@ s.write(b'\x01') # ^a enter raw mode
 while (s.in_waiting > 0): # clear buffer
    s.read()
 if (sys.argv[2] == 'run'):
+   s.write(b'\x04') # ^d reset
    s.write(b'\x03') # ^c interrupt
    file = open(sys.argv[3],'r')
    str = file.read()
@@ -42,6 +43,7 @@ if (sys.argv[2] == 'run'):
    while (True): # show output
       sys.stdout.write(s.read().decode('utf-8'))
 elif (sys.argv[2] == 'ls'):
+   s.write(b'\x04') # ^d reset
    s.write(b'\x03') # ^c interrupt
    s.write(b'import os\n')
    s.write(b'files = os.listdir()\n')
@@ -54,6 +56,7 @@ elif (sys.argv[2] == 'ls'):
       sys.stdout.write(s.read().decode('utf-8'))
    print('')
 elif (sys.argv[2] == 'put'):
+   s.write(b'\x04') # ^d reset
    s.write(b'\x03') # ^c interrupt
    file = open(sys.argv[3],'r')
    str = file.read()
@@ -72,6 +75,7 @@ elif (sys.argv[2] == 'put'):
       sys.stdout.write(s.read().decode('utf-8'))
    print('')
 elif (sys.argv[2] == 'get'):
+   s.write(b'\x04') # ^d reset
    s.write(b'\x03') # ^c interrupt
    s.write(bytes(f'file = open("{sys.argv[3]}","r")\n','ascii'))
    s.write(b'print(file.read())\n')
-- 
GitLab