blob: 1ee8a60d417e3080b55322480c92c21b185a09c9 [file] [log] [blame]
Jan Malek09e42042023-12-12 13:32:03 +01001*** 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 ***
10Create 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
17Set Enviroment
18 [Arguments] ${temperature}=0.00 ${humidity}=0.00
19 Execute Command ${SENSOR} DefaultTemperature ${temperature}
Jan Malek4f82da62024-01-12 09:34:38 +010020 Execute Command ${SENSOR} DefaultHumidity ${humidity}
Jan Malek09e42042023-12-12 13:32:03 +010021
22Check 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
27Create 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 Malekedddea62023-12-21 13:13:31 +010033 ... "--map", "humidity:humidity::0"
Jan Malek09e42042023-12-12 13:32:03 +010034 ... "--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 ***
41Should 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 Malekedddea62023-12-21 13:13:31 +010064Should Read Samples From RESD
Jan Malek09e42042023-12-12 13:32:03 +010065 Create Machine
66
67 ${resd_path}= Create RESD File ${SAMPLES_CSV}
68 Execute Command ${SENSOR} FeedTemperatureSamplesFromRESD @${resd_path}
Jan Malekedddea62023-12-21 13:13:31 +010069 Execute Command ${SENSOR} FeedHumiditySamplesFromRESD @${resd_path}
70 Set Enviroment temperature=25.56 humidity=30.39
Jan Malek09e42042023-12-12 13:32:03 +010071
Jan Malekedddea62023-12-21 13:13:31 +010072 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