Detecting hard reboot

Hello,

I am using QNX on processor MPC8349. I want to detect hard reboot i.e weather the device rebooted due to power cycle(Hard reboot) or a shutdown was initiated from software(soft reboot). I tried checking Power reset status register but value read is 0. I believe QNX might be using there register for some purpose(don’t know what) and as this register is Read/Write, the value is updated as 0.

Is there is any method available in qnx to detect type of reboot.

Ashi Gupta

You could include a simple command in the boot script to delete a certain file in persistent storage, like /home/user/cleanshutdown. Later, when you initiate a software-based shutdown command, you include a command like touch /home/user/cleanshutdown. On reboot, you can check if the file is present - if it is, it was a software-based shutdown. You can then delete the file, so it can be re-created on the next shutdown. If the next shutdown is a hard power-cycle, the file will not be there. On reboot, you will find it’s not there so it must have been a hard reboot.

HTH,

  • Malte

Thanx Malte…as i was not able to read power registers, i followed the same approach.