pros icon indicating copy to clipboard operation
pros copied to clipboard

Terminal output from opcontrol appearing before banner

Open theol0403 opened this issue 6 years ago • 6 comments

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:

image

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

theol0403 avatar Sep 19 '19 02:09 theol0403

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?

Octogonapus avatar Sep 19 '19 03:09 Octogonapus

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.

HotelCalifornia avatar Sep 19 '19 21:09 HotelCalifornia

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?

HotelCalifornia avatar Sep 19 '19 21:09 HotelCalifornia

This appears to be a new issue. Testing on 3.1.6 gives expected behavior:

theol0403 avatar Sep 20 '19 04:09 theol0403

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.

HotelCalifornia avatar Sep 20 '19 13:09 HotelCalifornia

@theol0403 is this still happening?

HotelCalifornia avatar Dec 18 '19 03:12 HotelCalifornia