Go to Post The kick-off is your opportunity to finally open the REALLY BIG box that has been sitting under the tree. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 29-07-2015, 11:00
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Smile Detecting if the code runs from the PC or the RoboRIO

I have some code that I want to run only when working from the PC (connected with an Ethernet cable) for debugging purposes.
Is there a way for the code to detect if the code runs from the PC or from the RoboRIO itself?
That way I won't need to disable this code block whenever I download it to the robot.
Thank you!
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew
Reply With Quote
  #2   Spotlight this post!  
Unread 29-07-2015, 13:04
Jonathan L. Jonathan L. is offline
Programmer alumnus, mentor, and CSA
FRC #1094 (Channel Cats)
 
Join Date: Jan 2013
Rookie Year: 2011
Location: St. Louis MO
Posts: 78
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
Re: Detecting if the code runs from the PC or the RoboRIO

I have not tested this with a FRC robot yet but I think this is what you're looking for. See this video at 18 min 15 sec and 21 min 30 sec. http://www.ni.com/webcast/3798/en/

The Conditional Disable Structure...
Reply With Quote
  #3   Spotlight this post!  
Unread 29-07-2015, 13:51
Ari423's Avatar
Ari423 Ari423 is offline
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 634
Ari423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud of
Re: Detecting if the code runs from the PC or the RoboRIO

I haven't ever done it, but I imagine it can be done using some kind of property node. (to LabVIEW documentation!) I would highly recommend removing any code only running in debugging mode from the final robot project to avoid any chance of the robot thinking it is in debug mode and to keep the robot from having to constantly check whether or not it is in debug mode.

Just my $0.02
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)


Reply With Quote
  #4   Spotlight this post!  
Unread 29-07-2015, 14:56
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Detecting if the code runs from the PC or the RoboRIO

Quote:
Originally Posted by Jonathan L. View Post
I have not tested this with a FRC robot yet but I think this is what you're looking for. See this video at 18 min 15 sec and 21 min 30 sec. http://www.ni.com/webcast/3798/en/

The Conditional Disable Structure...
That looks great! I will try it on the robot the next time I'll have a chance

Quote:
Originally Posted by Ari423 View Post
I haven't ever done it, but I imagine it can be done using some kind of property node. (to LabVIEW documentation!) I would highly recommend removing any code only running in debugging mode from the final robot project to avoid any chance of the robot thinking it is in debug mode and to keep the robot from having to constantly check whether or not it is in debug mode.

Just my $0.02
That's a good point, but I think that the structure that was suggested by Jonathan makes sure that whatever that is in the block doesn't even get compiled so there are no constant checking. (I hope )
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew
Reply With Quote
  #5   Spotlight this post!  
Unread 29-07-2015, 15:12
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Detecting if the code runs from the PC or the RoboRIO

Quote:
Originally Posted by Jonathan L. View Post
I have not tested this with a FRC robot yet but I think this is what you're looking for. See this video at 18 min 15 sec and 21 min 30 sec. http://www.ni.com/webcast/3798/en/

The Conditional Disable Structure...
Unfortunately I do not think the conditional disable structure will work the way that you want without some extra effort.

The only time RUN_TIME_ENGINE is FALSE will be if you are running the code on your host machine. This works if you are using the simulator vs the actual robot, but once you run it on the robot as you describe it will be TRUE. Target_Type and OS will give you the same issue.

You can create a conditional that is project wide, and manually change it when you build, but that is tedious and more importantly is error prone.

You may be able to play around with the build specification, maybe with the pre/post build actions combined with the project wide build specification, but this is not something I have never tried.

You may be better of with the suggestion from Ari423 unless you have a good reason to prevent the code block from compiling in the first place.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #6   Spotlight this post!  
Unread 29-07-2015, 15:30
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Detecting if the code runs from the PC or the RoboRIO

If you are asking about simulated versus running on the roboRIO, the Conditional Disable Structure is what you are looking for. An example of how to use it is shown in this VI vi.lib\Rock Robotics\SystemInterfaces\NetworkCommunication\Net Comm_UnloadCPPStartupProgram.vi

