import re import math import serial # import pyserial import serial.tools.list_ports as sertools import time import struct import sensorCommands ########################################################################################## instrument_baudrate = 115200 ports = sertools.comports() ser_comport = ports[0].device ser = serial.Serial(ser_comport, baudrate=instrument_baudrate, bytesize=serial.EIGHTBITS, timeout = 0.5) # Test Execution setup # Found out after test and trial that 2 seconds delay is needed # before reading the init status after executing the init function init_delay = 2 # in seconds test_execution_time = 2 # in seconds start_time = time.time() # # Execute initialization function print("\nStart initialization") sensorCommands.initializeAllSensors(ser) time.sleep(init_delay) # # # # Get initialization status print("\nGet initialization status") sensorCommands.getInitStatus(ser) # # # # # Read single sensor value j 4 # # # print("\nRead Sensor 4") # # # sensorCommands.readSingleSensorMeasurement(ser, 4) # # # # # Read single sensor value j 6 print("\nRead Sensor 6") sensorCommands.readSingleSensorMeasurement(ser, 6) # # # # # Read all sensor value # print("\nRead All Sensors") # sensorCommands.getAllSensorMeasurements(ser) # # # Loop for 10 secs and read alternatively values of sensor 4 and 6 # print("\nRead Sensor 4 and 6 in loop for 10 seconds") # sensorCommands.loopSingleSensorReadings(ser) # # # Loop for 10 secs and read alternatively values of sensor 4 and 6 # print("\nRead All Sensors in loop for 10 seconds") # sensorCommands.loopAllSensorReadings(ser) # # Get EEPROM data # print("\nGet EEPROM data") # sensorCommands.getEEPROMdata(ser) # # print("\nUpdate EEPROM data") # # sensorCommands.updateEEPROMData(ser, 45.342, 3634.3442, 63232.322, 6232.22) # # # print("\nGet EEPROM data") # sensorCommands.getEEPROMdata(ser) # # Get measurement settings print("\nGet Measurement Settings") sensorCommands.getMeasurementSettings(ser) # Get measurement settings print("\nUpdate Measurement Settings") sensorCommands.updateMeasurementSettingsStruct(ser) # Get measurement settings print("\nGet Measurement Settings") sensorCommands.getMeasurementSettings(ser) # Get all sensor data # print("\nGet all sensor data") # sensorCommands.getAllSensorData(ser) ##########################################################################################