void LIR_Assembler::emit_op0(LIR_Op0* op) {
  switch (op->code()) {
    case lir_word_align: {
      while (code_offset() % BytesPerWord != 0) {
        _masm->nop();
      }
      break;
    }

    case lir_nop:
      assert(op->info() == NULL, "not supported");
      _masm->nop();
      break;

    case lir_label:
      Unimplemented();
      break;

    case lir_build_frame:
      build_frame();
      break;

    case lir_std_entry:
      _masm->align(CodeEntryAlignment);
_masm->set_code_start();
      _masm->entry(_compilation->codeprofile());
      build_frame();
      break;

    case lir_osr_entry:
      Unimplemented();
      //osr_entry();
      break;

    case lir_breakpoint:
      breakpoint();
      break;

    case lir_membar:
      membar();
      break;

    case lir_membar_acquire:
      membar_acquire();
      break;

    case lir_membar_release:
      membar_release();
      break;

    case lir_get_thread:
      get_thread(op->result_opr());
      break;

    default: 
      ShouldNotReachHere();
      break;
  }
}
Ejemplo n.º 2
0
int main(){
  uint8_t buffer[256];
  uint8_t params[8] = {0xFF, 0xFD, 0xFD, 0xFF, 0xFF, 0xFF, 0xFD, 0x87};
  uint8_t size = build_frame(0x04, 0xFF, params, 8, buffer);
  uint8_t i;
  for(i=0; i < size; i++){
    printf("0x%2.2X ", buffer[i]);
  }
  printf("\n");
  return EXIT_SUCCESS;
}
Ejemplo n.º 3
0
static GtkWidget *build_settings(GtkWindow * main_window)
{
	GtkWidget *vbox, *hbox, *lvbox, *rvbox;

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);

	hbox = gtk_hbox_new(TRUE, 10);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);

	lvbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), lvbox, FALSE, TRUE, 0);

	rvbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), rvbox, FALSE, TRUE, 0);

	game_settings = GAMESETTINGS(game_settings_new(TRUE));
	game_rules = GAMERULES(game_rules_new());
	game_resources = GAMERESOURCES(game_resources_new());
	game_devcards = GAMEDEVCARDS(game_devcards_new());
	game_buildings = GAMEBUILDINGS(game_buildings_new());

	/* Caption */
	build_frame(lvbox, _("Game parameters"),
		    GTK_WIDGET(game_settings));
	/* Caption */
	build_frame(lvbox, _("Rules"), GTK_WIDGET(game_rules));
	/* Caption */
	build_frame(lvbox, _("Resources"), GTK_WIDGET(game_resources));
	/* Caption */
	build_frame(rvbox, _("Buildings"), GTK_WIDGET(game_buildings));
	/* Caption */
	build_frame(rvbox, _("Development cards"),
		    GTK_WIDGET(game_devcards));

	g_signal_connect(G_OBJECT(game_settings), "check",
			 G_CALLBACK(check_vp_cb), main_window);
	return vbox;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
SIMPLE_THREAD_END


PERIODIC_THREAD_BEGIN(dreq_thread_func)
{
   const char interval = 10;
   frame_t frame;
   PERIODIC_THREAD_LOOP_BEGIN
   {
      build_frame(frame, OUT_FC_DEBUG, (const plchar_t *)&interval, 1);
      serial_write_line(&port, frame);
   }
   PERIODIC_THREAD_LOOP_END
}
Ejemplo n.º 6
0
static int motors_action(char action, char setting)
{
   frame_t frame;

   char data[2];

   if (action == 'e') /* start motors */
   {
      data[0] = action;
      data[1] = setting;

      build_frame(frame, OUT_FC_MOTORS_ACTION,
                  (const plchar_t *)data, 2);
   }
   else /* stop motors */
   {
      data[0] = 'd';
      build_frame(frame, OUT_FC_MOTORS_ACTION,
                  (const plchar_t *)data, 1);
   }


   int result;
   do
   {
      serial_write_line(&port, frame);
      struct timespec ts;
      clock_gettime(CLOCK_REALTIME, &ts);
      ts = timespec_add_ms(ts, 100);
      pthread_mutex_lock(&ack_mutex);
      result = pthread_cond_timedwait(&ack, &ack_mutex, &ts);
      pthread_mutex_unlock(&ack_mutex);
   }
   while (result == ETIMEDOUT);

   return 0;
}
Ejemplo n.º 7
0
CEXPORT JSBool def_animate_now(JSContext *cx, unsigned argc, jsval *vp) {
	JS_BeginRequest(cx);
	
	jsval *vals = JS_ARGV(cx, vp);
	JSObject *thiz = JSVAL_TO_OBJECT(JS_THIS(cx, vp));

	if (JSVAL_IS_OBJECT(*vals)) {
		JSObject *target = JSVAL_TO_OBJECT(*vals);
		if (target) {
			build_frame(cx, target, argc, vp, view_animation_now);
		}
	}
	jsval thiz_val = OBJECT_TO_JSVAL(thiz);
	JS_SET_RVAL(cx, vp, thiz_val);

	JS_EndRequest(cx);
	return JS_TRUE;
}
Ejemplo n.º 8
0
PERIODIC_THREAD_END


