Call the command getInfo and fill up the information received in the fields of the object
(self, target_id)
| 249 | return self.targets[target_id] |
| 250 | |
| 251 | def _update_info(self, target_id): |
| 252 | """ Call the command getInfo and fill up the information received in |
| 253 | the fields of the object |
| 254 | """ |
| 255 | |
| 256 | # Call getInfo ... |
| 257 | pk = CRTPPacket() |
| 258 | pk.set_header(0xFF, 0xFF) |
| 259 | pk.data = (target_id, 0x10) |
| 260 | self.link.send_packet(pk) |
| 261 | |
| 262 | # Wait for the answer |
| 263 | pk = self.link.receive_packet(2) |
| 264 | |
| 265 | if (pk and pk.header == 0xFF and struct.unpack('<BB', pk.data[0:2]) == |
| 266 | (target_id, 0x10)): |
| 267 | tab = struct.unpack('BBHHHH', pk.data[0:10]) |
| 268 | cpuid = struct.unpack('B' * 12, pk.data[10:22]) |
| 269 | if target_id not in self.targets: |
| 270 | self.targets[target_id] = Target(target_id) |
| 271 | self.targets[target_id].addr = target_id |
| 272 | if len(pk.data) > 22: |
| 273 | self.targets[target_id].protocol_version = pk.datat[22] |
| 274 | self.protocol_version = pk.datat[22] |
| 275 | self.targets[target_id].page_size = tab[2] |
| 276 | self.targets[target_id].buffer_pages = tab[3] |
| 277 | self.targets[target_id].flash_pages = tab[4] |
| 278 | self.targets[target_id].start_page = tab[5] |
| 279 | self.targets[target_id].cpuid = '%02X' % cpuid[0] |
| 280 | for i in cpuid[1:]: |
| 281 | self.targets[target_id].cpuid += ':%02X' % i |
| 282 | |
| 283 | if (self.protocol_version == 0x10 and |
| 284 | target_id == TargetTypes.STM32): |
| 285 | self._update_mapping(target_id) |
| 286 | |
| 287 | return True |
| 288 | |
| 289 | return False |
| 290 | |
| 291 | def _update_mapping(self, target_id): |
| 292 | pk = CRTPPacket() |
no test coverage detected