Example #1
0
SIMPLE_THREAD_END


int scl_elevmap_init(void)
{
   THROW_BEGIN();
   scl_socket = scl_get_socket("elev");
   THROW_IF(scl_socket == NULL, -ENODEV);
   tsfloat_init(&elevation, 0.0f);
   simple_thread_start(&thread, thread_func, "elevmap_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
Example #2
0
SIMPLE_THREAD_END


int cmd_init(void)
{
   ASSERT_ONCE();
   cmd_socket = scl_get_socket("ap_ctrl");
   if (cmd_socket == NULL)
   {
      return -1;
   }
   simple_thread_start(&thread, thread_func, THREAD_NAME, THREAD_PRIORITY, NULL);
   return 0;
}
Example #3
0
int fc_init(void)
{
   if (!is_initialized)
   {
      is_initialized = 1;

      char *serial_port;
      opcd_param_t params[] =
      {
         {"serial_port", &serial_port},
         {"setting", &setting},
      OPCD_PARAMS_END
      };
      opcd_params_apply("actuators.mk_fc.", params);

      int ret;
      /* perform initialization once here: */
      if ((ret = serial_open(&port, serial_port, 57600, ICRNL, ICANON, 0)) != 0)
      {
         return ret;
      }
      else
      {
         const struct timespec dreq_period = {0, DREQ_THREAD_TIMEOUT_MS * NSEC_PER_MSEC};
         frame_t frame;
         char data = 1;
         LOG(LL_INFO, "setting up mikrokopter interface");
         build_frame(frame, OUT_NC_REDIRECT_UART, (const plchar_t *)&data, 0);
         serial_write_line(&port, frame);

         rpm = malloc(sizeof(float) * platform_motors());
         for (int i = 0; i < platform_motors(); i++)
         {
            rpm[i] = 0.0f;   
         }
         periodic_thread_start(&dreq_thread, dreq_thread_func, DREQ_THREAD_NAME,
                               DREQ_THREAD_PRIORITY, dreq_period, NULL);

         simple_thread_start(&sread_thread, sread_thread_func, SREAD_THREAD_NAME,
                             SREAD_THREAD_PRIORITY, NULL);

         LOG(LL_INFO, "mikrokopter interface up and running");
      }
   }
   else
   {
      LOG(LL_DEBUG, "mikrokopter interface already running");
   }
   return 0;
}
Example #4
0
SIMPLE_THREAD_END


int scl_power_init(void)
{
   THROW_BEGIN();
   scl_socket = scl_get_socket("power");
   THROW_IF(scl_socket == NULL, -ENODEV);
   pthread_mutexattr_init(&mutexattr);
   pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
   pthread_mutex_init(&mutex, &mutexattr);
   simple_thread_start(&thread, thread_func, "power_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
Example #5
0
SIMPLE_THREAD_END


int scl_gps_init(void)
{
   ASSERT_ONCE();
   THROW_BEGIN();
   scl_socket = scl_get_socket("gps");
   THROW_IF(scl_socket == NULL, -ENODEV);
   pthread_mutexattr_init(&mutexattr);
   pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
   pthread_mutex_init(&mutex, &mutexattr);
   interval_init(&interval);
   simple_thread_start(&thread, thread_func, "gps_reader", THREAD_PRIORITY, NULL);
   THROW_END();
}
Example #6
0
SIMPLE_THREAD_END


int scl_mag_decl_init(void)
{
   decl_socket = scl_get_socket("decl");
   if (decl_socket == NULL)
   {
      return -1;
   }
   pthread_mutexattr_init(&mutexattr);
   pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
   pthread_mutex_init(&mutex, &mutexattr);
   simple_thread_start(&thread, thread_func, "geomag", THREAD_PRIORITY, NULL);
   return 0;
}