1021 for determining information about the board. |
1018 for determining information about the board. |
1022 |
1019 |
1023 @return list of command strings to be executed |
1020 @return list of command strings to be executed |
1024 @rtype list of str |
1021 @rtype list of str |
1025 """ |
1022 """ |
1026 # These are a subset of the generic ones. |
1023 if self.hasCircuitPython(): |
1027 return [ # needs to be splitted for boards with low memory |
1024 return super()._boardInformationCommands() |
1028 """def get_board_info(): |
1025 else: |
|
1026 # These are a subset of the generic ones. |
|
1027 return [ # needs to be splitted for boards with low memory |
|
1028 """def get_board_info(): |
1029 res = {} |
1029 res = {} |
1030 |
1030 |
1031 try: |
1031 try: |
1032 import os |
1032 import os |
1033 uname = os.uname() |
1033 uname = os.uname() |
1163 return res |
1163 return res |
1164 |
1164 |
1165 print(get_board_info()) |
1165 print(get_board_info()) |
1166 del get_board_info |
1166 del get_board_info |
1167 """, |
1167 """, |
1168 ] |
1168 ] |
1169 |
1169 |
1170 def getBoardInformation(self): |
1170 def getBoardInformation(self): |
1171 """ |
1171 """ |
1172 Public method to get some information data of the connected board. |
1172 Public method to get some information data of the connected board. |
1173 |
1173 |
1174 @return dictionary containing the determined data |
1174 @return dictionary containing the determined data |
1175 @rtype dict |
1175 @rtype dict |
1176 """ |
1176 """ |
1177 res = super().getBoardInformation() |
1177 res = super().getBoardInformation() |
1178 |
1178 |
1179 # post-process the results to determine the right float entries |
1179 if not self.hasCircuitPython(): |
1180 |
1180 # post-process the results to determine the right float entries |
1181 # 1. memory |
1181 |
1182 res["mem_total_kb"] = res["mem_total"] / 1024.0 |
1182 # 1. memory |
1183 res["mem_used_kb"] = res["mem_used"] / 1024.0 |
1183 res["mem_total_kb"] = res["mem_total"] / 1024.0 |
1184 res["mem_used_pc"] = res["mem_used"] / res["mem_total"] * 100.0 |
1184 res["mem_used_kb"] = res["mem_used"] / 1024.0 |
1185 res["mem_free_kb"] = res["mem_free"] / 1024.0 |
1185 res["mem_used_pc"] = res["mem_used"] / res["mem_total"] * 100.0 |
1186 res["mem_free_pc"] = res["mem_free"] / res["mem_total"] * 100.0 |
1186 res["mem_free_kb"] = res["mem_free"] / 1024.0 |
1187 |
1187 res["mem_free_pc"] = res["mem_free"] / res["mem_total"] * 100.0 |
1188 # 2. flash |
1188 |
1189 if res["flash_info_available"]: |
1189 # 2. flash |
1190 res["flash_total_kb"] = res["flash_total"] / 1024.0 |
1190 if res["flash_info_available"]: |
1191 res["flash_free_kb"] = res["flash_free"] / 1024.0 |
1191 res["flash_total_kb"] = res["flash_total"] / 1024.0 |
1192 res["flash_used_kb"] = res["flash_total_kb"] - res["flash_free_kb"] |
1192 res["flash_free_kb"] = res["flash_free"] / 1024.0 |
1193 res["flash_free_pc"] = res["flash_free_kb"] / res["flash_total_kb"] * 100.0 |
1193 res["flash_used_kb"] = res["flash_total_kb"] - res["flash_free_kb"] |
1194 res["flash_used_pc"] = res["flash_used_kb"] / res["flash_total_kb"] * 100.0 |
1194 res["flash_free_pc"] = ( |
1195 |
1195 res["flash_free_kb"] / res["flash_total_kb"] * 100.0 |
1196 # 3. machine |
1196 ) |
1197 res["mc_frequency_mhz"] = ( |
1197 res["flash_used_pc"] = ( |
1198 res["mc_frequency"] / 1000000.0 if res["mc_frequency"] is not None else None |
1198 res["flash_used_kb"] / res["flash_total_kb"] * 100.0 |
1199 ) |
1199 ) |
1200 with contextlib.suppress(KeyError): |
1200 |
1201 if res["mc_temp_c"] is not None: |
1201 # 3. machine |
1202 res["mc_temp_c"] = res["mc_temp_c"] / 100 # due to integer support only |
1202 res["mc_frequency_mhz"] = ( |
|
1203 res["mc_frequency"] / 1000000.0 |
|
1204 if res["mc_frequency"] is not None |
|
1205 else None |
|
1206 ) |
|
1207 with contextlib.suppress(KeyError): |
|
1208 if res["mc_temp_c"] is not None: |
|
1209 res["mc_temp_c"] = ( |
|
1210 res["mc_temp_c"] / 100 |
|
1211 ) # due to integer support only |
1203 |
1212 |
1204 return res |
1213 return res |
1205 |
1214 |
1206 def isMicrobit(self): |
1215 def isMicrobit(self): |
1207 """ |
1216 """ |