int fc_write_motors(mixer_in_t *data)
{
   struct ExternControl ext_ctrl;
   frame_t frame;

   bzero(&ext_ctrl, sizeof(struct ExternControl));
   ext_ctrl.gas = 255.0 * data->gas;
   ext_ctrl.pitch = data->pitch * 127.0;
   ext_ctrl.roll = data->roll * 127.0;
   ext_ctrl.yaw = data->yaw * 127.0;
   ext_ctrl.config = 1;

   build_frame(frame, OUT_FC_EXTERN_CONTROL,
               (const plchar_t *)&ext_ctrl,
               sizeof(struct ExternControl));

   return serial_write_line(&port, frame);
}
Ejemplo n.º 9
0
void LIR_Assembler::emit_op0(LIR_Op0* op) {
    switch (op->code()) {
    case lir_word_align: {
        _masm->align(BytesPerWord);
        break;
    }

    case lir_nop:
        assert(op->info() == NULL, "not supported");
        _masm->nop();
        break;

    case lir_label:
        Unimplemented();
        break;

    case lir_build_frame:
        build_frame();
        break;

    case lir_std_entry:
        // init offsets
        offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
        _masm->align(CodeEntryAlignment);
        if (needs_icache(compilation()->method())) {
            check_icache();
        }
        offsets()->set_value(CodeOffsets::Verified_Entry, _masm->offset());
        _masm->verified_entry();
        build_frame();
        offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset());
        break;

    case lir_osr_entry:
        offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
        osr_entry();
        break;

    case lir_24bit_FPU:
        set_24bit_FPU();
        break;

    case lir_reset_FPU:
        reset_FPU();
        break;

    case lir_breakpoint:
        breakpoint();
        break;

    case lir_fpop_raw:
        fpop();
        break;

    case lir_membar:
        membar();
        break;

    case lir_membar_acquire:
        membar_acquire();
        break;

    case lir_membar_release:
        membar_release();
        break;

    case lir_membar_loadload:
        membar_loadload();
        break;

    case lir_membar_storestore:
        membar_storestore();
        break;

    case lir_membar_loadstore:
        membar_loadstore();
        break;

    case lir_membar_storeload:
        membar_storeload();
        break;

    case lir_get_thread:
        get_thread(op->result_opr());
        break;

    default:
        ShouldNotReachHere();
        break;
    }
}
Ejemplo n.º 10
0
Archivo: sender.c Proyecto: popacai/SWP
void handle_pending_frame(Sender * sender,
                          LLnode ** outgoing_frames_head_ptr)
{
    Frame* frame;
    char* buf;
    if (sender->fin == 2)
	return;
    if (sender->fin == 1)
	return;

    while ((sender->LFS - sender->LAR) < sender->SWS)
    {
	//calc whether LAR has been at the out part
	//if ((sender->LFS) == (sender->FSS + 1))
	if ((sender->LFS) == (sender->FSS))
	{
	    //no more packets
	    sender->fin = 1;
	    //print_sender(sender);
	    break;
	}
	
	frame = build_frame(sender);
	
	buf = add_chksum(frame);
	//buf = convert_frame_to_char(frame);
	// add into the sender buffer;
	int pos;
	pos = frame->seq % sender->SWS;

	free (sender->buffer[pos]);
	*(sender->buffer + pos) = (struct Frame*)frame;

	
	/* buffer lookup
	Frame* see;
	int i;
	for (i = 0; i < sender->SWS; i++)
	{
	    see = sender->buffer[i];
	    fprintf(stderr, "%s\n", see->data);
	}
	*/

	struct timeval now;
	gettimeofday(&now, NULL);
	//long long t;
	//long wait_time = 1000000;
	/*
	now.tv_usec = now.tv_usec + wait_time;


	if (now.tv_usec < wait_time)
	{
	    now.tv_sec++;
	    now.tv_usec = now.tv_usec - wait_time;
	}
	*/
	//now.tv_sec++;
	sender->timestamp[pos] = now;
	
	ll_append_node(outgoing_frames_head_ptr, buf);
    }
}