Example #1
0
void
frame_finalize (struct frame *frame,
		bool link_mtu_defined,
		int link_mtu,
		bool tun_mtu_defined,
		int tun_mtu)
{
  /* Set link_mtu based on command line options */
  if (tun_mtu_defined)
    {
      ASSERT (!link_mtu_defined);
      frame->link_mtu = tun_mtu + TUN_LINK_DELTA (frame);
    }
  else
    {
      ASSERT (link_mtu_defined);
      frame->link_mtu = link_mtu;
    }

  if (TUN_MTU_SIZE (frame) < TUN_MTU_MIN)
    {
      msg (M_WARN, "TUN MTU value (%d) must be at least %d", TUN_MTU_SIZE (frame), TUN_MTU_MIN);
      frame_print (frame, M_FATAL, "MTU is too small");
    }

  frame->link_mtu_dynamic = frame->link_mtu;

  frame->extra_buffer += PAYLOAD_ALIGN;
}
Example #2
0
int main(int argc, char **argv) {
    struct frame_type frame;
    struct camera_control_block ccb;

    ccb.device.category = tir4_camera;
    ccb.diag = true;
    /*   ccb.mode = operational_1dot; */
    /*   ccb.mode = operational_3dot; */

    cal_init(&ccb);

    /* loop forever reading and printing results */
    /*   while (true) { */
    /*     cal_get_frame(&ccb, &frame); */
    /*     frame_print(frame); */
    /*     frame_free(&ccb, &frame); */
    /*   } */

    int i;
    for(i=0; i<2000; i++) {
        cal_get_frame(&ccb, &frame);
        frame_print(frame);
        frame_free(&ccb, &frame);
    }

    /* call disconnects, turns all LEDs off */
    cal_shutdown(&ccb);
    return 0;
}
Example #3
0
static int before_frame_send_cb(nghttp2_session *ngh2,
                                const nghttp2_frame *frame,
                                void *userp)
{
    h2_session *session = (h2_session *)userp;
    (void)ngh2;

    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    /* Set the need to flush output when we have added one of the 
     * following frame types */
    switch (frame->hd.type) {
        case NGHTTP2_RST_STREAM:
        case NGHTTP2_WINDOW_UPDATE:
        case NGHTTP2_PUSH_PROMISE:
        case NGHTTP2_PING:
        case NGHTTP2_GOAWAY:
            session->flush = 1;
            break;
        default:
            break;

    }
    if (APLOGctrace2(session->c)) {
        char buffer[256];
        frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                      "h2_session(%ld): before_frame_send %s", 
                      session->id, buffer);
    }
    return 0;
}
Example #4
0
void machine_print(machine * m)
{
    frame *f = m->current_frame;
    printf("Now: ");
    frame_print(m->now, 0);
    if (m->now->instruction && !table_empty(oyster_bindings(m->now->instruction))) {
        printf(" with the bindings: \n");
        table_print(oyster_bindings(m->now->instruction));
    }
    while (f) {
        printf("frame: ");
        frame_print(f, 0);
        f = f->below;
    }
    if (m->accumulator) {
        printf("accum: ");
        oyster_print(m->accumulator);
    }
    printf
    ("\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n\n\n\n");
}
Example #5
0
//>> Initializing calibration of Gamepad
//------------------------------------------------------------------------------------------------------
void calibration_init(){
	if(FileExists){
		frame_stay("Found Profile!\n\n  Pad connected:\n     %s\n     %d Axis\n     %d Buttons", GamepadConnected, NUMBER_OF_AXES_USED, NUMBER_OF_BUTTONS_USED);
		frame_print("Press Button 1 for recalibration .", 1, 1);
		int i = 0;
		buzzer_short(1);
		while(i < 1000){
			if(check_if_button_pushed() == 0){
				i = 1;
				buzzer_short(3);
				break;
			}
			usleep(5000);
			if(!(i%100)){
				frame_print(" .", 0, 1);
				buzzer_short(1);
			}
			i++;
		}
		if(i == 1)
			{
				calibrate();
				frame_print("START", 1, 1);
			}else
			{
				while(1){if(!value_sum(0)){break;}
			}
			frame_print("START", 1, 1);
		}
	}else{
		buzzer_short(5);
		frame_stay("No Profile found!\n\n  Pad connected:\n     %s\n     %d Axis\n     %d Buttons", GamepadConnected, NUMBER_OF_AXES_USED, NUMBER_OF_BUTTONS_USED);
		calibrate();
		frame_print("START", 1, 1);
	}
}
Example #6
0
static int on_frame_not_send_cb(nghttp2_session *ngh2,
                                const nghttp2_frame *frame,
                                int lib_error_code, void *userp)
{
    h2_session *session = (h2_session *)userp;
    if (APLOGctrace2(session->c)) {
        char buffer[256];
        
        frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                      "h2_session: callback on_frame_not_send error=%d %s",
                      lib_error_code, buffer);
    }
    return 0;
}
Example #7
0
static int on_frame_send_cb(nghttp2_session *ngh2,
                            const nghttp2_frame *frame,
                            void *userp)
{
    h2_session *session = (h2_session *)userp;
    (void)ngh2;
    if (APLOGctrace2(session->c)) {
        char buffer[256];
        frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                      "h2_session(%ld): on_frame_send %s", 
                      session->id, buffer);
    }
    return 0;
}
Example #8
0
static int before_frame_send_cb(nghttp2_session *ngh2,
                                const nghttp2_frame *frame,
                                void *userp)
{
    h2_session *session = (h2_session *)userp;
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    if (APLOGctrace2(session->c)) {
        char buffer[256];
        frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                      "h2_session(%ld): before_frame_send %s", 
                      session->id, buffer);
    }
    return 0;
}
Example #9
0
static int on_invalid_frame_recv_cb(nghttp2_session *ngh2,
                                    const nghttp2_frame *frame,
                                    uint32_t error_code, void *userp)
{
    h2_session *session = (h2_session *)userp;
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    if (APLOGctrace2(session->c)) {
        char buffer[256];
        
        frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
        ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
                      "h2_session: callback on_invalid_frame_recv error=%d %s",
                      (int)error_code, buffer);
    }
    return 0;
}
Example #10
0
void print_stack_trace(machine * m)
{
    printf("\n\n\nNow: ");
    frame_print(m->now, 0);

    stack_trace *t = m->trace;
    while (t) {
        oyster_print(t->function);
        if (t->count > 1)
            printf(" (recursed %d times)", t->count);
        printf("\n");
        t = t->below;
    }
    if (m->accumulator) {
        printf("value: ");
        oyster_print(m->accumulator);
    }
    printf
    ("\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n\n\n");
}
Example #11
0
/**
 * nghttp2 session has received a complete frame. Most, it uses
 * for processing of internal state. HEADER and DATA frames however
 * we need to handle ourself.
 */
