Every pros::lcd::print() function in my workspace breaks due to unrelated bits of code

This year my team decided to give PROS a try because of all the wonderful things we’ve read about it on the forums and from other teams. At first everything was great, but our print functions started acting funny. The first issue was caused by running

loopRate.delay(okapi::QFrequency(50.0));

in other tasks (specifically a bang-bang flywheel control task). Every print function in our file immediately stopped running. Even pros::lcd::initialize(); failed to run. We fixed it by using pros::delay(20) instead

The second time was when I tried to open a task with an int function, but while it doesn’t make sense why only the prints broke and not the rest of my opcontrol(), I do understand that was an error on my part. Same symptoms as before.

The third and current issue has different symptoms. Instead of a black screen, I get the standard green background and every print function runs a single time, even if they’re in loops. I have narrowed down the cause to be a while loop (that doesn’t block the code, and hardly enters anyway) inside of a function called by my second task for odometry. Print functions called in my first task are affected and only run once, and, strangely, print functions after the offending while loop are also run once. I can’t debug my odometry without being able to read the values it’s outputting as I only ever see the initialized values.

I haven’t seen anyone else on the forum struggling with the pros::lcd::print() functions, but I get no end of trouble from them. Anybody know why? Am I missing something obvious?

1 Like

I wonder if pros::lcd::print() is thread safe.

@BennyBoy any thoughts ?

3 Likes

Just checked, none of LLEMU is thread safe. That’s most likely the culprit.

1 Like

I found another issue where if run a loop in any thread without a delay, even if it’s just the main, it will break every lcd function including lcd::initialize(). I don’t know if that is odd behavior, but I thought you might want to know if it is unintentional.

1 Like

Well, yes, it will break. If you have no delay in a loop, it will starve the CPU resources as that task will never yield, making it so the brain, devices, etc cannot update.
That is not a bug or unintentional behavior, make sure you have a delay in all of your loops.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.