src/eric7/MicroPython/Devices/DeviceBase.py

branch
eric7
changeset 11224
65b341cfab55
parent 11220
044ea8893b81
child 11236
75c26fe1d1c7
equal deleted inserted replaced
11223:bcdb5a20ddc7 11224:65b341cfab55
1221 1221
1222 @return dictionary containing the determined data 1222 @return dictionary containing the determined data
1223 @rtype dict 1223 @rtype dict
1224 @exception OSError raised to indicate an issue with the device 1224 @exception OSError raised to indicate an issue with the device
1225 """ 1225 """
1226 commands = [ # needs to be splitted for boards with low memory 1226 commands = [ # needs to be split for boards with low memory
1227 """def get_device_data(): 1227 """def get_device_data():
1228 res = {} 1228 res = {}
1229 1229
1230 try: 1230 try:
1231 import os 1231 import os
1344 for determining information about the board. 1344 for determining information about the board.
1345 1345
1346 @return list of command strings to be executed 1346 @return list of command strings to be executed
1347 @rtype list of str 1347 @rtype list of str
1348 """ 1348 """
1349 return [ # needs to be splitted for boards with low memory 1349 return [ # needs to be split for boards with low memory
1350 """def get_board_info(): 1350 """def get_board_info():
1351 res = {} 1351 res = {}
1352 1352
1353 import gc 1353 import gc
1354 gc.enable() 1354 gc.enable()
1456 """def get_board_info(): 1456 """def get_board_info():
1457 res = {} 1457 res = {}
1458 1458
1459 try: 1459 try:
1460 import machine as mc 1460 import machine as mc
1461 if isinstance(mc.freq(), tuple): 1461 try:
1462 res['mc_frequency_mhz'] = mc.freq()[0] / 1000000.0 1462 if isinstance(mc.freq(), tuple):
1463 else: 1463 res['mc_frequency_mhz'] = mc.freq()[0] / 1000000.0
1464 res['mc_frequency_mhz'] = mc.freq() / 1000000.0 1464 else:
1465 res['mc_frequency_mhz'] = mc.freq() / 1000000.0
1466 except NotImplementedError:
1467 res['mc_frequency_mhz'] = None
1465 res['mc_id'] = mc.unique_id() 1468 res['mc_id'] = mc.unique_id()
1466 except ImportError: 1469 except ImportError:
1467 try: 1470 try:
1468 import microcontroller as mc 1471 import microcontroller as mc
1469 res['mc_frequency_mhz'] = mc.cpu.frequency / 1000000.0 1472 res['mc_frequency_mhz'] = mc.cpu.frequency / 1000000.0
1470 res['mc_temp_c'] = mc.cpu.temperature 1473 res['mc_temp_c'] = mc.cpu.temperature
1471 res['mc_id'] = mc.cpu.uid 1474 res['mc_id'] = mc.cpu.uid
1472 except ImportError: 1475 except ImportError:
1473 res['mc_frequency'] = None 1476 res['mc_frequency_mhz'] = None
1474 res['mc_temp'] = None 1477 res['mc_temp_c'] = None
1478 res['mc_id'] = ''
1475 if 'mc_id' in res: 1479 if 'mc_id' in res:
1476 res['mc_id'] = ':'.join('{0:02X}'.format(x) for x in res['mc_id']) 1480 res['mc_id'] = ':'.join('{0:02X}'.format(x) for x in res['mc_id'])
1477 1481
1478 return res 1482 return res
1479 1483

eric ide

mercurial