Skip to content

best way to programatically test if the module is installed? #66

Open
@AndySchroder

Description

@AndySchroder

I'm trying to figure out a clean way to detect if can-isotp is installed before trying to use it (and potentially getting an error that is not clear if it has to do with a missing module or some other problem).

On first boot

lsmod|grep can_isotp

yields nothing. However, after running

isotprecv -s 123 -d 321 -l can0

I get

$ lsmod|grep can_isotp
can_isotp              32768  0
can                    28672  1 can_isotp
$

So, it looks the the module is loaded automatically on use. I can't figure out how the kernel decides to load modules automatically when needed. Is there a clean way to trigger this to happen manually? I can run sudo modprobe can_isotp, but I don't want to do that as root. Somehow the isotprecv command can do it without being root.

I know I could run

$ uname -r
5.15.0-1053-raspi
$

to see if it has a modern kernel installed, but I don't think this is a good approach because it seems complicated to parse the kernel version string above with so many variants. Also, people can manually install the kernel module, or have a custom kernel that doesn't have the module installed.

Any suggestions?

I'll be doing this in python by the way, but a solution that works in bash should be general enough for me to port to python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions