Example #1
0
void t4()
{
   int h, e, f, n, s, b, l, seq_ok, toggle_ok;
   gpioReport_t r;
   char p[32];

   printf("Pipe notification tests.\n");

   set_PWM_frequency(GPIO, 0);
   set_PWM_dutycycle(GPIO, 0);
   set_PWM_range(GPIO, 100);

   h = notify_open();
   e = notify_begin(h, (1<<4));
   CHECK(4, 1, e, 0, 0, "notify open/begin");

   time_sleep(1);

   sprintf(p, "/dev/pigpio%d", h);

   f = open(p, O_RDONLY);

   set_PWM_dutycycle(GPIO, 50);
   time_sleep(4);
   set_PWM_dutycycle(GPIO, 0);

   e = notify_pause(h);
   CHECK(4, 2, e, 0, 0, "notify pause");

   e = notify_close(h);
   CHECK(4, 3, e, 0, 0, "notify close");

   n = 0;
   s = 0;
   l = 0;
   seq_ok = 1;
   toggle_ok = 1;

   while (1)
   {
      b = read(f, &r, 12);
      if (b == 12)
      {
         if (s != r.seqno) seq_ok = 0;

         if (n) if (l != (r.level&(1<<4))) toggle_ok = 0;

         if (r.level&(1<<4)) l = 0;
         else                l = (1<<4);
           
         s++;
         n++;

         // printf("%d %d %d %X\n", r.seqno, r.flags, r.tick, r.level);
      }
      else break;
   }
   close(f);
 
   CHECK(4, 4, seq_ok, 1, 0, "sequence numbers ok");

   CHECK(4, 5, toggle_ok, 1, 0, "gpio toggled ok");

   CHECK(4, 6, n, 80, 10, "number of notifications");
}
Example #2
0
JNIEXPORT void JNICALL
Java_com_sharkable_sharkengine_DemoRenderer_nativePause(JNIEnv *env, jobject thiz) {
  notify_pause();
}