Jan Malek | 09e4204 | 2023-12-12 13:32:03 +0100 | [diff] [blame] | 1 | *** Variables *** |
| 2 | ${PLATFROM} platforms/cpus/stm32f4.repl |
| 3 | ${BIN} https://dl.antmicro.com/projects/renode/nucleo_f401re--zephyr-dht_polling.elf-s_651648-b107cceed1ebc23c894d983a6e519a6e494aee88 |
| 4 | ${UART} sysbus.usart2 |
| 5 | ${SENSOR} sysbus.i2c1.hs3001 |
| 6 | ${CSV2RESD} ${RENODETOOLS}/csv2resd/csv2resd.py |
| 7 | ${SAMPLES_CSV} ${CURDIR}/HS3001-samples.csv |
| 8 | |
| 9 | *** Keywords *** |
| 10 | Create Machine |
| 11 | Execute Command mach create |
| 12 | Execute Command machine LoadPlatformDescription @${PLATFROM} |
| 13 | Execute Command machine LoadPlatformDescriptionFromString "hs3001: Sensors.HS3001 @ i2c1 0x44" |
| 14 | Execute Command sysbus LoadELF @${BIN} |
| 15 | Create Terminal Tester ${UART} |
| 16 | |
| 17 | Set Enviroment |
| 18 | [Arguments] ${temperature}=0.00 ${humidity}=0.00 |
| 19 | Execute Command ${SENSOR} DefaultTemperature ${temperature} |
Jan Malek | 4f82da6 | 2024-01-12 09:34:38 +0100 | [diff] [blame] | 20 | Execute Command ${SENSOR} DefaultHumidity ${humidity} |
Jan Malek | 09e4204 | 2023-12-12 13:32:03 +0100 | [diff] [blame] | 21 | |
| 22 | Check Enviroment |
| 23 | [Arguments] ${temperature}=0.00 ${humidity}=0.00 |
| 24 | # The '\xc2\xb0' escape sequence is the unicode character: '°' |
| 25 | Wait For Line On Uart temp is ${temperature} \xc2\xb0C humidity is ${humidity} %RH |
| 26 | |
| 27 | Create RESD File |
| 28 | [Arguments] ${path} |
| 29 | ${resd_path}= Allocate Temporary File |
| 30 | ${args}= Catenate SEPARATOR=, |
| 31 | ... "--input", r"${path}" |
| 32 | ... "--map", "temperature:temp::0" |
Jan Malek | edddea6 | 2023-12-21 13:13:31 +0100 | [diff] [blame] | 33 | ... "--map", "humidity:humidity::0" |
Jan Malek | 09e4204 | 2023-12-12 13:32:03 +0100 | [diff] [blame] | 34 | ... "--start-time", "0" |
| 35 | ... "--frequency", "1" |
| 36 | ... r"${resd_path}" |
| 37 | Evaluate subprocess.run([sys.executable, "${CSV2RESD}", ${args}]) sys,subprocess |
| 38 | [Return] ${resd_path} |
| 39 | |
| 40 | *** Test Cases *** |
| 41 | Should Read Temperature And Humidity |
| 42 | Create Machine |
| 43 | |
| 44 | # Due the finite precision of the sensor we don't allways expect the exact same |
| 45 | # values as the ones that where set |
| 46 | |
| 47 | Check Enviroment temperature=0.00 humidity=0.00 |
| 48 | |
| 49 | Set Enviroment temperature=25.00 |
| 50 | Check Enviroment temperature=25.01 |
| 51 | |
| 52 | Set Enviroment humidity=50.00 |
| 53 | Check Enviroment humidity=50.10 |
| 54 | |
| 55 | Set Enviroment temperature=12.32 humidity=33.71 |
| 56 | Check Enviroment temperature=12.33 humidity=33.71 |
| 57 | |
| 58 | Set Enviroment temperature=-16.67 humidity=92.01 |
| 59 | Check Enviroment temperature=-16.-66 humidity=92.04 |
| 60 | |
| 61 | Set Enviroment temperature=88.02 humidity=8.50 |
| 62 | Check Enviroment temperature=88.08 humidity=8.50 |
| 63 | |
Jan Malek | edddea6 | 2023-12-21 13:13:31 +0100 | [diff] [blame] | 64 | Should Read Samples From RESD |
Jan Malek | 09e4204 | 2023-12-12 13:32:03 +0100 | [diff] [blame] | 65 | Create Machine |
| 66 | |
| 67 | ${resd_path}= Create RESD File ${SAMPLES_CSV} |
| 68 | Execute Command ${SENSOR} FeedTemperatureSamplesFromRESD @${resd_path} |
Jan Malek | edddea6 | 2023-12-21 13:13:31 +0100 | [diff] [blame] | 69 | Execute Command ${SENSOR} FeedHumiditySamplesFromRESD @${resd_path} |
| 70 | Set Enviroment temperature=25.56 humidity=30.39 |
Jan Malek | 09e4204 | 2023-12-12 13:32:03 +0100 | [diff] [blame] | 71 | |
Jan Malek | edddea6 | 2023-12-21 13:13:31 +0100 | [diff] [blame] | 72 | Check Enviroment temperature=-9.-99 humidity=0.00 |
| 73 | Check Enviroment temperature=0.00 humidity=20.00 |
| 74 | Check Enviroment temperature=4.99 humidity=40.05 |
| 75 | Check Enviroment temperature=10.00 humidity=60.01 |
| 76 | Check Enviroment temperature=15.00 humidity=80.31 |
| 77 | # Sensor should go back to the default values after the RESD file finishes |
| 78 | Check Enviroment temperature=25.56 humidity=30.39 |
| 79 | Check Enviroment temperature=25.56 humidity=30.39 |