|
| 1 | +*** Settings *** |
| 2 | +Resource ../resources/common.robot |
| 3 | +Library Cumulocity |
| 4 | + |
| 5 | +Suite Setup Set Main Device |
| 6 | + |
| 7 | +*** Variables *** |
| 8 | + |
| 9 | +${EXPECTED_BAUD_RATE} 9600 |
| 10 | +${EXPECTED_STOP_BITS} 2 |
| 11 | +${EXPECTED_PARITY} N |
| 12 | +${EXPECTED_DATA_BITS} 8 |
| 13 | + |
| 14 | + |
| 15 | +*** Test Cases *** |
| 16 | +Set values via c8y_SerialConfiguration Operation |
| 17 | + ${operation}= Update Serial Configuration Settings |
| 18 | + ... baud_rate=${EXPECTED_BAUD_RATE} |
| 19 | + ... stop_bits=${EXPECTED_STOP_BITS} |
| 20 | + ... parity=${EXPECTED_PARITY} |
| 21 | + ... data_bits=${EXPECTED_DATA_BITS} |
| 22 | + Cumulocity.Operation Should Be SUCCESSFUL ${operation} |
| 23 | + |
| 24 | +Serial configuration should be updated for the Device |
| 25 | + ${mo}= Managed Object Should Have Fragment Values |
| 26 | + ... c8y_SerialConfiguration.baudRate\=${EXPECTED_BAUD_RATE} |
| 27 | + ... c8y_SerialConfiguration.stopBits\=${EXPECTED_STOP_BITS} |
| 28 | + ... c8y_SerialConfiguration.parity\=${EXPECTED_PARITY} |
| 29 | + ... c8y_SerialConfiguration.dataBits\=${EXPECTED_DATA_BITS} |
| 30 | + |
| 31 | + ${baudrate}= Set Variable ${mo}[c8y_SerialConfiguration][baudRate] |
| 32 | + ${stopbits}= Set Variable ${mo}[c8y_SerialConfiguration][stopBits] |
| 33 | + ${parity}= Set Variable ${mo}[c8y_SerialConfiguration][parity] |
| 34 | + ${databits}= Set Variable ${mo}[c8y_SerialConfiguration][dataBits] |
| 35 | + |
| 36 | + Should Be Equal As Numbers ${baudrate} ${EXPECTED_BAUD_RATE} |
| 37 | + Should Be Equal As Numbers ${stopbits} ${EXPECTED_STOP_BITS} |
| 38 | + Should Be Equal As Strings ${parity} ${EXPECTED_PARITY} |
| 39 | + Should Be Equal As Numbers ${databits} ${EXPECTED_DATA_BITS} |
| 40 | + |
| 41 | +Serial configuration should be updated on the Device |
| 42 | + ${shell_operation}= Execute Shell Command cat /etc/tedge/plugins/modbus/modbus.toml |
| 43 | + ${shell_operation}= Cumulocity.Operation Should Be SUCCESSFUL ${shell_operation} |
| 44 | + |
| 45 | + ${result_text}= Set Variable ${shell_operation}[c8y_Command][result] |
| 46 | + |
| 47 | + Should Contain ${result_text} baudrate = ${EXPECTED_BAUD_RATE} |
| 48 | + Should Contain ${result_text} stopbits = ${EXPECTED_STOP_BITS} |
| 49 | + Should Contain ${result_text} parity = "${EXPECTED_PARITY}" |
| 50 | + Should Contain ${result_text} databits = ${EXPECTED_DATA_BITS} |
| 51 | + |
| 52 | +*** Keywords *** |
| 53 | + |
| 54 | +Update Serial Configuration Settings |
| 55 | + [Arguments] ${baud_rate} ${stop_bits} ${parity} ${data_bits} |
| 56 | + ${operation}= Cumulocity.Create Operation |
| 57 | + ... fragments={"c8y_SerialConfiguration": {"baudRate":${baud_rate},"stopBits":${stop_bits},"parity":"${parity}","dataBits":${data_bits}}} |
| 58 | + RETURN ${operation} |
0 commit comments