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 *** 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} Temperature ${temperature} 20 Execute Command ${SENSOR} Humidity ${humidity} 21 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" 33 ... "--map", "humidity:humidity::0" 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 *** 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 64Should Read Samples From RESD 65 Create Machine 66 67 ${resd_path}= Create RESD File ${SAMPLES_CSV} 68 # Explicitly set temperature and humidity before loading RESD. 69 # Sensor will default to these values after RESD stream ends. 70 Set Enviroment temperature=25.56 humidity=30.39 71 Execute Command ${SENSOR} FeedTemperatureSamplesFromRESD @${resd_path} 72 Execute Command ${SENSOR} FeedHumiditySamplesFromRESD @${resd_path} 73 74 Check Enviroment temperature=-9.-99 humidity=0.00 75 Check Enviroment temperature=0.00 humidity=20.00 76 Check Enviroment temperature=4.99 humidity=40.05 77 Check Enviroment temperature=10.00 humidity=60.01 78 Check Enviroment temperature=15.00 humidity=80.31 79 # Sensor should go back to the default values after the RESD file finishes 80 Check Enviroment temperature=25.56 humidity=30.39 81 Check Enviroment temperature=25.56 humidity=30.39 82