Pre-1.9.5 shut_down_in replacement

3 replies [Last post]
Beta
Beta's picture
Title: The Magnificent
Joined: 02/24/2012
Posts:
BotPoints: 266
User offline. Last seen 3 years 23 weeks ago.

Hi,

Here is a drop-in replacement for shut_down_in you can use in your program. This is meant for teams who DO NOT want to update to 1.9.5 the day before the tournament. This shut_down_in will stop the create automatically. There are no other functional changes. Paste this block at the beginning of your program. No other changes to your program are necessary.

  1. // BEGIN SHUT_DOWN_IN_REPLACEMENT //
  2.  
  3. // Drop-in replacement for shut_down_in.
  4. // Paste the following at the beginning of
  5. // your program.
  6.  
  7. #define shut_down_in(x) __shut_down_in(x)
  8.  
  9. double __shutdown_time;
  10.  
  11. void __shut_down_in_thread()
  12. {
  13. const double start = seconds();
  14. msleep(__shutdown_time * 1000.0);
  15. const double end = seconds();
  16. printf("Shutdown after %lf seconds\n", end - start);
  17. create_stop();
  18.  
  19. // Hard halt process with no cleanup
  20. _Exit(0);
  21. }
  22.  
  23. void __shut_down_in(double secs)
  24. {
  25. printf("Using shut_down_in replacement\n");
  26. __shutdown_time = secs;
  27. thread t = thread_create(__shut_down_in_thread);
  28. thread_start(t);
  29. }
  30.  
  31. // END SHUT_DOWN_IN REPLACEMENT //

Check to make sure it is working by looking for the line "Using shut_down_in replacement" in your program's output.

If you are wanting to update to 1.9.5, please see the firmware update page on kipr.org.

Braden McDorman

Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.

Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.

lspangler
Title: NooBot
Joined: 02/25/2013
Posts:
BotPoints: 8
User offline. Last seen 4 years 19 weeks ago.

How would you do this using C++?

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 2 years 10 weeks ago.

if you surround it by extern "C"
{
}
It should work.
NOTE: I have not tested this and I may have typed something wrong.

Beta
Beta's picture
Title: The Magnificent
Joined: 02/24/2012
Posts:
BotPoints: 266
User offline. Last seen 3 years 23 weeks ago.

The code will work unmodified in C++ if you #include <kovan/kovan.h> before it.

Braden McDorman

Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.

Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.