I have a port 0x80 BIOS post debug card installed in a PCI slot. I want to use it purposefully after booting by having the CPU temperature displayed on the card. The address takes one byte and is displayed in HEX. How do I convert the two digit decimal Celsius temperature values into a single byte for writing to the card? Remember, the display is HEX, so the byte output needs to be converted as such into something that is readable in base 10, although just getting the byte would be helpful at this point. Googling is driving me nuts.

e.g. echo d | dd of=/dev/port bs=1 count=1 seek=128 gives a display of 64, the ASCII byte for the letter d.

cat /sys/class/hwmon/hwmon0/temp2_input | cut -c1-2

gives the CPU temperature in °C in two bytes of ASCII: 58

A bash command string would be preferable as it could be called with a cron job or systemd timers.


BIOS debug card


You want to convert the temperature, read as a decimal value, into a character corresponding to the hexadecimal value which when displayed, reads the same as the temperature...

The request sounds more complex than it really is; printf can be used to print a character corresponding to a given character code:

$ printf "\x64\n"

So you’ll get the result you’re after with

printf "\x$(cut -c1-2 < /sys/class/hwmon/hwmon0/temp2_input)" | dd of=/dev/port bs=1 count=1 seek=128

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.