Go to Post FIRST is not all about the competitions. FIRST is about what you learn to get to wherever you got to, whether that be first seed or last. - StephLee [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-17-2012, 01:25 AM
josh.pruim josh.pruim is offline
Registered User
FRC #4014
Team Role: Programmer
 
Join Date: Aug 2012
Rookie Year: 2011
Location: United States
Posts: 36
josh.pruim will become famous soon enough
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

Last edited by josh.pruim : 08-17-2012 at 01:28 AM. Reason: Added Github Link
Reply With Quote
  #2   Spotlight this post!  
Unread 08-17-2012, 11:35 AM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Determining if code is on cRIO

Quote:
Originally Posted by josh.pruim View Post
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
Reply With Quote
  #3   Spotlight this post!  
Unread 08-17-2012, 04:41 PM
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-17-2012, 07:14 PM
josh.pruim josh.pruim is offline
Registered User
FRC #4014
Team Role: Programmer
 
Join Date: Aug 2012
Rookie Year: 2011
Location: United States
Posts: 36
josh.pruim will become famous soon enough
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 08-17-2012, 07:19 PM
josh.pruim josh.pruim is offline
Registered User
FRC #4014
Team Role: Programmer
 
Join Date: Aug 2012
Rookie Year: 2011
Location: United States
Posts: 36
josh.pruim will become famous soon enough
Re: Determining if code is on cRIO

Quote:
Originally Posted by Joe Ross View Post
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.
Reply With Quote
Reply


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 07:25 AM.

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