static int on_frame_recv_cb(nghttp2_session *ng2s,
                            const nghttp2_frame *frame,
                            void *userp)
{
    int rv;
    h2_session *session = (h2_session *)userp;
    apr_status_t status = APR_SUCCESS;
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    
    ++session->frames_received;
    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
                  "h2_session(%ld): on_frame_rcv #%ld, type=%d", session->id,
                  (long)session->frames_received, frame->hd.type);
    switch (frame->hd.type) {
        case NGHTTP2_HEADERS: {
            int eos;
            h2_stream * stream = h2_stream_set_get(session->streams,
                                                   frame->hd.stream_id);
            if (stream == NULL) {
                ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c,
                              APLOGNO(02921) 
                              "h2_session:  stream(%ld-%d): HEADERS frame "
                              "for unknown stream", session->id,
                              (int)frame->hd.stream_id);
                rv = nghttp2_submit_rst_stream(ng2s, NGHTTP2_FLAG_NONE,
                                               frame->hd.stream_id,
                                               NGHTTP2_INTERNAL_ERROR);
                if (nghttp2_is_fatal(rv)) {
                    return NGHTTP2_ERR_CALLBACK_FAILURE;
                }
                return 0;
            }

            eos = (frame->hd.flags & NGHTTP2_FLAG_END_STREAM);
            status = stream_end_headers(session, stream, eos);

            break;
        }
        case NGHTTP2_DATA: {
            h2_stream * stream = h2_stream_set_get(session->streams,
                                                   frame->hd.stream_id);
            if (stream == NULL) {
                ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c,
                              APLOGNO(02922) 
                              "h2_session:  stream(%ld-%d): DATA frame "
                              "for unknown stream", session->id,
                              (int)frame->hd.stream_id);
                rv = nghttp2_submit_rst_stream(ng2s, NGHTTP2_FLAG_NONE,
                                               frame->hd.stream_id,
                                               NGHTTP2_INTERNAL_ERROR);
                if (nghttp2_is_fatal(rv)) {
                    return NGHTTP2_ERR_CALLBACK_FAILURE;
                }
                return 0;
            }
            break;
        }
        case NGHTTP2_PRIORITY: {
            ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
                          "h2_session:  stream(%ld-%d): PRIORITY frame "
                          " weight=%d, dependsOn=%d, exclusive=%d", 
                          session->id, (int)frame->hd.stream_id,
                          frame->priority.pri_spec.weight,
                          frame->priority.pri_spec.stream_id,
                          frame->priority.pri_spec.exclusive);
            break;
        }
        default:
            if (APLOGctrace2(session->c)) {
                char buffer[256];
                
                frame_print(frame, buffer,
                            sizeof(buffer)/sizeof(buffer[0]));
                ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
                              "h2_session: on_frame_rcv %s", buffer);
            }
            break;
    }

    /* only DATA and HEADERS frame can bear END_STREAM flag.  Other
       frame types may have other flag which has the same value, so we
       have to check the frame type first.  */
    if ((frame->hd.type == NGHTTP2_DATA || frame->hd.type == NGHTTP2_HEADERS) &&
        frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
        h2_stream * stream = h2_stream_set_get(session->streams,
                                               frame->hd.stream_id);
        if (stream != NULL) {
            status = h2_stream_write_eos(stream);
            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
                          "h2_stream(%ld-%d): input closed",
                          session->id, (int)frame->hd.stream_id);
        }
    }
    
    if (status != APR_SUCCESS) {
        ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c,
                      APLOGNO(02923) 
                      "h2_session: stream(%ld-%d): error handling frame",
                      session->id, (int)frame->hd.stream_id);
        rv = nghttp2_submit_rst_stream(ng2s, NGHTTP2_FLAG_NONE,
                                       frame->hd.stream_id,
                                       NGHTTP2_INTERNAL_ERROR);
        if (nghttp2_is_fatal(rv)) {
            return NGHTTP2_ERR_CALLBACK_FAILURE;
        }
        return 0;
    }
    
    return 0;
}
Example #12
0
void calibrate(void){
	frame_print("Please calibrate. Begin with Layout, assign buttons and axis:\n", 1, 0);
	int i = 0;
	while(i < NUMBER_OF_AXES_USED){
			frame_print("\n    (Axis) ", 0, 0);
			frame_print(LablesOfAxis[i], 0, 0);
			int u = -1;
			int axisDefault = 0;
			while(1){if(!value_sum(1)){break;}}						//Wait until all buttons released
			while(u == -1){
				for (int p = 0; p < NumberOfAxesAvailiable; p++)
				{
					read_gamepad_data();
					if(u == -1 && Axis[p] != axisDefault){u = p;}
				}
			}
			GamepadLayout[i] = u;
			i++;
			frame_print("		check", 0, 0);
			buzzer_short(1);
	}
	while(i < (NUMBER_OF_BUTTONS_USED + NUMBER_OF_AXES_USED)){
			frame_print("\n    (Button) ", 0, 0);
			frame_print(LablesOfButtons[i - NUMBER_OF_AXES_USED], 0, 0);
			int u = -1;
			while(1){if(!value_sum(0)){break;}}
			while(u == -1){
				u = check_if_button_pushed();
			}
			GamepadLayout[i] = u;
			i++;
			frame_print("	check", 0, 0);
			buzzer_short(1);
	}
	while(1){if(!value_sum(0)){break;}}		
	frame_print("Press Button 1 to continue...", 1, 1);
	while(!check_if_button_pushed() == 0){};	
	buzzer_short(1);
	frame_print("To calibrate the maximum value of the axis, \n  pull and hold the assigned CamNick axis at the maximum \n  and store the value by pressing any button.\n\n    Maximum Value of Nick axis: ", 1, 0);
	while(1){if(!value_sum(0)){break;}}
		while(1){
			read_gamepad_data();
			if(value_sum(0))
			{
				MaxAxisValue = Axis[GamepadLayout[0]];
				break;	
			}
		}
		buzzer_short(1);
		fflush(stdout);
	frame_print("	check", 0, 0);
	write_file();
	frame_print("", 1, 0);
}
Example #13
0
/**
 * nghttp2 session has received a complete frame. Most, it uses
 * for processing of internal state. HEADER and DATA frames however
 * we need to handle ourself.
 */
