05-04-2012 10:50 AM
I'm doing my first cRIO development, haven't taken any RT or RIO courses, but did look through the training material and have searched through examples and what not. Feel like I got a pretty good grasp of things and even figured out how to use arrays on the FPGA side of things.
My question is more of a style question, I guess, but does it matter what I do on the right side of my loops? I mean, style-wise, I know closing references, killing queues, and flushing memory is just plain good code. But in an RT or RIO environment, specifically, a unit that's going to be placed in the field transfering data back to a host with no RIO-specific UI, the loop is never going to stop, unless it gets powered down, and then it really doesn't matter what's on the right side of the loop as it won't make it there.
Am I wrong here? Should proper style prevail, just for good coding habits, or does it just act as useless clutter considering the fact that it will never be called?
-Ian
05-07-2012 07:29 PM
Hi Ian,
When working with RT targets, good coding habits such as closing references, queues, and clearing memory provide safe exit strategies when you exit the RT application. This is partly the reason we urge programmers to use a Stop control instead of "aborting" to exit an application because it may leave references in memory which can lead to leaks in the future. In the end, these operations, which are usually placed on the right side of these loops, have a bigger impact on your application when you have nested while/for loops operating on computer memory. Performance problems frequently occur when programmers don't close out references to these data structures. I hope this answers your questions. If not, please let me know.
05-08-2012 08:11 AM
Ian,
Stick with the good coding habits. Remember that you want your code to run clean in development mode as well.
05-08-2012 08:40 AM
05-09-2012 01:45 PM
Hi Ian,
Although some of our cRIOs have an internal battery, if you yank out the external power supply, you will not be able to get extra cycles out of it. The internal battery serves the internal clock of the cRIO.