• getChipTemperature() Input/output error

Hi, I'm trying to log the average chip temperature to .csv every second with:

"temp_oak": round(device.getChipTemperature().average)

From time to time I get the following error when trying to log the temperature:

RuntimeError: Device already closed or disconnected: Input/output error

I tried to solve this problem with:

"temp_oak": round(device.getChipTemperature().average) if device.isClosed() == False else "NA"

…which doesn't seem to change anything, the error still occurs with the same frequency.

I would appreciate any tips on how I could make the temperature logging more robust against this error, which stops the script at the moment!

  • erik replied to this.
  • Thanks erik this is a simple solution that seems to work well:

    try:
        temp_oak = round(device.getChipTemperature().average)
    except RuntimeError:
        temp_oak = "NA"

    Hi maxsitt ,
    Maybe you just use try/catch, and if device is already closed you stop logging and close the excel sheet?
    Thanks, Erik

      Thanks erik this is a simple solution that seems to work well:

      try:
          temp_oak = round(device.getChipTemperature().average)
      except RuntimeError:
          temp_oak = "NA"