pros
pros copied to clipboard
Terminal output from opcontrol appearing before banner
This issue is very minor and low priority.
Expected Behavior:
The PROS banner should show in the terminal, then any user text should be printed after the banner.
Actual Behavior:
User text is printed before or in the middle of the banner:

Steps to reproduce:
void opcontrol() {
std::cout << "This print is at the top of opcontrol()" << std::endl;
while (true) {
pros::delay(20);
}
}
Solution
One solution would be to delay about 200ms before starting the competition control tasks. This will have the added benefit of giving the ADI ports time to initialize.
System information:
PROS Kernel Version: 3.2.0
Additional Information
This is strange behavior, considering https://github.com/purduesigbots/pros/blob/6394b233ac02e337cd4d8dc103a8c7f069272ae4/src/system/startup.c#L36-L52 and https://github.com/purduesigbots/pros/blob/6394b233ac02e337cd4d8dc103a8c7f069272ae4/src/system/system_daemon.c#L125
This will have the added benefit of giving the ADI ports time to initialize.
Maybe this is related to getting garbage data out of the ADI ports at the start of the program. Is there a way for us to poll if the ADI ports have been initialized?
Wondering if the solution could be as simple as swapping the order vfs_initialize and vdml_initialize. The fact that serial output is initialized before VDML could potentially explain the appearance of garbage data as @Octogonapus mentioned.
Actually, now I think about it, the two issues may be separate after all.
The terminal output timing issue may just be because vfs_initialize takes a while to start up and/or gets preempted by the competition tasks. Inserting a small delay would probably fix it, hacky as that seems. @theol0403 does this happen on kernel versions <3.2.0? or is this a new issue?
This appears to be a new issue. Testing on 3.1.6 gives expected behavior:

As far as I can verify the only thing that's changed in that neck of the woods was moving display_initialize to before system_daemon_initialize... If that's what ended up causing this then there's some pretty fragile timing at play here.
I'll try to repro this later and mess around with it a bit.
@theol0403 is this still happening?