[SOLVED] Howto use irda / infrared computers with modern linux (2021)

992 views
Skip to first unread message

Andrea Lusuardi

unread,
Jul 21, 2021, 9:05:00 PM7/21/21
to Subsurface Divelog
Greetings,
what follows is the result of at least 8-10 hours of googling, reading documentation,
reading source code, build scripts, trial, errors, mental breakdowns and so on.
I am a computer programmer turned scuba instructor, so i am lucky enough to have some
expertise in both worlds. I have an Uwatec Aladin 2g and an Uwatec Aladin Tec 3g that
i use for courses and as a depth gauge/timer during tech dives and
some spare time, so i want to give back to the community by writing how to get
subsurface to work on the latest ubuntu 20.10 (and i suppose this might work
on the 21.04) with irda having been removed from the kernel. The instructions
below work as well on a recent Debian host, like the one i use for work, with
minimal changes. I'm assuming that if you run debian you can adapt this
stuff pretty easily from ubuntu, so i'm going to cover the ubuntu part of it.
I also know that the irda stack got removed from windows as well, so this might
literally be the only way to download the dives if you have an irda computer.
The shearwater perdix that use when tech diving and the petrel that i have on
my rebreather work with bluetooth and, while that is another world of pain,
are outside the scope of this guide. They are starting to have problems after
the release of version 5 of subsurface as well, but with some wiggling i make
them work, i might do another writeup in the future about them.

Get ready, this is going to get _ugly_.

What we are going to do:
1 - build the out-of-tree irda stack for the current kernel (since kernel people
decided that if you have any irda devices after 2018 you are out of luck
and have to throw them out and buy new stuff. nice, thanks i hate it)
2 - build subsurface from sources, tricking it into thinking it's still 2018
3 - install the irda-utils from an ubuntu package, since that has been dropped as well
4 - get your user set up
5 - attach the usb irda device
6 - FINALLY download your dives from your perfectly working but no longer supported dive computer

First of all a word of WARNING: this will change stuff on your computer, it might break things,
kill your cat, demagnetize your credit card, make all your mouthpieces fall of the regulator,
make your o2 sensors be non-linear or punch a hole in your drysuit. You have been warned,
you are following this ""guide"" at your own risk and peril. Also, i am not a native english speaker,
so please bear with me.

I had bought, back when we still thought deep air was a good idea and were convinced that people
and companies were going to support the stuff they were developing or selling for a reasonable time,
an usb IrDA adapter off ebay for like 10 euros, this is its usb id:

Bus 001 Device 007: ID 9710:7780 MosChip Semiconductor MCS7780 4Mbps Fast IrDA Adapter

It uses the MCS7780 chipset, support for which got dropped with the killing of the in-tree
irda stack back in kernel 4.17 (if i remember correctly,  i do not want to look for it as my
hatred runs deeper than my dives). What follows might work for other dive computers and/or other
usb irda adapters but i have not tested them. Good luck.

1 Building the out of tree irda stack

Thanks to some HERO we still have the irda out of tree stack buildable on recent kernels, I am currently
running on

Linux bugolo 5.8.0-55-generic #62-Ubuntu SMP Tue Jun 1 08:21:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

, using the repo at


I cannot thank this person enough. Should they ever read this they have at least a 6-pack of beers or
ther equivalent intoxicant on me, anytime, no questions asked.

Follow the instruction on the readme to get the kernel modules built. Mainly:

- make sure the kernel headers for your current kernel are installed (it's relatively straightforward,
google it or install the linux-headers- package for your current kernel)
- clone the repo
- cd into it
- run autoconf
- run ./configure
- run sudo dkms add <where you cloned the repo>/src
- run the dkms incantation in the readme
- pray to all the elditch gods that are slumbering at the edges of our reality that your chipset is supported

Connect the usb irda adapter and you should see stuff like

[18303.117404] usb 1-3: New USB device found, idVendor=9710, idProduct=7780, bcdDevice= 0.01

in the dmesg and then the

