0

We want to put a computer (probably an industrial computer) with Linux on a system powered by a battery. The computer will be configured to power on when the battery is powered-on The battery has a BMS, a button and some pins and/or a serial port that can be used to power it on or off.

If I want to shutdown the battery from the computer, for example by sending the signal to the battery from a serial port, how can I do? Do I have to create a kernel module to replace the usual ACPI shutdown? Or can I just setup a script that does a sync, remount the file-system in read-only and send the signal to the battery?

I'm sure there is a best-practice and a lot of examples but I can't find them.

1 Answer 1

2

Put a bash script into /usr/lib/systemd/system-shutdown which will do all you want including sending a message to a COM (serial) port. Scripts in these directory are executed at the very last, i.e. when all the filesystems have been umounted and the root fs has been remounted read only. If you want to run it earlier, please refer to How to run a script with systemd right before shutdown?

There are multiple ways of working with a serial port, so choose what works for you: How to send data to a serial port and see any answer?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .