Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Determining if code is on cRIO (http://www.chiefdelphi.com/forums/showthread.php?t=107830)

josh.pruim 17-08-2012 01:25

Determining if code is on cRIO
 
Hello, I was wondering if there is a good way to determine whether or not the code is running on the cRIO. Since I do not have the cRIO with me, I wrote an if statement that I am guessing would work.

It will return true if it is on the cRIO, false if on a PC/Mac.

Code:

//Lines 2-8 on LimitSwitches/NICompactRIOToolkit.java
public boolean iscRIO(){
                if(System.getProperty("os.arch").contains("amd64") || System.getProperty("os.arch").contains("x86_64") || System.getProperty("os.arch").contains("x86") || System.getProperty("os.arch").contains("i386")){
                        return false;
                }else{
                        return true;
                }
        }

EDIT: Code is on GitHub, this specific class is here
https://github.com/itguy51/RobotClas...IOToolkit.java


Side note: If anyone knows where to get the WPILibJ libraries as a binary, [.jar or otherwise], that would be very helpful

Joe Ross 17-08-2012 11:35

Re: Determining if code is on cRIO
 
Quote:

Originally Posted by josh.pruim (Post 1181965)
Side note: If anyone knows where to get the WPILibJ libraries as a binary, [.jar or otherwise], that would be very helpful

On my computer it's in C:\Users\<UserName>\sunspotfrcsdk\lib\WPILibJ\suit e

Ginto8 17-08-2012 16:41

Re: Determining if code is on cRIO
 
I don't see why this would be helpful. Code I'd write to run on the cRio and code I'd write to run on a PC would be different in big enough ways that I don't think I'd ever need to check whether the code is on the cRio from the program itself. Not only are the Java versions different when comparing the cRio to the PC (Java ME vs Java SE), most of the libraries that work on one would not work on the other (SmartDashboard and javacv would never be able to run on the cRio, and WPILibJ uses too much direct hardware access to be usable on a PC). I think a better choice than having a runtime check for whether or not the program is running on the cRio would be to simply write the program for the platform it's being deployed on.

josh.pruim 17-08-2012 19:14

Re: Determining if code is on cRIO
 
This code is not to be a full-out Robot program, it is a set of tools, sort of an extension, consisting of 'drivers' for Limit Switches and other third-party, non-KOP parts. I am writing it so that it runs on a PC and a cRIO for the sake that it's also going to be used in teaching how to write for the bot. I could build an x86 version, and a cRIO version, but if I can avoid that at all, it would be great.

josh.pruim 17-08-2012 19:19

Re: Determining if code is on cRIO
 
Quote:

Originally Posted by Joe Ross (Post 1181984)
On my computer it's in C:\Users\<UserName>\sunspotfrcsdk\lib\WPILibJ\suit e

Thank you VERY much, I knew they would be local, but I had no idea where to look.


All times are GMT -5. The time now is 09:14.

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