#!/usr/bin/python # part of the Dalsa1M60 package # a module for verifying the temperature of the Dalsa 1M60 # # The serial command 'vt' is sent to the camera. The camera responds as follow s # > vt # Camera Temperature on Digitzer Board: 47.2 Celsius # Camera Temperature on Sensor Board: 39.4 Celsius # OK> # # Written by Aidan Brooks. 5th May 2010 import os, subprocess def VerifyTemperature( serial_cmd_location ): # get default values for the digitizer and sensor temperatures digitizerTemp = 0.0 sensorTemp = 0.0 # run the subprocess to call the vt command process = subprocess.Popen(serial_cmd_location + ' vt', shell=True, stdout = subprocess.PIPE) # get the response serial_cmd_response = process.communicate() temperatureString = serial_cmd_response[0] command_success = serial_cmd_response[1] # if there are no standard errors then get the values of the response if (command_success == None): # Locate the substring that corresponds to the Digitizer Board Tempera ture substring = 'Digitizer Board: ' digitLoc = temperatureString.find(substring) # if the substring exists then check that there is a value after it if (digitLoc > 0): if ( (digitLoc + len(substring) + 4) < len(temperatureString)): tempdigitLoc = digitLoc + len(substring) digitizerTempSTR = temperatureString[tempdigitLoc:(tempdigitLo c + 4)] # check that the string is numeric try: digitizerTemp = float(digitizerTempSTR) finally: pass # Locate the substring that corresponds to the Sensor Board Temperatur e substring = 'Sensor Board: ' sensLoc = temperatureString.find(substring) # if the substring exists then check that there is a value after it if (sensLoc > 0): if ( (sensLoc + len(substring) + 4) < len(temperatureString)): tempsensLoc = sensLoc + len(substring) sensorTempSTR = temperatureString[tempsensLoc:(tempsensLoc + 4 )] # check that the string is numeric try: sensorTemp = float(sensorTempSTR) finally: pass # define the return values temperatures = [digitizerTemp, sensorTemp] return(temperatures)