Esempio n. 1
0
bool extscr_cli::run(std::string cmd, const Plugin::ExecuteRequestMessage_Request &request, Plugin::ExecuteResponseMessage_Response *response) {
	if (cmd == "add")
		add_script(request, response);
	else if (cmd == "install")
		configure(request, response);
	else if (cmd == "list")
		list(request, response);
	else if (cmd == "show")
		show(request, response);
	else if (cmd == "delete")
		delete_script(request, response);
	else
		return false;
	return true;
}
Esempio n. 2
0
void t9()
{
   int s, oc, c, e;
   uint32_t p[10];

   printf("Script store/run/status/stop/delete tests.\n");

   gpio_write(GPIO, 0); /* need known state */

   /*
   100 loops per second
   p0 number of loops
   p1 GPIO
   */
   char *script="\
   lda p0\
   sta v0\
   tag 0\
   w p1 1\
   mils 5\
   w p1 0\
   mils 5\
   dcr v0\
   lda v0\
   sta p9\
   jp 0";

   callback(GPIO, RISING_EDGE, t9cbf);

   s = store_script(script);
   oc = t9_count;
   p[0] = 99;
   p[1] = GPIO;
   run_script(s, 2, p);
   time_sleep(2);
   c = t9_count - oc;
   CHECK(9, 1, c, 100, 0, "store/run script");

   oc = t9_count;
   p[0] = 200;
   p[1] = GPIO;
   run_script(s, 2, p);
   while (1)
   {
      e = script_status(s, p);
      if (e != PI_SCRIPT_RUNNING) break;
      time_sleep(0.5);
   }
   c = t9_count - oc;
   time_sleep(0.1);
   CHECK(9, 2, c, 201, 0, "run script/script status");

   oc = t9_count;
   p[0] = 2000;
   p[1] = GPIO;
   run_script(s, 2, p);
   while (1)
   {
      e = script_status(s, p);
      if (e != PI_SCRIPT_RUNNING) break;
      if (p[9] < 1900) stop_script(s);
      time_sleep(0.1);
   }
   c = t9_count - oc;
   time_sleep(0.1);
   CHECK(9, 3, c, 110, 10, "run/stop script/script status");

   e = delete_script(s);
   CHECK(9, 4, e, 0, 0, "delete script");
}
Esempio n. 3
0
void t9(int pi)
{
   int s, oc, c, e, id;
   uint32_t p[10];

   printf("Script store/run/status/stop/delete tests.\n");

   gpio_write(pi, GPIO, 0); /* need known state */

   /*
   100 loops per second
   p0 number of loops
   p1 GPIO
   */
   char *script="\
   ld p9 p0\
   tag 0\
   w p1 1\
   mils 5\
   w p1 0\
   mils 5\
   dcr p9\
   jp 0";

   id = callback(pi, GPIO, RISING_EDGE, t9cbf);

   s = store_script(pi, script);

   /* Wait for script to finish initing. */
   while (1)
   {
      time_sleep(0.1);
      e = script_status(pi, s, p);
      if (e != PI_SCRIPT_INITING) break;
   }

   oc = t9_count;
   p[0] = 99;
   p[1] = GPIO;
   run_script(pi, s, 2, p);
   time_sleep(2);
   c = t9_count - oc;
   CHECK(9, 1, c, 100, 0, "store/run script");

   oc = t9_count;
   p[0] = 200;
   p[1] = GPIO;
   run_script(pi, s, 2, p);
   while (1)
   {
      time_sleep(0.1);
      e = script_status(pi, s, p);
      if (e != PI_SCRIPT_RUNNING) break;
   }
   c = t9_count - oc;
   time_sleep(0.1);
   CHECK(9, 2, c, 201, 0, "run script/script status");

   oc = t9_count;
   p[0] = 2000;
   p[1] = GPIO;
   run_script(pi, s, 2, p);
   while (1)
   {
      time_sleep(0.1);
      e = script_status(pi, s, p);
      if (e != PI_SCRIPT_RUNNING) break;
      if (p[9] < 1600) stop_script(pi, s);
   }
   c = t9_count - oc;
   time_sleep(0.1);
   CHECK(9, 3, c, 410, 10, "run/stop script/script status");

   e = delete_script(pi, s);
   CHECK(9, 4, e, 0, 0, "delete script");

   callback_cancel(id);
}