@@ -270,10 +270,13 @@ def rtt_device_task(device, output_dir, mcu, programmer_type, reset, timeout, ms
270270
271271
272272def rtt_multiple_devices (devices , output_dir , mcu , programmer_type , reset , timeout , msg , msg_timeout , msg_retries , log_level ):
273- """RTT for multiple devices in parallel."""
273+ """RTT for multiple devices - parallel for IPs, sequential for serials ."""
274274 # Create output directory
275275 Path (output_dir ).mkdir (parents = True , exist_ok = True )
276276
277+ # Check if we have IP or serial devices
278+ has_ip = any (dev ['ip' ] for dev in devices )
279+
277280 print (f"Starting RTT for { len (devices )} device(s)" )
278281 print (f"Output directory: { output_dir } " )
279282 if timeout == 0 :
@@ -282,32 +285,49 @@ def rtt_multiple_devices(devices, output_dir, mcu, programmer_type, reset, timeo
282285 print (f"(Reading for { timeout } seconds)\n " )
283286
284287 results = []
285- threads = []
286288
287- # Start threads for each device
288- for dev in devices :
289- device_id = dev ['ip' ] or f"serial { dev ['serial' ]} " or "auto"
290- print (f"✓ Started RTT for { device_id } " )
289+ if has_ip :
290+ # Parallel execution for IP devices using threads
291+ threads = []
291292
292- thread = threading .Thread (
293- target = lambda d = dev : results .append (
294- rtt_device_task (d , output_dir , mcu , programmer_type , reset , timeout , msg , msg_timeout , msg_retries , log_level )
293+ for dev in devices :
294+ device_id = dev ['ip' ] or f"serial { dev ['serial' ]} " or "auto"
295+ print (f"✓ Started RTT for { device_id } " )
296+
297+ thread = threading .Thread (
298+ target = lambda d = dev : results .append (
299+ rtt_device_task (d , output_dir , mcu , programmer_type , reset , timeout , msg , msg_timeout , msg_retries , log_level )
300+ )
295301 )
296- )
297- thread .start ()
298- threads .append (thread )
299-
300- # Wait for all threads to complete
301- try :
302- for thread in threads :
303- thread .join ()
304- except KeyboardInterrupt :
305- print ("\n \n Interrupted by user. Waiting for threads to finish..." )
306- for thread in threads :
307- thread .join (timeout = 5 )
302+ thread .start ()
303+ threads .append (thread )
304+
305+ # Wait for all threads to complete
306+ try :
307+ for thread in threads :
308+ thread .join ()
309+ except KeyboardInterrupt :
310+ print ("\n \n Interrupted by user. Waiting for threads to finish..." )
311+ for thread in threads :
312+ thread .join (timeout = 5 )
313+ else :
314+ # Sequential execution for serial devices (USB driver limitations)
315+ print ("Note: Serial devices are processed sequentially due to USB driver limitations\n " )
316+
317+ for dev in devices :
318+ device_id = f"serial { dev ['serial' ]} " if dev ['serial' ] else "auto"
319+ print (f"✓ Processing RTT for { device_id } ..." )
320+
321+ result = rtt_device_task (dev , output_dir , mcu , programmer_type , reset , timeout , msg , msg_timeout , msg_retries , log_level )
322+ results .append (result )
323+
324+ if result ['success' ]:
325+ print (f" → Completed: { result ['file' ]} \n " )
326+ else :
327+ print (f" → Failed: { result .get ('error' , 'Unknown error' )} \n " )
308328
309329 # Summary
310- print (f"\n { '=' * 60 } " )
330+ print (f"{ '=' * 60 } " )
311331 print (f"RTT completed for { len (devices )} device(s)" )
312332 print (f"{ '=' * 60 } \n " )
313333
0 commit comments