system-logger.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import depthai as dai
  2. def printSystemInformation(info):
  3. m = 1024 * 1024 # MiB
  4. print(f"Ddr used / total - {info.ddrMemoryUsage.used / m:.2f} / {info.ddrMemoryUsage.total / m:.2f} MiB")
  5. print(f"Cmx used / total - {info.cmxMemoryUsage.used / m:.2f} / {info.cmxMemoryUsage.total / m:.2f} MiB")
  6. print(f"LeonCss heap used / total - {info.leonCssMemoryUsage.used / m:.2f} / {info.leonCssMemoryUsage.total / m:.2f} MiB")
  7. print(f"LeonMss heap used / total - {info.leonMssMemoryUsage.used / m:.2f} / {info.leonMssMemoryUsage.total / m:.2f} MiB")
  8. t = info.chipTemperature
  9. print(f"Chip temperature - average: {t.average:.2f}, css: {t.css:.2f}, mss: {t.mss:.2f}, upa: {t.upa:.2f}, dss: {t.dss:.2f}")
  10. print(f"Cpu usage - Leon CSS: {info.leonCssCpuUsage.average * 100:.2f}%, Leon MSS: {info.leonMssCpuUsage.average * 100:.2f} %")
  11. print("----------------------------------------")
  12. # Create pipeline
  13. pipeline = dai.Pipeline()
  14. # Define source and output
  15. sysLog = pipeline.create(dai.node.SystemLogger)
  16. linkOut = pipeline.create(dai.node.XLinkOut)
  17. linkOut.setStreamName("sysinfo")
  18. # Properties
  19. sysLog.setRate(1) # 1 Hz
  20. # Linking
  21. sysLog.out.link(linkOut.input)
  22. # Connect to device and start pipeline
  23. with dai.Device(pipeline) as device:
  24. # Output queue will be used to get the system info
  25. qSysInfo = device.getOutputQueue(name="sysinfo", maxSize=4, blocking=False)
  26. while True:
  27. sysInfo = qSysInfo.get() # Blocking call, will wait until a new data has arrived
  28. printSystemInformation(sysInfo)