i'm using Thonny to operate on rasberry pi pico with micropython the script is:
def writejson(gps_altitudes, gps_time, baro_altitudes, baro_time):
f = open("samples.json", "w")
f.write('{\n"gps_altitude": [')
result=""
c=0
for element in gps_altitudes:
flag=True
result = result+str(element)
c+=1
if c != len(gps_altitudes):
result += ", "
f.write(result)
result=""
result = result + '],\n"gps_time": ['
c=0
for element in gps_time:
result = result+"["+str(element[0])+", "+ str(element[1])+", "+str(element[2])+"]"
c+=1
if c != len(gps_time):
result += ", "
f.write(result)
result=""
result = result +'],\n"baro_altitude": ['
c=0
for element in baro_altitudes:
flag = True
result = result + str(element)
c+=1
if c != len(baro_altitudes):
result += ", "
f.write(result)
result=""
result = result+'],\n"baro_time": ['
c=0
for element in baro_time:
result = result+"["+str(element[0])+", "+ str(element[1])+", "+str(element[2])+"]"
c+=1
if c != len(baro_time):
result += ", "
f.write(result)
result=""
f.write(']\n}')
f.close()
to resume everything i just created a json file, the problem is that if the file exceeds a certain lenght that is variable, Thonny gives me this error when i try to open it.
PROBLEM IN THONNY'S BACK-END: Exception while handling 'read_file' (thonny.plugins.micropython.mp_back.ManagementError: Script produced errors).
log is:
Traceback (most recent call last):
File "B:\Thonny\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "B:\Thonny\lib\site-packages\thonny\base_file_browser.py", line 586, in on_double_click
self.open_file(path)
File "B:\Thonny\lib\site-packages\thonny\base_file_browser.py", line 1201, in open_file
get_workbench().get_editor_notebook().show_remote_file(path)
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 1069, in show_remote_file
return self.show_file(make_remote_path(target_filename))
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 1043, in show_file
editor = self.get_editor(filename, True)
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 1134, in get_editor
return self._open_file(filename_or_id)
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 1116, in _open_file
if editor._load_file(filename):
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 206, in _load_file
result = self._load_remote_file(filename)
File "B:\Thonny\lib\site-packages\thonny\editors.py", line 265, in _load_remote_file
raise RuntimeError(response["error"])
RuntimeError: Backend terminated
i don't understand why this happen if someone can help thanks in advance (: