int main ( void )
{
		utils_init();
		debug_init();
		pwm_in_init();
		pwm_out_init();
		_delay_ms(2000);
		orientation_init();

		char out[200];
		float dt = 0;
		uint32_t t = _micros();
	  uint32_t dt_c = 20000;
		for ( ; ; )
		{

				t = _micros();
				/* Read all data from sensor 1 */
				orientation_update( 20.0 );

				bzero( out , sizeof ( out ) );
				/* Format data */
				sprintf( out, "{\"x\":%f,\"y\":%f,\"z\":%f,\"xx\":%f,\"xy\":%f,\"xz\":%f}\n" , angles[PITCH], angles[ROLL], angles[YAW],acc_smooth[PITCH], acc_smooth[ROLL], acc_smooth[YAW]);

				debug_write( out );
				while((_micros() - t) < dt_c);

		}
}
示例#2
0
    // Open interface
  static int ven_init (const bt_vendor_callbacks_t * p_cb, unsigned char * local_bdaddr) {

    logd ("ven_init p_cb: %p  local_bdaddr: %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x", p_cb, local_bdaddr [0], local_bdaddr [1], local_bdaddr [2], local_bdaddr [3], local_bdaddr [4], local_bdaddr [5] );

    logd ("main start: %s %s", binary_description, manifest_version);   // manifest_version automatically set during build
    logd (copyright);                                                   // Copyright

    utils_init ();

    if (p_cb == NULL) {
      loge ("ven_init no user callbacks");
      return (BT_HC_STATUS_FAIL);
    }
    bt_ven_cbacks = (bt_vendor_callbacks_t *) p_cb;                     // Store reference to user callbacks

    if (shim_start () == NULL) {
      loge ("ven_init shim_start error");
      return (BT_HC_STATUS_FAIL);
    }

    int ret = -88;
    if (veno_init)
      ret = veno_init (p_cb, local_bdaddr);
    logd ("ven_init ret: %d", ret);
    if (ret == 0)
      ret = server_thread_start ();

    return (ret);
  }
static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
    int result;

    ALOGI("init");

    if (p_cb == NULL)
    {
        ALOGE("init failed with no user callbacks!");
        return BT_HC_STATUS_FAIL;
    }

    hc_cb.epilog_timer_created = false;
    fwcfg_acked = false;
    has_cleaned_up = false;

    pthread_mutex_init(&hc_cb.worker_thread_lock, NULL);

    /* store reference to user callbacks */
    bt_hc_cbacks = (bt_hc_callbacks_t *) p_cb;

    vendor_open(local_bdaddr);

    utils_init();
#ifdef HCI_USE_MCT
    extern tHCI_IF hci_mct_func_table;
    p_hci_if = &hci_mct_func_table;
#else
    extern tHCI_IF hci_h4_func_table;
    p_hci_if = &hci_h4_func_table;
