28 |
28 |
29 It includes a list of commands for general use on the various boards. |
29 It includes a list of commands for general use on the various boards. |
30 If a board needs special treatment, the command should be overwritten |
30 If a board needs special treatment, the command should be overwritten |
31 in the board specific subclass. Commands are provided to perform operations |
31 in the board specific subclass. Commands are provided to perform operations |
32 on the file system of a connected MicroPython device, for getting and setting |
32 on the file system of a connected MicroPython device, for getting and setting |
33 the time on the board and getting board related data. Supported file system |
33 the time on the board and getting board related data. |
34 commands are: |
34 |
|
35 Supported file system commands are: |
35 <ul> |
36 <ul> |
36 <li>cd: change directory</li> |
37 <li>cd: change directory</li> |
37 <li>exists: test the existence of a file or directory on the device</li> |
38 <li>exists: test the existence of a file or directory on the device</li> |
38 <li>fileSystemInfo: get information about the file system</li> |
39 <li>fileSystemInfo: get information about the file system</li> |
39 <li>get: get a file from the connected device</li> |
40 <li>get: get a file from the connected device</li> |
969 """ |
970 """ |
970 command = """ |
971 command = """ |
971 def get_device_data(): |
972 def get_device_data(): |
972 res = {} |
973 res = {} |
973 |
974 |
974 import os |
975 try: |
975 uname = os.uname() |
976 import os |
976 res['sysname'] = uname.sysname |
977 uname = os.uname() |
977 res['nodename'] = uname.nodename |
978 res['sysname'] = uname.sysname |
978 res['release'] = uname.release |
979 res['nodename'] = uname.nodename |
979 res['version'] = uname.version |
980 res['release'] = uname.release |
980 res['machine'] = uname.machine |
981 res['version'] = uname.version |
|
982 res['machine'] = uname.machine |
|
983 except AttributeError: |
|
984 import sys |
|
985 res['sysname'] = sys.platform |
|
986 res['nodename'] = sys.platform |
|
987 res['release'] = '.'.join(str(v) for v in sys.implementation.version) |
|
988 res['version'] = sys.version.split(';', 1)[-1].strip() |
|
989 res['machine'] = sys.implementation._machine |
981 |
990 |
982 import sys |
991 import sys |
983 res['py_platform'] = sys.platform |
992 res['py_platform'] = sys.platform |
984 res['py_version'] = sys.version |
993 res['py_version'] = sys.version |
985 |
994 |
1053 res['mem_used_pc'] = mem_alloc / mem_total * 100.0 |
1062 res['mem_used_pc'] = mem_alloc / mem_total * 100.0 |
1054 res['mem_free_kb'] = mem_free / 1024.0 |
1063 res['mem_free_kb'] = mem_free / 1024.0 |
1055 res['mem_free_pc'] = mem_free / mem_total * 100.0 |
1064 res['mem_free_pc'] = mem_free / mem_total * 100.0 |
1056 del gc, mem_alloc, mem_free, mem_total |
1065 del gc, mem_alloc, mem_free, mem_total |
1057 |
1066 |
1058 import os |
1067 try: |
1059 uname = os.uname() |
1068 import os |
1060 res['sysname'] = uname.sysname |
1069 uname = os.uname() |
1061 res['nodename'] = uname.nodename |
1070 res['sysname'] = uname.sysname |
1062 res['release'] = uname.release |
1071 res['nodename'] = uname.nodename |
1063 res['version'] = uname.version |
1072 res['release'] = uname.release |
1064 res['machine'] = uname.machine |
1073 res['version'] = uname.version |
|
1074 res['machine'] = uname.machine |
|
1075 except AttributeError: |
|
1076 import sys |
|
1077 res['sysname'] = sys.platform |
|
1078 res['nodename'] = sys.platform |
|
1079 res['release'] = '.'.join(str(v) for v in sys.implementation.version) |
|
1080 res['version'] = sys.version.split(';', 1)[-1].strip() |
|
1081 res['machine'] = sys.implementation._machine |
1065 |
1082 |
1066 import sys |
1083 import sys |
1067 res['py_platform'] = sys.platform |
1084 res['py_platform'] = sys.platform |
1068 res['py_version'] = sys.version |
1085 res['py_version'] = sys.version |
1069 |
1086 |