|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Programmatically Determine Which Rio Code is on
Im sure there is probably some flag you could set that could then be read natively in your code, but something really simple might just be to put a text file on each roborio, each containing a unique identifier, like "Practice Setup" or "Competition Robot". Simply read this file in your robot code and you'll have which rio its running on.
|
|
#2
|
||||
|
||||
|
Re: Programmatically Determine Which Rio Code is on
Quote:
|
|
#3
|
||||
|
||||
|
Re: Programmatically Determine Which Rio Code is on
We've done this with a 'name' field in a WPILIB Preferences object, we've done it with a jumper on the bot (like Alan), and we have worked off the network MAC address.
In our experience, Alan's is the best/easiest way if you have the spare DIO (you don't need a programmer around if you move roboRIO XXXX from the test chassis to the competition chassis). We made sure the competition robot required NO jumpers, we used jumpers to disable stuff on the test/practice robots. Murphy says you will lose the jumper if you need it at competition. If you want to go from the MAC address (yes, there is a typo in one of the MACs): Code:
public boolean havePneumatics = false;
public void checkForPneumatics() {
havePneumatics = false;
try {
for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
NetworkInterface network = e.nextElement();
System.out.println("network " + network);
byte[] mac = network.getHardwareAddress();
if (mac != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
// Mule Board (wegscheid) MAC: "00-80-2F-17-EA-A4"
// MAC: "00-80-2F-17-EA-A5"
//Test bot (3630KOP) MAC: "00-80-2F-17-93-IE"
//Prototype (3620 Spare) MAC: "00-80-2F-17-EB-09"
// MAC: "00-80-2F-17-EB-08"
String macString = sb.toString();
System.out.println(" looking at MAC:" + macString);
if (macString.equals("00-80-2F-17-EB-09") || macString.equals("00-80-2F-17-EA-A4")) {
havePneumatics = true;
break;
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
System.out.println ("We have " + (havePneumatics ? "" : "no ") + "pneumatics");
}
|
|
#4
|
||||
|
||||
|
Re: Programmatically Determine Which Rio Code is on
Thanks for the replies, all good suggestions. I was trolling for an API that would return a serial number or some such built in identifier and the mac address would fill that bill. However, I am leaning toward the configuration file using a java properties object. That would offer the most flexibility and future expansion.
|
|
#5
|
||||
|
||||
|
Re: Programmatically Determine Which Rio Code is on
as I recall, the serial number is accessible from LV, but it didn't get exposed to the Java or C++ APIs.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|