#endif

    p_hci_if->init();

    userial_init();
    lpm_init();

    utils_queue_init(&tx_q);

    if (hc_cb.worker_thread)
    {
        ALOGW("init has been called repeatedly without calling cleanup ?");
    }

    // Set prio here and let hci worker thread inherit prio
    // remove once new thread api (thread_set_priority() ?)
    // can switch prio
    raise_priority_a2dp(TASK_HIGH_HCI_WORKER);

    hc_cb.worker_thread = thread_new("bt_hc_worker");
    if (!hc_cb.worker_thread) {
        ALOGE("%s unable to create worker thread.", __func__);
        return BT_HC_STATUS_FAIL;
    }

    return BT_HC_STATUS_SUCCESS;
}
示例#4
0
int main()
{
  utils_init();
	printf("value: %d\n", value);
  utils_inc();
	printf("value: %d\n", value);

  return 0;
}
示例#5
0
文件: client.c 项目: reddragon/cse533
int main(int argc, char **argv) {
  atexit(on_client_exit);

  const char *cargs_file = CARGS_FILE;
  cargs = MALLOC(client_args);
  if (read_cargs((const char *)cargs_file, cargs)) {
      exit(1);
  }
  
  utils_init();
  perhaps_init();
  vector_init(&interfaces, sizeof(struct ifi_info));

  // Initialize the receiving window
  rwindow_init(&rwin, cargs->sw_size);

  get_all_interfaces();

  // Call print_ifi_info().
  print_ifi_info((struct ifi_info*)vector_at(&interfaces, 0));

  conn = MALLOC(client_conn);
  file_name_pkt = MALLOC(packet_t);
  memset(file_name_pkt, 0, sizeof(packet_t));
  file_name_pkt->ack = 0;
  file_name_pkt->seq = 0;
  file_name_pkt->flags = FLAG_SYN;
  file_name_pkt->datalen = strlen(cargs->file_name);
  strcpy(file_name_pkt->data, cargs->file_name);

  get_conn(conn);
  INFO("Server is %s\nIPServer: %s\nIPClient: %s\n", 
       (conn->is_local ? "Local" : "Not Local"),
       sa_data_str(conn->serv_sa),
       sa_data_str(conn->cli_sa));
  initiate_tx();
  return 0;
}
int main (int argc, char *argv[]) 
{ 
  int i, j, k;
  long s1, s2;

  int nodes, cells, cell_size;

  if ( argc != 2 ){
    // Print usage
    printf("usage: %s filename \n", argv[0]);
    printf("The filename must be of the form: /Path/To/Meshes/Folder/meshname_without_extension\n");
    exit(0);
  }
  utils_init(CORES);

  /* 
   * Read in 2D mesh informations, coordinates of the vertices and the
   * map from trinagles to vertices.
   */
  char * node_path = str_cat(argv[1], ".node");
  char * cell_path = str_cat(argv[1], ".ele");
  double * coords_2D = read_coords_2D(node_path, &nodes);
  int * map_2D = read_cell_node_map_2D(cell_path, &cells, &cell_size);
  free(node_path);
  free(cell_path);

  /* 
   * 3D coordinate field.
   */
  double * coords_3D = extrude_coords(coords_2D, nodes, LAYERS, LAYER_HEIGHT);
  free(coords_2D);
  /* 
   * 3D map from cells to vertices.
   */
  int * map_3D = extrude_map(map_2D, cells, cell_size, LAYERS);
  int off_3D[6] = {1, 1, 1, 1, 1, 1};
  free(map_2D);

  /*
   * Helmholtz Assembly
   *
   * Assembly of the LHS and RHS of a Helmholtz Equation.
   */
  wrap_init(CORES);
  /* 
   * Evaluate an expression over the mesh.
   *
   */
  double *expr1 = (double*)malloc(sizeof(double) * nodes * LAYERS);
  printf(" Evaluating expression... ");
  s1 = stamp();
  wrap_expression_1(0, cells,
                    expr1, map_3D,
                    coords_3D, map_3D,
                    off_3D, off_3D, LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);
  //fprint(expr1, 150, 1);

  /*
   * Zero an array
   */
  double *expr2 = (double*)malloc(sizeof(double) * nodes * LAYERS);
  printf(" Set array to zero... ");
  s1 = stamp();
  wrap_zero_1(0, nodes * LAYERS,
              expr2,
              LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);

  /*
   * Interpolation operation.
   */
  printf(" Interpolate expression... ");
  s1 = stamp();
  wrap_rhs_1(0, cells,
             expr2, map_3D,
             coords_3D, map_3D,
             expr1, map_3D,
             off_3D, off_3D, off_3D, LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);

  /*
   * Another expression kernel
   */
  double *expr3 = (double*)malloc(sizeof(double) * nodes * LAYERS);
  printf(" Evaluating expression... ");
  s1 = stamp();
  wrap_expression_2(0, nodes * LAYERS,
                    expr2,
                    expr3,
                    LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);

  /*
   * RHS assembly loop
   */
  double *expr4 = (double*)malloc(sizeof(double) * nodes * LAYERS);
  printf(" Assembling right-hand side... ");
  s1 = stamp();
  wrap_rhs(0, cells,
           expr4, map_3D,
           coords_3D, map_3D,
           expr2, map_3D,
           expr3, map_3D,
           off_3D, off_3D, off_3D, off_3D, LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);


  /*
   * Matrix assembly loop
   */
  double *expr5 = (double*)malloc(sizeof(double) * nodes * LAYERS);
  printf(" Assembling left-hand side... ");
  s1 = stamp();
  wrap_lhs(0, cells,
           expr5, map_3D, map_3D,
           coords_3D, map_3D,
           off_3D, off_3D, off_3D, LAYERS);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);

  /*
   * RHS and LHS output
   */

  write: s1 = stamp();
  printf(" Numerical results written to output files... ");
  output(FILE_RHS, expr4, nodes * LAYERS, 1);
  output(FILE_LHS, expr5, nodes * LAYERS, 1);
  s2 = stamp();
  printf("%g s\n", (s2 - s1)/1e9);

  free(coords_3D);
  free(map_3D);
  free(expr1);
  free(expr2);
  free(expr3);
  free(expr4);
  free(expr5);

  return 0;
}
示例#7
0
static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
    pthread_attr_t thread_attr;
    struct sched_param param;
    int policy, result;

    ALOGI("init");

    if (p_cb == NULL)
    {
        ALOGE("init failed with no user callbacks!");
        return BT_HC_STATUS_FAIL;
    }

    hc_cb.epilog_timer_created = 0;
    fwcfg_acked = FALSE;

    /* store reference to user callbacks */
    bt_hc_cbacks = (bt_hc_callbacks_t *) p_cb;

    init_vnd_if(local_bdaddr);

    utils_init();

   if(is_bt_transport_smd())
   {
       extern tHCI_IF hci_mct_func_table;
       extern tUSERIAL_IF userial_mct_func_table;
       p_hci_if = &hci_mct_func_table;
       p_userial_if = &userial_mct_func_table;
   }
   else
   {
       extern tHCI_IF hci_h4_func_table;
       extern tUSERIAL_IF userial_h4_func_table;
       p_hci_if = &hci_h4_func_table;
       p_userial_if = &userial_h4_func_table;
   }

    p_hci_if->init();

    p_userial_if->init();
    lpm_init();

    utils_queue_init(&tx_q);

    if (lib_running)
    {
        ALOGW("init has been called repeatedly without calling cleanup ?");
    }

    lib_running = 1;
    ready_events = 0;
    pthread_mutex_init(&hc_cb.mutex, NULL);
    pthread_cond_init(&hc_cb.cond, NULL);
    pthread_attr_init(&thread_attr);

    if (pthread_create(&hc_cb.worker_thread, &thread_attr, \
                       bt_hc_worker_thread, NULL) != 0)
    {
        ALOGE("pthread_create failed!");
        lib_running = 0;
        return BT_HC_STATUS_FAIL;
    }

    if(pthread_getschedparam(hc_cb.worker_thread, &policy, &param)==0)
    {
        policy = BTHC_LINUX_BASE_POLICY;
#if (BTHC_LINUX_BASE_POLICY!=SCHED_NORMAL)
        param.sched_priority = BTHC_MAIN_THREAD_PRIORITY;
#endif
        result = pthread_setschedparam(hc_cb.worker_thread, policy, &param);
        if (result != 0)
        {
            ALOGW("libbt-hci init: pthread_setschedparam failed (%s)", \
                  strerror(result));
        }
    }

    return BT_HC_STATUS_SUCCESS;
}