1*** Variables *** 2${SCRIPT} scripts/single-node/zedboard.resc 3${BIN} https://dl.antmicro.com/projects/renode/zynq-interface-tests-icp10101-vmlinux-s_14145184-faf7b152d8913a54efee567c701b4f8a494d72ea 4${DTB} https://dl.antmicro.com/projects/renode/zynq-linux-icp10101.dtb-s_11796-15666b09e3900565b3c5c31bbf08f8b2ecab1e93 5${UART} sysbus.uart0 6${SENSOR} sysbus.i2c0.barometer 7${CSV2RESD} ${RENODETOOLS}/csv2resd/csv2resd.py 8${SAMPLES_CSV} ${CURDIR}/ICP_101xx-samples.csv 9${PROMPT} \#${SPACE} 10 11*** Keywords *** 12Create Machine 13 Execute Command set bin @${BIN} 14 Execute Command set dtb @${DTB} 15 Execute Command include @${SCRIPT} 16 17 Execute Command machine LoadPlatformDescriptionFromString "barometer: Sensors.ICP_101xx @ i2c0 0x50" 18 19 # Wait for Linux to boot up 20 Create Terminal Tester ${UART} defaultPauseEmulation=True 21 Wait For Prompt On Uart buildroot login: timeout=25 22 Write Line To Uart root 23 Wait For Prompt On Uart ${PROMPT} 24 25Set Enviroment 26 [Arguments] ${temperature} ${pressure} 27 Execute Command ${SENSOR} DefaultTemperature ${temperature} 28 Execute Command ${SENSOR} DefaultPressure ${pressure} 29 30Check Enviroment 31 # temperature read is in miliCelsius, pressure in kiloPascals 32 [Arguments] ${temperature} ${pressure} 33 Write Line To Uart cd /sys/bus/i2c/devices/0-0050/iio:device1/ 34 Wait For Prompt On Uart ${PROMPT} 35 Write Line To Uart echo "`cat in_temp_offset` + `cat in_temp_raw` * `cat in_temp_scale`" | bc 36 37 Wait For Line On Uart ${temperature} 38 39 Wait For Prompt On Uart ${PROMPT} 40 Write Line To Uart cat in_pressure_input 41 42 Wait For Line On Uart ${pressure} 43 44Create RESD File 45 [Arguments] ${path} 46 ${resd_path}= Allocate Temporary File 47 ${args}= Catenate SEPARATOR=, 48 ... "--input", r"${path}" 49 ... "--map", "temperature:temp::0" 50 ... "--map", "pressure:pres::0" 51 # Offset since Linux manages to boot-up and display the first measurement, minus 0.03 second, to be sure the change will be seen 52 # Note that for different Linux build, this time might be different, and the tests will fail 53 ... "--start-time", "5_290_000_000" 54 ... "--frequency", "10" 55 ... r"${resd_path}" 56 Evaluate subprocess.run([sys.executable, "${CSV2RESD}", ${args}]) sys,subprocess 57 RETURN ${resd_path} 58 59*** Test Cases *** 60 61Should Boot And Login 62 Create Machine 63 64 Provides booted-linux 65 66Should Read Temperature And Pressure 67 Requires booted-linux 68 69 # The values set and received from the sensor will not match 1:1, 70 # since the sensor has finite precision, but they fit within sensor's accuracy range 71 72 Check Enviroment temperature=-.306624 pressure=29.999993 73 74 Set Enviroment temperature=25.00 pressure=30000 75 Check Enviroment temperature=24998.929632 pressure=29.999998 76 77 Set Enviroment temperature=25.00 pressure=68219 78 Check Enviroment temperature=24998.929632 pressure=68.218994 79 80 Set Enviroment temperature=37.82 pressure=101237 81 Check Enviroment temperature=37818.982320 pressure=101.236999 82 83Should Read Temperature And Pressure From RESD 84 Requires booted-linux 85 ${resd_path}= Create RESD File ${SAMPLES_CSV} 86 87 Execute Command ${SENSOR} FeedTemperatureSamplesFromRESD @${resd_path} 88 Execute Command ${SENSOR} FeedPressureSamplesFromRESD @${resd_path} 89 90 # Pressure will fluctuate a bit, since its calculation depends on the temperature 91 # these are very much dependent on a specific software build, because the samples need to be fed and read-out at strict intervals 92 # if the soft changes, frequency and start-time in RESD might need to change as well 93 Check Enviroment temperature=-21002.121744 pressure=29.999976 94 Check Enviroment temperature=-.306624 pressure=29.999993 95 Check Enviroment temperature=4998.472512 pressure=52.911995 96 Check Enviroment temperature=9999.921936 pressure=101.450998 97 Check Enviroment temperature=54999.615312 pressure=72.520999 98