Index: Teensy_Python_scripts/sensorCommands.py =================================================================== diff -u -rffd8133b92274cfd07e4d94068c938534a41813d -rd2f07b0563ab2aaeca34241d3f6ebb2da5dd3c0c --- Teensy_Python_scripts/sensorCommands.py (.../sensorCommands.py) (revision ffd8133b92274cfd07e4d94068c938534a41813d) +++ Teensy_Python_scripts/sensorCommands.py (.../sensorCommands.py) (revision d2f07b0563ab2aaeca34241d3f6ebb2da5dd3c0c) @@ -10,6 +10,27 @@ loop_time = 10 +# List of Measurement Settings parameters used to unpack the update status response +cfgSettingsParam = [ + "sinfreq", + "dacpp", + "bias", + "rtia", + "pga", + "dftnum", + "avgnum" +] + +# List of expected update measurement settings status response +UPDATE_CFG_STATUS = { + 0: "ERR_UNRECOGNIZED_PARAM", + 1: "NO_CHANGE_TO_TIA", + 2: "NO_CHANGE_TO_PGA", + 3: "NO_CHANGE_TO_DFT_NUM", + 4: "NO_CHANGE_TO_AVG_NUM", + 5: "SUCCESS" +} + ########################################################################################## # Execute initialization function def initializeAllSensors(ser): @@ -71,6 +92,7 @@ parsePackets.parseMesaurementData(serial_data) ########################################################################################## +# Function to pack measurement settings in CSV format def packMeasurementSettingsCSV(): # Define measurement settings values SinFreq = 11000.0 @@ -87,27 +109,7 @@ return csv_command ########################################################################################## - - -cfgSettingsParam = [ - "sinfreq", - "dacpp", - "bias", - "rtia", - "pga", - "dftnum", - "avgnum" -] - -UPDATE_CFG_STATUS = { - 0: "ERR_UNRECOGNIZED_PARAM", - 1: "NO_CHANGE_TO_TIA", - 2: "NO_CHANGE_TO_PGA", - 3: "NO_CHANGE_TO_DFT_NUM", - 4: "NO_CHANGE_TO_AVG_NUM", - 5: "SUCCESS" -} - +# Function to send measurement settings in CSV format and receive status response def updateMeasurementSettingsStruct(ser): ser.reset_input_buffer() printTimestamp() @@ -122,15 +124,6 @@ time.sleep(0.2) response = ser.read(7) # MAX_CONDUCTIVITY_MST_PARAM_IDX = 7 - UPDATE_CFG_STATUS = { - 0: "ERR_UNRECOGNIZED_PARAM", - 1: "NO_CHANGE_TO_TIA", - 2: "NO_CHANGE_TO_PGA", - 3: "NO_CHANGE_TO_DFT_NUM", - 4: "NO_CHANGE_TO_AVG_NUM", - 5: "SUCCESS" - } - if len(response) == len(cfgSettingsParam): print("Received update status for all parameters:") for idx, status_byte in enumerate(response): @@ -141,7 +134,6 @@ else: print(f"Expected {len(cfgSettingsParam)} bytes, received {len(response)} bytes. Response incomplete.") - ########################################################################################## # Function to read all the sensor values def getMeasurementSettings(ser): @@ -158,7 +150,7 @@ ########################################################################################## def updateEEPROMData(ser, *values): """ - Sends a 'save' command with 1 to N EEPROM values over UART in CSV format, + Sends a 'upe' command with 1 to N EEPROM values over UART in CSV format, and interprets the response using Update_EEPROM_Status codes. Args: