Hardware beep with ioctl write to /dev/console

Hello and thanks for a great project.

I’ve successfully installed BalenaOS Intel NUC image to a Moxa Embedded computer (https://www.moxa.com/en/products/industrial-computing/x86-computers/v2201-series).

Most of the features work out of the box, but right now I’m trying to get the hardware to make a beep sound. Using this code http://www.johnath.com/beep/ and have ported it to my own golang project. When running the binary on the standard moxa os (some debian variant) the hardware makes a beep, but nothing happens when I run this on BalenaOS.

Looking at the code, it tries to write to /dev/console or /dev/tty0 with some ioctl function. Are these files wired differently in Balena?

Regards
Bernt-Johan

Hi @berntjb, you may try adding UDEV=on in the Dockerfile.template file of your application.

I suggest that you try first a single container application (without a docker-compose.yml file). (https://www.balena.io/docs/learn/develop/hardware/#interact-with-hardware)

If this still does not work, maybe there is a kernel module which needs to be enabled in the host OS.

Please let us know if you have any questions.

Thanks,
Zahari

Hello @majorz, thank you so much for the reply.

I’m actually running this on the host-os. I copied the binaries to /mnt/data and ran them over ssh.

Testing a bit more, it looks like this kernel module is needed.

Is there a way to get this into the official build?

Regards
Bernt-Johan

So I built the kernel module pcspkr and loaded it in the host-os and the beep started working.

How is the best way to get this permanently into the host-os? Could I make some scripts that reside inside the /mnt/data folder that gets run on boot? Will this be there after a OS update from the Balena Cloud?

Regards
Bernt-Johan

This repo may be of some help: https://github.com/balena-io-projects/kernel-module-build, I think you should be able to use this as an example to get this running.