How to delay an update?


After downloading, the software is updated immediately. But, I am tasked to check if the ECU is currently at IDLE state before updating the software. Is there a way for me to delay the update even though the artifact is already downloaded? Which part of the mender codes I can put the checking of the ECU’s state?

Please advise. Thank you!

Kind regards,

You should look into state scripts. You can pause inside the scripts at certain points. Be aware of the script timeout though.

For more advanced usage, you can also look into the Update Management API, where the update can be controlled programmatically over DBus.

Hi @kacf ! Thank you for your reply.

I created the following Download_Enter_00 script. It is called but the state does not transition to the next state even after the subscribe_secc function exits. Downloading status is stuck at 69%. Am I missing something?


echo "$(mender -show-artifact): $(basename "$0") was called!" >&2

# This script subscribes to a MQTT topic using mosquitto_sub.
# On each message received, you can execute whatever you want.

# 14 = FW_UpdateSECC
# 5 = FW_UpdateNeeded_SECC

function publish_secc()
	echo "$(mender -show-artifact): $(basename "$0") - publishing FW_UpdateNeeded_SECC" >&2
	while true
		mosquitto_pub -h localhost -t 'FW_UpdateSECC' -m "{\"FW_UpdateNeeded\":5}"
		echo "{ FW_UpdateNeeded:5 }"

function subscribe_secc()
	echo "$(mender -show-artifact): $(basename "$0") - waiting for FW_Command = 14" >&2
	mosquitto_sub -h localhost -t 'FW_CommandSECC' | while read -r payload
		# Here is the callback to execute whenever you receive a message:
		fwCmd=$(echo "Rx MQTT: ${payload}" | grep -o -E '[0-9]+')		
		if [ $fwCmd -eq 14 ]
			kill -9 $(cat /mnt/hero-secc/userdata/
			echo "$(mender -show-artifact): $(basename "$0") - FW_Command = ${fwCmd}" >&2

publish_secc &
echo $! > /mnt/hero-secc/userdata/


exit 0

Even though it exits, are you sure all sub processes have also exited, including the background execution and all mosquitto_sub processes? State scripts are executed in their own process group, so I think all sub processes have to exit, not just the mother process.

Thanks @kacf ! mosquitto_sub is not killed. Everything works fine now. Thanks!