If you want to know if a debugging host is connected, I believe you want to use a Property Node to read the App.UserInterfaceAvailable property. Read the help and I think you will see that it does what you want. If not, please explain more of what you are looking for.

Greg McKaskle
Reply With Quote
  #7   Spotlight this post!  
Unread 29-07-2015, 15:34
Ari423's Avatar
Ari423 Ari423 is offline
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 634
Ari423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud of
Re: Detecting if the code runs from the PC or the RoboRIO

Quote:
Originally Posted by wt200999 View Post
The only time RUN_TIME_ENGINE is FALSE will be if you are running the code on your host machine. This works if you are using the simulator vs the actual robot, but once you run it on the robot as you describe it will be TRUE. Target_Type and OS will give you the same issue.
I just had an idea. When you get the file path of Robot Main in Robot Main, if it is built and running in the robot project the second to last string in the file path will be projectName.exe, whereas if you were running it in debug mode (manually running Robot Main) the second to last string in the file path will be the folder the project is in. You should be able to get the file path, strip it twice, and search the second stripped string for ".exe". If you are running a build the index will be greater than 0 (it exists somewhere in the string). If it is running in debug mode, the index will be -1 (search string isn't in source string). You can then save this bool as a global, carry it into teleop and/or periodic, or do whatever you want with it. Let me know if this works.

EDIT: I think this is what you are looking for without using any complicated property nodes. There may be other ways to do the same thing using property nodes or otherwise, and you should feel free to use whichever you feel is easier. My original suggestion about removing this code from the final project still stands.
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)



Last edited by Ari423 : 29-07-2015 at 15:37.
Reply With Quote
  #8   Spotlight this post!  
Unread 30-07-2015, 07:33
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Quote:
Originally Posted by Greg McKaskle View Post
If you want to know if a debugging host is connected, I believe you want to use a Property Node to read the App.UserInterfaceAvailable property. Read the help and I think you will see that it does what you want. If not, please explain more of what you are looking for.

Greg McKaskle
This is what I'm looking for, I'll try it.
Quote:
Originally Posted by Ari423 View Post
I just had an idea. When you get the file path of Robot Main in Robot Main, if it is built and running in the robot project the second to last string in the file path will be projectName.exe, whereas if you were running it in debug mode (manually running Robot Main) the second to last string in the file path will be the folder the project is in. You should be able to get the file path, strip it twice, and search the second stripped string for ".exe". If you are running a build the index will be greater than 0 (it exists somewhere in the string). If it is running in debug mode, the index will be -1 (search string isn't in source string). You can then save this bool as a global, carry it into teleop and/or periodic, or do whatever you want with it. Let me know if this works.

EDIT: I think this is what you are looking for without using any complicated property nodes. There may be other ways to do the same thing using property nodes or otherwise, and you should feel free to use whichever you feel is easier. My original suggestion about removing this code from the final project still stands.
I want to try your method but I don't have enough experience with LabVIEW strings. Can you post here the code that does what you have explained?
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew
Reply With Quote
  #9   Spotlight this post!  
Unread 02-08-2015, 17:03
Ari423's Avatar
Ari423 Ari423 is offline
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 634
Ari423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud ofAri423 has much to be proud of
Re: Detecting if the code runs from the PC or the RoboRIO

Quote:
Originally Posted by GuyM142 View Post
I want to try your method but I don't have enough experience with LabVIEW strings. Can you post here the code that does what you have explained?
Sorry it has taken me so long to get back to you, I haven't had access to a computer with LabVIEW on it.

Here is the sample code (you can drag and drop it into a vi and it will automatically render as LabVIEW code):
Click image for larger version

Name:	tmp.png
Views:	19
Size:	12.7 KB
ID:	19245

It should return true if it is running in debug mode and false if it is running as part of a build. Let me know how it works out.
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)


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 21:28.

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