So, what is the difference between printf and PrintToScreen when using WPILib? Both appear to work for us, provided we have only a main() function. However, as soon as we introduce IO_Initialization(), Initialize(), Autonomous(), and OperatorControl() functions, neither produces any output on the IFI Loader output screen. I have also heard of folks having to do a Wait(1000) prior to their first PrintToScreen call in these functions – does that make any sense?
Our team used a modified version of the default FRC code last year, but it was recommended that we switch to WPILib this year due to all of the builtin sensor functions (many of which we did not use last year). We never ran into this problem in that environment, so I suspect a library issue. We are using the two libraries from the WPILib 2k6 directory, along with the two header files and linker script (5 files in total).
PrintToScreen just calls printf inside, so I’d have to look to see what the problems might be. I’m not sure why competition projects might behave differently, although the startup is a little different. I’ll try to take a look and see what I can find.
Just so I know what to look for, are you saying you can’t see output from printf functions at all or just during the first few seconds of operation?
Also, can you try writing a quick competition program with easyC and putting in some printing? easyC uses the same library but since it generates all the build files it might eliminate some things to look for.
The team that suggested we use WPILib has used it both years they have been in the competition (the last two). They claimed that printf will NOT work at all when using WPILib, and that PrintToScreen needed a short 1sec delay put in prior to the first call to it. We have not seen either behavior.
Our experience so far has shown both printf and PrintToScreen work fine and are able to print strings to the IFI loader output screen, provided we only have a main() function. When using the competition mode style functions, we cannot get ANY output at all to come out, ever. We have the WPI library first in the library order. We are using #define _FRC_BOARD on the first line of main.c and have no other .c files currently. For build options, we suppress COD file generation (to allow longer paths), use large code model, and have specified an include path of C:\mcc18\h and library path of C:\mcc18\lib and the remainder of the options are default MPLAB. Again, the only other 5 files in our test project are the two header files, two libraries, and linker script from the WPILib 2k6 directory.
Our team will try writing a comparable easyC program tomorrow night when we meet to see how it compares in behavior to using WPIlib.
Our team has never used easyC, but I had a copy of the CD from last year. I tried installing this, and it asked for a product key. I did not have one, but was able to get in (once). Upon trying to get in the second time, it would not let me run it without that key. At that point I sent a private message to you requesting a copy of the sample competition program (from the WPILIB.pdf file), packaged in an MPLAB project file, including all necessary files (including the 5 from WPILib). I figured that would tell us whether it was something about our project, or something else. Alternatively, I could package up our version of that project and have you try it in your environment.
UPDATE: I created a project from scratch that basically was a copy of the sample competition code with printf() functions embedded and it WORKED. At this point I am having the student whose seemingly identical code did NOT work (did not cause output on the IFI loader window) send me his MPLAB project to me so I can compare the programs and all of the options that were used to see if I can explain why the difference in behavior. I will post another reply if this mystery finally gets solved.
FINAL UPDATE: I took a functional competition-style program that contained printf statements (that worked) and placed it on the student’s laptop who was having problems getting a seemingly identical program to print to the IFI terminal window. Guess what? It also did not print to the terminal window! At this point we are content to avoid that laptop (or at least stick to a ‘main’ function only), as we don’t want to waste any more time trying to solve this problem.