Interrogating the CAN bus



In year’s past, we were able to interrogate the CAN bus for the presence or absence of devices, and skip creating WPILIB objects for them if they were not present. We did this to minimize the amount of spam on the console if someone was debugging a project, but the CAN devices were not present in the test chassis.

This thread has the details; much thanks for Omar at CTRE for that.

Unfortunately, it appears that the edu.wpi.first.wpilibj.can.CANJNI.FRCNetCommCANSessionMuxReceiveMessage method used to sniff the bus has disappeared. Is it there and I just missed it, or will I need to come up with a new way to do the interrogation (I see a lot of useful looking methods in edu.wpi.first.hal.CANAPIJNI, especially readCANPacketLatest).

If the latter, has anyone done anything like this so far this season?


It moved packages to


Thanks! I missed that when searching that package. Code builds now, need to test when I get to school.


When we implemented Phoenix Tuner/Diagnostics, I was thinking of your discovery use case.

An possibly-simpler alternative is to send a “getdevices” command to Phoenix Diag Server from the RIO. Basically open a tcp socket to http://localhost:1250/?action=getversion, and look at the response.

You can also do this off the rio with, or whatever hostname you want to use.

That will give you a formatted json list of all discovered devices. You can also do things like use the name of the Talon/Vic/Pigeon/CANifier to make decisions inside the RIO.


This is a good solution, provided we have Phoenix installed. It would be nice if it was integrated into WPILIBJ for those teams that just need it to check for the PDP or PCM…


Note that Phoenix has to be installed in the roborio, not the PC, for this strategy.
Which you are likely to do if you are using talons/victors/pigeons/canifiers anyway or setting-ids at all.

… I agree, it was not my call. I’d be happy if Phoenix was pre-installed for you.


Understood. Upon reflection, installing Phoenix is not an issue; we’ll want it installed on all our roboRIOs so we can assign IDs to Talons, etc.