static int on_frame_recv_cb(nghttp2_session *ng2s,
                            const nghttp2_frame *frame,
                            void *userp)
{
    h2_session *session = (h2_session *)userp;
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    apr_status_t status = APR_SUCCESS;
    
    ++session->frames_received;
    ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
                  "h2_session(%ld): on_frame_rcv #%ld, type=%d", session->id,
                  session->frames_received, frame->hd.type);
    switch (frame->hd.type) {
        case NGHTTP2_HEADERS: {
            h2_stream * stream = h2_stream_set_get(session->streams,
                                                   frame->hd.stream_id);
            if (stream == NULL) {
                ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c,
                              "h2_session:  stream(%ld-%d): HEADERS frame "
                              "for unknown stream", session->id,
                              (int)frame->hd.stream_id);
                return NGHTTP2_ERR_INVALID_STREAM_ID;
            }
            
            if (frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) {
                int eos = (frame->hd.flags & NGHTTP2_FLAG_END_STREAM);
                status = stream_end_headers(session, stream, eos);
            }
            break;
        }
        case NGHTTP2_DATA: {
            h2_stream * stream = h2_stream_set_get(session->streams,
                                                   frame->hd.stream_id);
            if (stream == NULL) {
                ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c,
                              "h2_session:  stream(%ld-%d): DATA frame "
                              "for unknown stream", session->id,
                              (int)frame->hd.stream_id);
                return NGHTTP2_ERR_PROTO;
            }
            break;
        }
        default:
            if (APLOGctrace2(session->c)) {
                char buffer[256];
                
                frame_print(frame, buffer,
                            sizeof(buffer)/sizeof(buffer[0]));
                ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
                              "h2_session: on_frame_rcv %s", buffer);
            }
            break;
    }
    
    if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
        h2_stream * stream = h2_stream_set_get(session->streams,
                                               frame->hd.stream_id);
        if (stream != NULL) {
            status = h2_stream_write_eos(stream);
            ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
                          "h2_stream(%ld-%d): input closed",
                          session->id, (int)frame->hd.stream_id);
        }
    }
    
    if (status != APR_SUCCESS) {
        ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c,
                      "h2_session: stream(%ld-%d): error handling frame",
                      session->id, (int)frame->hd.stream_id);
        return NGHTTP2_ERR_INVALID_STREAM_STATE;
    }
    
    return 0;
}
Example #14
0
int main(int argc, char **argv) {
  struct frame_type frame;
  struct camera_control_block ccb;
  struct transform t;
  struct reflector_model_type rm;

  if(get_device(&ccb) == false){
    log_message("Can't get device category!\n");
    return 1;
  }
/*   ccb.mode = diagnostic; */
/*   ccb.mode = operational_1dot; */
  ccb.mode = operational_3dot;

  if(cal_init(&ccb) < 0){
    log_message("Initialization unsuccessfull!\n");
    return 1;
  }
  bool changed;
  if(get_pose_setup(&rm, &changed) == false){
    log_message("Can't get pose setup!\n");
    return 1;
  }
/*
  rm.p1[0] = -35.0;
  rm.p1[1] = -50.0;
  rm.p1[2] = -92.5;
  rm.p2[0] = +35.0;
  rm.p2[1] = -50.0;
  rm.p2[2] = -92.5;
  rm.hc[0] = +0.0;
  rm.hc[1] = -100.0;
  rm.hc[2] = +90.0;
*/
  pose_init(rm);

  /* loop forever reading and printing results */
/*   while (true) { */
/*     cal_get_frame(&ccb, &frame); */
/*     frame_print(frame); */
/*     frame_free(&ccb, &frame); */
/*   } */

/*   /\* NEW PLAN *\/ */
/*   /\* NEW PLAN *\/ */
/*   /\* NEW PLAN *\/ */
/*   /\* going to read in from stdin simulated blobs.  */
/*    * echoing input blob out, along with alter92  */
/*    * estimates *\/ */
/*   struct bloblist_type working_bloblist; */
/*   struct blob_type wba[3]; */
/*   bool force_recenter = false; */
/*   int force_recenter_int; */
/*   int scanf_result; */
/*   working_bloblist.num_blobs = 3; */
/*   working_bloblist.blobs = wba; */
/*   while (!feof(stdin)) { */
/* /\*     printf("Enter blobs: "); *\/ */
/*     scanf_result=scanf("%f,%f,%f,%f,%f,%f,%d", */
/*                        &(wba[0].x), &(wba[0].y), */
/*                        &(wba[1].x), &(wba[1].y), */
/*                        &(wba[2].x), &(wba[2].y), */
/*                        &force_recenter_int); */
/*     if (scanf_result == 7) { */
/* /\*       printf("Received: "); *\/ */
/* /\*       printf("%f,%f,", (wba[0].x), (wba[0].y)); *\/ */
/* /\*       printf("%f,%f,", (wba[1].x), (wba[1].y)); *\/ */
/* /\*       printf("%f,%f,", (wba[2].x), (wba[2].y)); *\/ */
/* /\*       printf("%d\n", force_recenter_int); *\/ */
/*       pose_process_blobs(working_bloblist, &t); */
/*       transform_print(t); */
/*     } */
/*   } */

/*   int i; */
/*   for(i=0; i<2000; i++) { */
  cal_get_frame(&ccb, &frame);
  frame_print(frame);
  pose_recenter();
  pose_process_blobs(frame.bloblist, &t);
  transform_print(t);
  frame_free(&ccb, &frame);
  while (true) {
    cal_get_frame(&ccb, &frame);
    frame_print(frame);
    pose_process_blobs(frame.bloblist, &t);
    transform_print(t);
    frame_free(&ccb, &frame);
  }

  /* call disconnects, turns all LEDs off */
  cal_shutdown(&ccb);
  return 0;
}