|
-
-
-
-
-
- #include <RadioHead.h>
- #if (RH_PLATFORM == RH_PLATFORM_UNIX)
-
- #include <stdio.h>
- #include <RHutil/simulator.h>
- #include <sys/time.h>
- #include <unistd.h>
- #include <time.h>
-
- SerialSimulator Serial;
-
-
- extern void setup();
- extern void loop();
-
-
- unsigned long start_millis;
-
- int _simulator_argc;
- char** _simulator_argv;
-
-
- unsigned long time_in_millis()
- {
- struct timeval te;
- gettimeofday(&te, NULL);
- unsigned long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000;
- return milliseconds;
- }
-
-
- int main(int argc, char** argv)
- {
-
- _simulator_argc = argc;
- _simulator_argv = argv;
- start_millis = time_in_millis();
-
- srand(getpid() ^ (unsigned) time(NULL)/2);
- setup();
- while (1)
- loop();
- }
-
- void delay(unsigned long ms)
- {
- usleep(ms * 1000);
- }
-
-
- unsigned long millis()
- {
- return time_in_millis() - start_millis;
- }
-
- long random(long from, long to)
- {
- return from + (random() % (to - from));
- }
-
- long random(long to)
- {
- return random(0, to);
- }
-
- #endif
|