RoboRIO USB on Linux

Mostly posting this for those in the future who are searching for how to use an NI (formerly the knights who called themselves National Instruments) RoboRIO (or RIO-esque) device on Linux over USB. I’m doing this on a raspberry pi running raspbian lite but it should work for Ubuntu and others.

When you plug the device in, it is actually found and comes up as a usb network adapter “usb0”. So the trick is that it is expecting DHCP so let’s give it DHCP in a reasonably clever way. First, use apt to install the isc-dhcp-server package.

Then we need to do some configuration:

/etc/dhcpcd.conf

# Example static IP configuration:
interface usb0
static ip_address=172.22.11.1/24

Next is /etc/default/isc-dhcp-server

INTERFACESv4="usb0"

Then we need to set the subnet info in /etc/dhcp/dhcpd.conf

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;

subnet 172.22.11.0 netmask 255.255.255.0 {
  range 172.22.11.2 172.22.11.2;
}

Then, here’s the clever part, let’s create some udev rules to start and stop our DHCP service when we plug and unplug in /etc/udev/rules.d/98-rio.rules

SUBSYSTEM=="net", ACTION=="add", ENV{ID_BUS}=="usb", ENV{ID_VENDOR_ID}=="3923", RUN="/sbin/ip addr add 172.22.11.1 dev %k", ENV{SYSTEMD_WANTS}="isc-dhcp-server.service"

ACTION=="remove", ENV{ID_BUS}=="usb", ENV{ID_MODEL}=="NI_roboRIO*", RUN="/usr/bin/systemctl stop isc-dhcp-server.service"

And then you have to run a couple of commands to restart udev:

udevadm control --reload
systemctl daemon-reload

This seems to be working very repeatably for me and I’m quite happy with it for what I need. Kind of cool. It’s possible I missed something so if you give it a try then let me know.

20 Likes

neat

1 Like

http://www.virtualroadside.com/blog/index.php/2015/01/03/connect-to-roborio-usb-on-linux/

1 Like

Thanks? It’s remarkably hard to find the info on this. I was actually surprised that it wasn’t documented by NI somewhere. They have recently added support for Ubuntu 18.04 and 20.04 as experimental for their Linux driver package.

I guess you could combine the two approaches and have a lighter weight DHCP solution. The udev rules make it a bit more repeatable for what I need.

I went to look at the linked python script and it appears the link from the blog is dead but it appears to be this script: https://github.com/javier-lopez/learn/blob/master/python/tools/simple-dhcpd

I like the udev script, it’s a better solution for this than what I had done.

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.