Get memory status

 1
 2'''
 3System - get_memory_status.py.
 4
 5This example project shows how to get RAM and flash memory.
 6
 7For other examples please check:
 8    https://github.com/WPC-Systems-Ltd/WPC_Stand-alone_Python_release/tree/main/examples
 9
10Copyright (c) 2024 WPC Systems Ltd.
11All rights reserved.
12'''
13
14## WPC
15import pywpc
16
17## Python
18import time
19import gc
20import os
21
22def WPC_getFlashInfo():
23  s = os.statvfs('//')
24  return ('Flash size: {0} MB'.format((s[0]*s[3])/1048576))
25
26def WPC_getRAMInfo():
27  F = gc.mem_free()
28  A = gc.mem_alloc()
29  T = F+A
30  P = '{0:.2f}%'.format(F/T*100)
31  return ('Total SRAM: {0} MB, Free SRAM: {1} MB ({2})'.format((T/1048576), (F/1048576), P))
32
33print(WPC_getFlashInfo())
34print(WPC_getRAMInfo())