5: irda0: <NOARP,UP,LOWER_UP> mtu 2048 qdisc fq_codel state UNKNOWN group default qlen 8
    link/irda 3f:f0:ff:f0 brd ff:ff:ff:ff

irda0 device should pop up in "ip a".
Assuming Those Who Shall Not Be Named have been kind to you, move to step 2

2 Build subsurface from sources, 1999-faking-2018 style

You see, in order for subsurface, or to be precise for the bundled libdivecomputer that is used
by subsurface to connect to the dive computer as the name suggests, to access an irda device you need
to trick it into thinking that you are running on a system that actually supports irda. Cool.
This is done in the depths of the compilation hell - more on this later - by checking that the
"irda.h" file is present in the linux kernel include directory (system wide? kernel wide? do i care?).
To do this just be a lazy person like i was and

sudo ln -s /path/to/the/out/of/tree/irda/src/include/linux/irda.h /usr/include/linux

This will create the file and make the configure step of libdivecomputer during the build
of subsurface think you have irda and print the magical

  Transports:

    Serial    : yes
    USB       : yes
    USBHID    : yes
    IrDA      : yes
    Bluetooth : yes
    BLE       : no

line in the build.log during the build. IF YOU DO NOT SEE THAT YES DO NOT PROCEED, AS YOU WILL
GO INSANE AND WASTE YOUR LIFE INSTEAD OF DIVING. HEED MY WORDS.

Once this link is done, build subsurface from sources, following the INSTALL file.
Just to summarize:
- create a dir called unholy_abomination or similar appropriate name
- cd into it
- clone the subsurface repo
- cd into subsurface
- git checkout v5.0.2 or whatever version you want
- install all the libraries and packages as specified in the INSTALL file for your distro
- cd .. (very important)
- run ./subsurface/scripts/build.sh
- watch it fill up the disk (the whole thing on my machine is 2.4 GB AH AH AH) and print
  the full text of the invocation of cthulhu to screen
- tremble in fear as you check that the above "IrDA     : yes" line appears
- hope that the build succeeds

You should now be able to cd subsurface/build/ and ./subsurface.

3 Install the irda-utils from an ubuntu package

Of course, since the stack got dropped, the userspace tools have been dropped as well.
Fear not, we can simply (?) open


and download the latest version that has them. Once you have the deb simply

sudo dpkg -i the_name_of_the_deb.deb

and _pray_ there are no missing dependencies if you are reading this in the future.

4 - Make sure you user is set up

Run the groups command and make sure the "dialout" and "tty" groups appear in the list
that gets printed, if not just

sudo adduser <your_user> <the_missing_group>

and then, just out of spite (and cause otherwise it does not work), reboot your machine
(you can actually just su to your own user, but it is then limited to that shell
and other stuff and it's easier to just reboot). This should take care of fixing
the permissions on the /dev that gets created. Do not be tempted by the "i can run
this as root and bypass the problem" siren. It lies.

5 - Attaching the usb irda device

You are almost there. You are about to finish deco, get out of the water,
take off the drysuit, shower aind go to eat. Be strong. This might be the
trickiest part of it all.

You now need to make it so that the irda0 device we have seen in step 1 gets somehow
MASSAGED into being a /dev/ttyS<something> device. Remove the usb adapter if it was
plugged in - no idea why, it just worked only when i did it so for your sanity's sake
do it - and plug it in again and run

sudo irattach irda0 -s

hoping the device gets correctly setup. If this fails i literally have no help for
you, install windows or use your smartphone. I am so sorry.

6 - Finally download your dives from your perfectly working but no longer supported dive computer

It's time. Go to the directory where you launched subsurface, turn the dive computer on,
align the ports and the stars, click import from dive computer, select the make and model,
click download and if the gods have smiled on your effort you will be able to download the dives.

I hope this helps someone save a bit of time, use an old computer and spare a bit of sanity.
Good luck and safe dives.
saludos


Reply all
Reply to author
Forward
0 new messages