MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / get_trgetId_from_pack

Function get_trgetId_from_pack

tools/vscpyocd.py:134–162  ·  view source on GitHub ↗
(pack)

Source from the content-addressed store, hash-verified

132 return pack_dir + max_similar_pack
133
134def get_trgetId_from_pack(pack):
135 # get soc name from <rtconfig.h> file
136 socName = get_socName_from_rtconfig()
137 if socName == None:
138 return
139
140 # View the soc supported by the most similar cmsisPack
141 result = os.popen('python -m pyocd json --target --pack ' + pack)
142 pyocd_json = json.loads(result.read())
143 if pyocd_json['status'] != 0:
144 return
145
146 # Find the targetId that best matches soc name
147 max_similar_num = 0
148 max_similar_targetId = None
149 for target in pyocd_json['targets']:
150 if (target['source'] == 'pack'):
151 similar_num = similar_char_num(socName.lower(), target['name'])
152 if(similar_num > max_similar_num):
153 max_similar_num = similar_num
154 max_similar_targetId = target['name']
155 print('SOC<%s> match the targetId is <%s>' % (socName, max_similar_targetId))
156 if max_similar_targetId == None:
157 return
158 if max_similar_num < len(socName):
159 print('<%s> not match the <%s>' % (socName, pack))
160 return
161
162 return max_similar_targetId
163
164def GenerateVSCodePyocdConfig(pack):
165 if pack == 'env':

Callers 1

Calls 3

similar_char_numFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected