Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal output from opcontrol appearing before banner #171

Open
theol0403 opened this issue Sep 19, 2019 · 6 comments
Open

Terminal output from opcontrol appearing before banner #171

theol0403 opened this issue Sep 19, 2019 · 6 comments
Labels
bug Something isn't working p: normal Normal priority

Comments

@theol0403
Copy link
Contributor

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

__attribute__((constructor(101))) static void pros_init(void) {
rtos_initialize();
vfs_initialize();
vdml_initialize();
display_initialize();
// NOTE: this function should be called after all other initialize
// functions. for an example of what could happen if this is not
// the case, see
// https://github.com/purduesigbots/pros/pull/144/#issuecomment-496901942
system_daemon_initialize();
invoke_install_hot_table();
}

and
void system_daemon_initialize() {

@theol0403 theol0403 changed the title terminal ouput from opcontrol appearing before banner Terminal output from opcontrol appearing before banner Sep 19, 2019
@Octogonapus
Copy link
Contributor

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?

@HotelCalifornia
Copy link
Contributor

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
Copy link
Contributor

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 HotelCalifornia added the question Further information is requested label Sep 19, 2019
@theol0403
Copy link
Contributor Author

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

@HotelCalifornia HotelCalifornia added bug Something isn't working p: normal Normal priority and removed question Further information is requested labels Sep 20, 2019
@HotelCalifornia
Copy link
Contributor

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
Copy link
Contributor

@theol0403 is this still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p: normal Normal priority
Projects
None yet
Development

No branches or pull requests

4 participants