本站改版新增arduino频道

Micropython
Arduino

micropython 获取开发板系统各项参数


import gc

import os

import sys

import time as tm

import machine as mc


##################################################################################

# system setting QQ123691873

##################################################################################

gc.enable()

gc.collect()


mc.freq(240000000)


##################################################################################

# show_hw_info()

##################################################################################

def show_hw_info():

    uname = os.uname()

    mem_total = gc.mem_alloc()+gc.mem_free()

    free_percent = "("+str((gc.mem_free())/mem_total*100.0)+"%)"

    alloc_percent = "("+str((gc.mem_alloc())/mem_total*100.0)+"%)"

    stat = os.statvfs('/flash')

    block_size = stat[0]

    total_blocks = stat[2]

    free_blocks  = stat[3]

    rom_total = (total_blocks * block_size)/1024

    rom_free = (free_blocks * block_size)/1024

    rom_usage = (rom_total-rom_free)

    rfree_percent = "("+str(rom_free/rom_total*100.0)+"%)"

    rusage_percent = "("+str(rom_usage/rom_total*100.0)+"%)"

    print("ID ............:",mc.unique_id())

    print("Platform ......:",sys.platform)

    print("Version .......:",sys.version)

    print("Memory")

    print("   total ......:",mem_total/1024,"KB")

    print("   usage ......:",gc.mem_alloc()/1024,"KB",alloc_percent)

    print("   free .......:",gc.mem_free()/1024,"KB",free_percent)

    print("ROM")

    print("   total ......:", rom_total,"KB" )

    print("   usage ......:", rom_usage,"KB",rfree_percent )

    print("   Free .......:", rom_free,"KB",rusage_percent )

    print("system name ...:",uname.sysname)

    print("node name .....:",uname.nodename)

    print("release .......:",uname.release)

    print("version .......:",uname.version)

    print("machine .......:",uname.machine)

    print("Frequency .....:",mc.freq())



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号

执行时间: 0.0095410346984863 seconds