# This is a function to process the list of cell voltage data def process_list(v): # Instantiate an empty string to store all of the voltage data # Creating one long string alleviates the problem of having 1/2 a voltage on each message v_string = "" # Iterate through the 29 entries of the list for i in range(0, 29): # Create a temporary variable and store the next string temp = v[i] # Concatenate the temporary string to the end of the long string v_string = v_string + temp # Create an empty list to store the voltage of each cell voltages = [0.0] * 97 for i in range(0, 96): # Each cell has a 16 bit value. Extract the next 16 bits and convert it into a float voltages[i] = float(int(v_string[(i*16):(i*16+16)], 2)) # Divide by 1000 to get the final value voltages[i] = voltages[i]/1000 # Print the voltage of the cell to the console #print("Cell " + str(i+1) + " = %.3f" % voltages[i]) return voltages