photonvision
photonvision copied to clipboard
PhotonVision image does not correctly identify the network connection name on first boot
Describe the bug When booting from a fresh image on the OrangePi5, the photonvision settings page does not show the current network interface in the Network Manager Interface, but it is listed in the dropdown. The user must select it once and after that it is properly saved in settings.
Screenshots / Videos
Digging through the logs, on the very first boot, the check for network interfaces returns connection with empty connName
values.
Nov 17 06:45:11 ubuntu java[806]: [2023-11-17 06:45:11] [General - ShellExec] [DEBUG] Executing "nmcli -t -f GENERAL.CONNECTION,GENERAL.DEVICE,GENERAL.TYPE device show"
Nov 17 06:45:11 ubuntu java[806]: [2023-11-17 06:45:11] [General - ShellExec] [DEBUG] Got exit code 0
Nov 17 06:45:11 ubuntu java[806]: [2023-11-17 06:45:11] [General - NetworkUtils] [DEBUG] Found network interfaces:
Nov 17 06:45:11 ubuntu java[806]: [NMDeviceInfo [connName=, devName=eth0, nmType=NMTYPE_ETHERNET], NMDeviceInfo [connName=, devName=lo, nmType=NMTYPE_UNKNOWN]]
This causes the code to default to the name "Wired connection 1" which is used by RaspberryPi. It then uses the wrong interface name to try to configure DHCP:
Nov 17 06:45:12 photonvision java[806]: [2023-11-17 06:45:12] [General - ShellExec] [DEBUG] Executing "nmcli con mod "Wired connection 1" ipv4.method "auto" ipv6.method "disabled""
Nov 17 06:45:12 photonvision java[806]: [2023-11-17 06:45:12] [General - ShellExec] [DEBUG] Got exit code 10
Nov 17 06:45:12 photonvision java[806]: [2023-11-17 06:45:12] [General - NetworkManager] [ERROR] Exception while setting DHCP!
This fails, but because DHCP is the default, the network still uses DHCP to get the IP address.
A later event that causes it to scan the network interfaces again yields interfaces with valid connName
values:
Jan 23 03:03:42 photonvision java[806]: [2024-01-23 03:03:42] [General - ShellExec] [DEBUG] Executing "nmcli -t -f GENERAL.CONNECTION,GENERAL.DEVICE,GENERAL.TYPE device show"
Jan 23 03:03:42 photonvision java[806]: [2024-01-23 03:03:42] [General - ShellExec] [DEBUG] Got exit code 0
Jan 23 03:03:42 photonvision java[806]: [2024-01-23 03:03:42] [General - NetworkUtils] [DEBUG] Found network interfaces:
Jan 23 03:03:42 photonvision java[806]: [NMDeviceInfo [connName=netplan-eth0, devName=eth0, nmType=NMTYPE_ETHERNET], NMDeviceInfo [connName=, devName=lo, nmType=NMTYPE_UNKNOWN]]
Note the time change. The OPi was connected to my home router and must have synchronized the clock between the two events.
So, it seems like the first check for network interfaces happens too early and nmcli
doesn't return valid names, the second check is valid, but by then, PhotonVision has already selected a default value, which is wrong for the OPi.
Options to fix this:
- Special case the default network connection name for OPi
- Delay configuring the network until a valid interface name is returned by nmcli
- Update the default network interface when nmcli returns valid names and the current interface isn't in the list.
- Put a message in the UI asking users to select the correct network interface from the dropdown if it is empty.
Option 1 is simple and would address the problem for the OPi image, but it kicks the can down the road for other systems that may have the same problem. Option 2 would be more universal, but it isn't clear how long to delay and if it would stop loading photonvision while waiting for a valid connection name. Option 3 might cause photonvision to pick the wrong interface if multiple interfaces are present. Option 4 is consistent with how photonvision handles a missing team number currently, but it seems like something that shouldn't require user intervention.
I'm leaning toward Option 1 for now, but it seems like a hacky way to fix the problem. Are there other ways to fix this?