Thread: Field Issues
View Single Post
  #32   Spotlight this post!  
Unread 14-03-2011, 21:07
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Field Issues

Quote:
Originally Posted by Warlord View Post
We were having extreme communication issues for basically all of Thursday and we couldn't figure out what it was. After a ton of other things we stopped printing things to the display and that seemed to fix some of our problems.
Formatted printing (using printf or cout or similar functions) is one of the slowest functions in the C/C++/Java libraries. It should be avoided at all costs in the production or competition environment. If it is buffered things get worse because the functions will block waiting for room in the buffers. This can cause huge problems with timing, even professional programmers (new to programming in a embedded real-time environment) make this mistake. Memory allocation functions are also problematic in critical code sections.

FYI, there is a simple function provided by the operating system on the cRIO called 'logMsg'. It sends a message to a task that does the printing for you and the priority of that task can be adjusted so it does not affect your application. There is not much you can do about the memory allocation functions except organize your code so the allocations are done during startup sequences and not when the robot is responding to DS inputs, running PID code etc.

HTH

Last edited by wireties : 14-03-2011 at 21:09.