When using Thonny, my colleague found that the system time was automatically set when saving files. After analyzing the download program by Thonny, I found that Thonny sent the following command:
try:
from machine import RTC as __thonny_RTC
try:
__thonny_RTC()datetime((2021, 6, 16, 3, 16, 6, 0, 0))
except:
__thonny_RTC()init((2021, 6, 16, 16, 6, 0, 0, 0))
del __thonny_RTC
__thonny_helperprint_mgmt_value(True)
except Exception as e:
__thonny_helperprint_mgmt_value(str(e))
try:
__thonny_path = '/testpy'
__thonny_written = 0
__thonny_fp = open(__thonny_path, 'wb')
except Exception as e:
print(str(e))
def __W(x):
global __thonny_written
__thonny_written += __thonny_fpwrite(x)
__thonny_fpflush()
if hasattr(__thonny_helperos, "sync"):
__thonny_helperossync()
__W(b'print(1+2+3+4+5)')__thonny_helperprint_mgmt_value(__thonny_written)
try:
del __W
del __thonny_written
del __thonny_path
__thonny_fpclose()
del __thonny_fp
del __thonny_result
del __thonny_unhex
except:
pass
__thonny_result = {}
try:
__thonny_names = __thonny_helperlistdir('/')
except OSError:
__thonny_helperprint_mgmt_value(None)
else:
for __thonny_name in __thonny_names:
if not __thonny_namestartswith("") or False:
try:
__thonny_result[__thonny_name] = __thonny_helperosstat('/' + __thonny_name)
except OSError as e:
__thonny_result[__thonny_name] = str(e)
__thonny_helperprint_mgmt_value(__thonny_result)
__thonny_result = {}
try:
__thonny_names = __thonny_helperlistdir('/')
except OSError:
__thonny_helperprint_mgmt_value(None)
else:
for __thonny_name in __thonny_names:
if not __thonny_namestartswith("") or False:
try:
__thonny_result[__thonny_name] = __thonny_helperosstat('/' + __thonny_name)
except OSError as e:
__thonny_result[__thonny_name] = str(e)
__thonny_helperprint_mgmt_value(__thonny_result)
As you can see, the first thing is to set the time, and datetime() or init() will be automatically sent according to the system to synchronize the system time with the computer time.
|