Quote:
Originally Posted by Warlord
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