Go to Post You don't see teams plastering the arena with signs saying "Show your spirit!" or "Be creative in your robot design!" or "Be sure to be innovative in your control!" - Mr. Van [more]
Home
Go Back   Chief Delphi > Technical > Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 11-03-2015, 09:16
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
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");
                
    }
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi