2054 views|2 replies

1w

Posts

25

Resources
The OP
 

Thonny Automatically set the time [Copy link]

 

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.

Latest reply

Is your company using mpy for projects? Are your colleagues using it too?   Details Published on 2021-6-16 17:15
 
 

7422

Posts

2

Resources
2
 

Is your company using mpy for projects? Are your colleagues using it too?

Comments

Yes, thonny is quite handy, especially on the ESP32.  Details Published on 2021-6-16 23:24
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

1w

Posts

25

Resources
3
 
freebsder posted on 2021-6-16 17:15 Is your company using mpy for projects? Are your colleagues also using it?

Yes, thonny is quite handy, especially on the ESP32.

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list