/* Entry point of cc1/c++. Decode command args, then call compile_file. Exit code is 35 if can't open files, 34 if fatal error, 33 if had nonfatal errors, else success. */ int main(int argc, char **argv) { register int i; dd_list files, preludes; dd_list_pos cur; int version_flag = 0; char *p; char *config_file = NULL; #ifdef TIMER_USERTIME reset_timer(&total_time); #endif start_timer(&total_time); region_init(); parse_region = newregion(); in_prelude = FALSE; num_hotspots = 0; parsed_files = dd_new_list(parse_region); copy_argc = 0; copy_argv = xmalloc((argc + 1) * sizeof(*copy_argv)); files = dd_new_list(parse_region); preludes = dd_new_list(parse_region); p = argv[0] + strlen (argv[0]); while (p != argv[0] && p[-1] != '/' #ifdef DIR_SEPARATOR && p[-1] != DIR_SEPARATOR #endif ) --p; progname = p; #ifdef SIGPIPE signal (SIGPIPE, pipe_closed); #endif copy_argv[0] = argv[0]; copy_argc = 1; for (i = 1; i < argc; i++) { int j; bool copy_arg = TRUE; /* If this is a language-specific option, decode it in a language-specific way. */ for (j = 0; lang_options[j] != 0; j++) if (!strncmp (argv[i], lang_options[j], strlen (lang_options[j]))) break; if (lang_options[j] != 0) /* If the option is valid for *some* language, treat it as valid even if this language doesn't understand it. */ c_decode_option(argv[i]); else if (argv[i][0] == '-' && argv[i][1] != 0) { register char *str = argv[i] + 1; if (str[0] == 'Y') str++; if (!strcmp (str, "dumpbase")) copy_argv[copy_argc++] = argv[i++]; else if (str[0] == 'f') { register char *p = &str[1]; int found = 0; /* Some kind of -f option. P's value is the option sans `-f'. Search for it in the table of options. */ for (j = 0; !found && j < sizeof (f_options) / sizeof (f_options[0]); j++) { if (!strcmp (p, f_options[j].string)) { *f_options[j].variable = f_options[j].on_value; /* A goto here would be cleaner, but breaks the vax pcc. */ found = 1; } if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' && ! strcmp (p+3, f_options[j].string)) { *f_options[j].variable = ! f_options[j].on_value; found = 1; } } } else if (!strcmp (str, "pedantic")) pedantic = 1; else if (!strcmp (str, "pedantic-errors")) flag_pedantic_errors = pedantic = 1; else if (!strcmp (str, "quiet")) quiet_flag = 1; else if (!strcmp (str, "version")) version_flag = 1; else if (!strcmp (str, "w")) inhibit_warnings = 1; else if (!strcmp (str, "W")) { extra_warnings = 1; /* We save the value of warn_uninitialized, since if they put -Wuninitialized on the command line, we need to generate a warning about not using it without also specifying -O. */ if (warn_uninitialized != 1) warn_uninitialized = 2; } else if (str[0] == 'W') { register char *p = &str[1]; int found = 0; /* Some kind of -W option. P's value is the option sans `-W'. Search for it in the table of options. */ for (j = 0; !found && j < sizeof (W_options) / sizeof (W_options[0]); j++) { if (!strcmp (p, W_options[j].string)) { *W_options[j].variable = W_options[j].on_value; /* A goto here would be cleaner, but breaks the vax pcc. */ found = 1; } if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' && ! strcmp (p+3, W_options[j].string)) { *W_options[j].variable = ! W_options[j].on_value; found = 1; } } if (found) ; else if (!strncmp (p, "id-clash-", 9)) { char *endp = p + 9; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", argv[i]); goto id_clash_lose; } } warn_id_clash = 1; id_clash_len = atoi (str + 10); id_clash_lose: ; } else if (!strncmp (p, "larger-than-", 12)) { char *endp = p + 12; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", argv[i]); goto larger_than_lose; } } warn_larger_than = 1; larger_than_size = atoi (str + 13); larger_than_lose: ; } } else if (!strcmp (str, "o")) copy_argv[copy_argc++] = argv[i++]; else if (str[0] == 'G') { if (str[1] == '\0') copy_argv[copy_argc++] = argv[i++]; } else if (!strncmp (str, "aux-info", 8)) { if (str[8] == '\0') copy_argv[copy_argc++] = argv[i++]; } else if (!strcmp(str, "config")) { if (i < argc - 1) { i++; config_file = strdup(argv[i]); } else error ("Missing -config file"); } else if (!strcmp(str, "prelude")) { if (i < argc - 1) { i++; dd_add_last(parse_region, preludes, rstrdup(parse_region, argv[i])); } else error("Missing -prelude file"); } else if (!strcmp(str, "hotspots")) { if (i < argc - 1) { i++; num_hotspots = atoi(argv[i]); if (num_hotspots < 0) error("Negative value for -hotspots count"); } else error("Missing -hotspots count"); } else if (!strcmp( str, "program-files")) { if (i < argc - 1) { i++; add_program_files(argv[i], files); } else error("Missing -program-files file"); } } else if (argv[i][0] == '+') ; else { /* Allow wildcards, because PAM won't expand files */ glob_t globbuf; char **cur; if (glob(argv[i], 0, NULL, &globbuf)) { /* glob returned non-zero error status; abort */ fprintf(stderr, "%s: file not found\n", argv[i]); exit(FATAL_EXIT_CODE); } else for (cur = globbuf.gl_pathv; *cur; cur++) { /* Assume anything called prelude.i is a prelude file */ if ( strlen(*cur) >= 9 && !strncmp("prelude.i", *cur + strlen(*cur) - 9, 9)) dd_add_last(parse_region, preludes, rstrdup(parse_region, *cur)); else dd_add_last(parse_region, files, rstrdup(parse_region, *cur)); } copy_arg = FALSE; } if (copy_arg) copy_argv[copy_argc++] = argv[i]; } copy_argv[copy_argc] = NULL; if (flag_casts_preserve && flag_flow_sensitive) { fprintf(stderr, "-fcasts-preserve currently not allowed with " "-fflow_sensitive"); exit(FATAL_EXIT_CODE); } /* Now analyze *all* of the files. First, initialize all appropriate data structures. */ init_types(); cval_init(); init_effects(); init_qtype(); init_quals(); init_qerror(); init_store(); if (config_file) load_config_file_quals(config_file); /* Add const so that we can do -fconst-subtyping no matter what */ if (!const_qual) { begin_po_qual(); const_qual = add_qual("const"); add_level_qual(const_qual, level_ref); set_po_nonprop(); end_po_qual(); } /* Add volatile so we can handle noreturn functions */ if (!volatile_qual) { begin_po_qual(); volatile_qual = add_qual("volatile"); add_level_qual(volatile_qual, level_ref); add_sign_qual(volatile_qual, sign_eq); set_po_nonprop(); end_po_qual(); } /* Add noreturn, for non-returning functions */ if (!noreturn_qual) { begin_po_qual(); noreturn_qual = add_qual("noreturn"); add_level_qual(noreturn_qual, level_value); add_sign_qual(noreturn_qual, sign_eq); set_po_nonprop(); end_po_qual(); } end_define_pos(); /* Allow cqual to run with no qualifiers */ init_pam(); init_analyze(); found_fs_qual = FALSE; /* Force reset, since init_analyze may look up some quals */ /* Now analyze the prelude files */ in_prelude = TRUE; dd_scan(cur, preludes) { char *file; file = DD_GET(char *, cur); fprintf(stderr, "Analyzing prelude %s\n", file); compile_file(file); }
/*********************************** * MAIN * *********************************/ int main(int argc, char *argv[]){ Connection connection; write_error_ptr = &write_error; //initialize the function pointer to write error //parse arguments if(argc == 4){ //first argument is always name of program or empty string connection.planebone_ip=argv[1]; connection.port_number_server_to_planebone=atoi(argv[2]); connection.port_number_planebone_to_server=atoi(argv[3]); }else{ printf("wrong parameters: planebone ip - send port number - receive port number\n"); exit(EXIT_FAILURE); } pthread_t thread_server_to_planebone; //create a second thread which executes server_to_planebone if(pthread_create(&thread_server_to_planebone, NULL, server_to_planebone,&connection)) { error_write(FILENAME,"error creating lisa thread"); exit(EXIT_FAILURE); } /*-------------------------START OF FIRST THREAD: PLANEBONE TO SERVER------------------------*/ static UDP udp_server; uint8_t input_stream[MAX_INPUT_STREAM_SIZE]; timeval tv_now; UDP_err_handler(openUDPServerSocket(&udp_server,connection.port_number_planebone_to_server,UDP_SOCKET_TIMEOUT),write_error_ptr); //init the data decode pointers init_decoding(); /* * WHAT WE EXPECT: * IMU_ACCEL_RAW 204 * IMU_GYRO_RAW 203 * IMU_MAG_RAW 205 * BARO_RAW 221 * GPS_INT 155 * AIRSPEED_ETS 57 * SYSMON 33 * UART_ERROR 208 * ACTUATORS_received 105 * */ int IMU_ACCEL_RAW_received=0; int IMU_GYRO_RAW_received=0; int IMU_MAG_RAW_received=0; int BARO_RAW_received=0; int GPS_INT_received=0; int AIRSPEED_received=0; int SVINFO_received=0; int SYSMON_received=0; int UART_ERROR_received=0; int ACTUATORS_received=0; int NMEA_IIMWV_received = 0; int NMEA_WIXDR_received = 0; int err; #if ANALYZE Analyze an_imu_accel_raw_freq,an_imu_accel_raw_lat; int an_imu_accel_freq_done=0,an_imu_accel_lat_done=0; init_analyze(&an_imu_accel_raw_freq,2000); init_analyze(&an_imu_accel_raw_lat,2000); Analyze an_imu_gyro_raw_freq,an_imu_gyro_raw_lat; int an_imu_gyro_freq_done=0,an_imu_gyro_lat_done=0; init_analyze(&an_imu_gyro_raw_freq,2000); init_analyze(&an_imu_gyro_raw_lat,2000); Analyze an_imu_mag_raw_freq,an_imu_mag_raw_lat; int an_imu_mag_freq_done=0,an_imu_mag_lat_done=0; init_analyze(&an_imu_mag_raw_freq,2000); init_analyze(&an_imu_mag_raw_lat,2000); Analyze an_baro_raw_freq,an_baro_raw_lat; int an_baro_raw_freq_done=0,an_baro_raw_lat_done=0; init_analyze(&an_baro_raw_freq,2000); init_analyze(&an_baro_raw_lat,2000); Analyze an_gps_int_freq,an_gps_int_lat; int an_gps_int_freq_done=0,an_gps_int_lat_done=0; init_analyze(&an_gps_int_freq,40); init_analyze(&an_gps_int_lat,40); Analyze an_airspeed_ets_freq,an_airspeed_ets_lat; int an_airspeed_ets_freq_done=0,an_airspeed_ets_lat_done=0; init_analyze(&an_airspeed_ets_freq,100); init_analyze(&an_airspeed_ets_lat,100); Analyze an_actuators_freq,an_actuators_lat; int an_actuators_freq_done=0,an_actuators_lat_done=0; init_analyze(&an_actuators_freq,500); init_analyze(&an_actuators_lat,500); Analyze an_UART_errors_freq,an_UART_errors_lat; int an_UART_errors_freq_done=0,an_UART_errors_lat_done=0; init_analyze(&an_UART_errors_freq,50); init_analyze(&an_UART_errors_lat,50); Analyze an_sys_mon_freq,an_sys_mon_lat; int an_sys_mon_freq_done=0,an_sys_mon_lat_done=0; init_analyze(&an_sys_mon_freq,50); init_analyze(&an_sys_mon_lat,50); #endif int recv_len; size_t data_len = sizeof(input_stream); while (1){ // err = receiveUDPServerData(&udp_server,(void *)&input_stream, sizeof(input_stream)); //blocking !!! //1. retreive UDP data form planebone from ethernet port. err = receiveUDPServerData(&udp_server,(void *)&input_stream, data_len, &recv_len); //blocking !!! if (recv_len != 30) { printf("Wrong number of bytes in received UDP packet!\n"); printf("Expected 30 bytes, Received %d bytes!\n", recv_len); err = UDP_ERR_RECV; } UDP_err_handler(err,write_error_ptr); if(err == UDP_ERR_NONE){ gettimeofday(&tv_now,NULL); //timestamp from receiving to calculate latency #if DEBUG > 0 printf("message raw: "); int i; for(i=0;i<input_stream[1];i++){ printf("%d ",input_stream[i]); } printf("\n"); printf("start hex: %x\n", input_stream[0]); printf("length: %d\n", input_stream[1]); printf("send id: %d\n", input_stream[2]); printf("message id: %d\n", input_stream[3]); printf("checksum1: %d\n", input_stream[input_stream[1]-2]); printf("checksum2: %d\n", input_stream[input_stream[1]-1]); // printf("%d", input_stream[3]); printf("\n"); #endif //2. decode data int err = data_decode(input_stream); DEC_err_handler(err,write_error_ptr); if(err==DEC_ERR_NONE){ switch_read_write(); //only switch read write if data decoding was succesfull Data* data = get_read_pointer(); if(input_stream[3]==IMU_GYRO_RAW){ IMU_GYRO_RAW_received=1; }else if(input_stream[3]==IMU_ACCEL_RAW){ IMU_ACCEL_RAW_received=1; }else if(input_stream[3]==IMU_MAG_RAW){ IMU_MAG_RAW_received=1; }else if(input_stream[3]==BARO_RAW){ BARO_RAW_received=1; }else if(input_stream[3]==GPS_INT){ GPS_INT_received=1; }else if(input_stream[3]==AIRSPEED_ETS){ AIRSPEED_received=1; }else if(input_stream[3]==SVINFO){ SVINFO_received=1; }else if(input_stream[3]==SYSMON){ SYSMON_received=1; }else if(input_stream[3]==UART_ERRORS){ UART_ERROR_received=1; }else if(input_stream[3]==ACTUATORS){ ACTUATORS_received=1; }else if(input_stream[3]==NMEA_IIMWV_ID){ NMEA_IIMWV_received=1; }else if(input_stream[3]==NMEA_WIXDR_ID){ NMEA_WIXDR_received=1; } /*printf("IMU_GYRO_RAW_received %d\n",IMU_GYRO_RAW_received); printf("IMU_ACCEL_RAW_received %d\n",IMU_ACCEL_RAW_received); printf("IMU_MAG_RAW_received %d\n",IMU_MAG_RAW_received); printf("BARO_RAW_received %d\n",BARO_RAW_received); printf("GPS_INT_received %d\n",GPS_INT_received); printf("AIRSPEED_received %d\n",AIRSPEED_received); printf("SVINFO_received %d\n",SVINFO_received); printf("SYSMON_received %d\n",SYSMON_received); printf("UART_ERROR_received %d\n",UART_ERROR_received); printf("ACTUATORS_received %d\n",ACTUATORS_received); printf("NMEA_IIMWV_received %d\n",NMEA_IIMWV_received); printf("NMEA_WIXDR_received %d\n",NMEA_WIXDR_received); printf("\n");*/ if(input_stream[3]==BARO_RAW){ #if ANALYZE if(calculate_frequency(&an_baro_raw_freq,data->lisa_plane.baro_raw.tv)==1){ an_baro_raw_freq_done=1; } if(calculate_latency(&an_baro_raw_lat,data->lisa_plane.baro_raw.tv,tv_now)==1){ an_baro_raw_lat_done=1; } #endif /*int i; printf("Baro_raw content:"); print_mem((void *)&data->lisa_plane.baro_raw,sizeof(Baro_raw)); printf("abs %d\n",data->lisa_plane.baro_raw.abs); printf("diff %d\n",data->lisa_plane.baro_raw.diff); printf("\n\n\n");*/ } if(input_stream[3]==IMU_GYRO_RAW){ #if ANALYZE if(calculate_frequency(&an_imu_gyro_raw_freq,data->lisa_plane.imu_gyro_raw.tv)==1){ an_imu_gyro_freq_done=1; } if(calculate_latency(&an_imu_gyro_raw_lat,data->lisa_plane.imu_gyro_raw.tv,tv_now)==1){ an_imu_gyro_lat_done=1; } #endif /* int i; printf("Imu_gyro_raw content:"); print_mem((void *)&data->lisa_plane.imu_gyro_raw,sizeof(Imu_gyro_raw)); printf("\n"); printf("gp %d\n",data->lisa_plane.imu_gyro_raw.gp); printf("gq %d\n",data->lisa_plane.imu_gyro_raw.gq); printf("gr %d\n",data->lisa_plane.imu_gyro_raw.gr); print_latency(data->lisa_plane.imu_gyro_raw.tv); printf("\n\n\n");*/ } if(input_stream[3]==IMU_ACCEL_RAW){ #if ANALYZE if(calculate_frequency(&an_imu_accel_raw_freq,data->lisa_plane.imu_accel_raw.tv)==1){ an_imu_accel_freq_done=1; } if(calculate_latency(&an_imu_accel_raw_lat,data->lisa_plane.imu_accel_raw.tv,tv_now)==1){ an_imu_accel_lat_done=1; } #endif /*int i; printf("Imu_accel_raw content:"); print_mem((void *)&data->lisa_plane.imu_accel_raw,sizeof(Imu_accel_raw)); printf("\n"); printf("ax %d\n",data->lisa_plane.imu_accel_raw.ax); printf("ay %d\n",data->lisa_plane.imu_accel_raw.ay); printf("az %d\n",data->lisa_plane.imu_accel_raw.az); printf("\n"); printf("\n\n\n");*/ } if(input_stream[3]==IMU_MAG_RAW){ #if ANALYZE if(calculate_frequency(&an_imu_mag_raw_freq,data->lisa_plane.imu_mag_raw.tv)==1){ an_imu_mag_freq_done=1; } if(calculate_latency(&an_imu_mag_raw_lat,data->lisa_plane.imu_mag_raw.tv,tv_now)==1){ an_imu_mag_lat_done=1; } #endif } if(input_stream[3]==AIRSPEED_ETS){ #if ANALYZE if(calculate_frequency(&an_airspeed_ets_freq,data->lisa_plane.airspeed_ets.tv)==1){ an_airspeed_ets_freq_done=1; } if(calculate_latency(&an_airspeed_ets_lat,data->lisa_plane.airspeed_ets.tv,tv_now)==1){ an_airspeed_ets_lat_done=1; } #endif /*int i; printf("airspeed content:"); print_mem((void *)&data->lisa_plane.airspeed_ets,sizeof(Airspeed_ets)); char temp[64]; timestamp_to_timeString(data->lisa_plane.airspeed_ets.tv,temp); printf("send time %s\n",temp); printf("adc %d\n",data->lisa_plane.airspeed_ets.adc); printf("offset %d\n",data->lisa_plane.airspeed_ets.offset); printf("scaled %f\n",data->lisa_plane.airspeed_ets.scaled);*/ } if(input_stream[3]==GPS_INT){ #if ANALYZE if(calculate_frequency(&an_gps_int_freq,data->lisa_plane.gps_int.tv)==1){ an_gps_int_freq_done=1; } if(calculate_latency(&an_gps_int_lat,data->lisa_plane.gps_int.tv,tv_now)==1){ an_gps_int_lat_done=1; } #endif /*int i; printf("Gps_int_message content:"); print_mem((void *)&data->lisa_plane.gps_int,sizeof(Gps_int)); printf("\n"); printf("ecef_x %d\n",data->lisa_plane.gps_int.ecef_x); printf("ecef_y %d\n",data->lisa_plane.gps_int.ecef_y); printf("ecef_z %d\n",data->lisa_plane.gps_int.ecef_z); printf("lat %d\n",data->lisa_plane.gps_int.lat); printf("lon %d\n",data->lisa_plane.gps_int.lon); printf("alt %d\n",data->lisa_plane.gps_int.alt); printf("hmsl %d\n",data->lisa_plane.gps_int.hmsl); printf("ecef_xd %d\n",data->lisa_plane.gps_int.ecef_xd); printf("ecef_yd %d\n",data->lisa_plane.gps_int.ecef_yd); printf("ecef_zd %d\n",data->lisa_plane.gps_int.ecef_zd); printf("pacc %d\n",data->lisa_plane.gps_int.pacc); printf("sacc %d\n",data->lisa_plane.gps_int.sacc); printf("tow %d\n",data->lisa_plane.gps_int.tow); printf("pdop %d\n",data->lisa_plane.gps_int.pdop); printf("numsv %d\n",data->lisa_plane.gps_int.numsv); printf("fix %d\n",data->lisa_plane.gps_int.fix); print_latency(data->lisa_plane.gps_int.tv);*/ } if(input_stream[3]==SYSMON){ #if ANALYZE if(calculate_frequency(&an_sys_mon_freq,data->lisa_plane.sys_mon.tv)==1){ an_sys_mon_freq_done=1; } if(calculate_latency(&an_sys_mon_lat,data->lisa_plane.sys_mon.tv,tv_now)==1){ an_sys_mon_lat_done=1; } #endif /* int i; printf("sysmon content:"); print_mem((void *)&data->lisa_plane.sys_mon,sizeof(Sys_mon)); printf("\n"); printf("periodic_time %d\n",data->lisa_plane.sys_mon.periodic_time); printf("periodic_cycle %d\n",data->lisa_plane.sys_mon.periodic_cycle); printf("periodic_cycle_min %d\n",data->lisa_plane.sys_mon.periodic_cycle_min); printf("periodic_cycle_max %d\n",data->lisa_plane.sys_mon.periodic_cycle_max); printf("event_number %d\n",data->lisa_plane.sys_mon.event_number); printf("cpu_load %d\n",data->lisa_plane.sys_mon.cpu_load); print_latency(data->lisa_plane.sys_mon.tv);*/ } if(input_stream[3]==UART_ERRORS){ #if ANALYZE if(calculate_frequency(&an_UART_errors_freq,data->lisa_plane.uart_errors.tv)==1){ an_UART_errors_freq_done=1; } if(calculate_latency(&an_UART_errors_lat,data->lisa_plane.uart_errors.tv,tv_now)==1){ an_UART_errors_lat_done=1; } #endif /* int i; printf("uart error content:"); print_mem((void *)&data->lisa_plane.uart_errors,sizeof(UART_errors)); printf("overrun_cnt %d\n",data->lisa_plane.uart_errors.overrun_cnt); printf("noise_err_cnt %d\n",data->lisa_plane.uart_errors.noise_err_cnt); printf("framing_err_cnt %d\n",data->lisa_plane.uart_errors.framing_err_cnt); printf("bus_number %d\n",data->lisa_plane.uart_errors.bus_number); print_latency(data->lisa_plane.uart_errors.tv);*/ } if(input_stream[3]==ACTUATORS){ #if ANALYZE if(calculate_frequency(&an_actuators_freq,data->lisa_plane.actuators.tv)==1){ an_actuators_freq_done=1; } if(calculate_latency(&an_actuators_lat,data->lisa_plane.actuators.tv,tv_now)==1){ an_actuators_lat_done=1; } #endif /*int i; printf("actuators content:"); print_mem((void *)&data->lisa_plane.actuators,sizeof(Actuators)); printf("arr_length %d\n",data->lisa_plane.actuators.arr_length); for(i=0;i<data->lisa_plane.actuators.arr_length;i++){ printf("servo_%d %d\n",i,data->lisa_plane.actuators.values[i]); } print_latency(data->lisa_plane.actuators.tv);*/ } if(input_stream[3]==BEAGLE_ERROR){ //printf("beagle bone error content:"); //print_mem((void *)&data->bone_plane.error,sizeof(Beagle_error)); switch(data->bone_plane.error.library){ case UDP_L: UDP_err_handler(data->bone_plane.error.error_code,write_error_ptr); break; case UART_L: UART_err_handler(data->bone_plane.error.error_code,write_error_ptr); break; case DECODE_L: DEC_err_handler(data->bone_plane.error.error_code,write_error_ptr); break; case LOG_L: LOG_err_handler(data->bone_plane.error.error_code,write_error_ptr); break; } } if(input_stream[3]==NMEA_IIMWV_ID){ printf("NMEA_IIMWV_ID content:"); print_mem((void *)&data->bone_wind.nmea_iimmwv,sizeof(NMEA_IIMWV)); printf("wind angle %lf\n",data->bone_wind.nmea_iimmwv.wind_angle); printf("relative %c\n",data->bone_wind.nmea_iimmwv.relative); printf("wind speed %lf\n",data->bone_wind.nmea_iimmwv.wind_speed); printf("wind speed unit %c\n",data->bone_wind.nmea_iimmwv.wind_speed_unit); printf("status %c\n",data->bone_wind.nmea_iimmwv.status); char temp[64]; timestamp_to_timeString16(data->bone_wind.nmea_iimmwv.tv,temp); printf("send time: %s\n",temp); printf("\n"); } if(input_stream[3]==NMEA_WIXDR_ID){ printf("NMEA_WIXDR_ID content:"); print_mem((void *)&data->bone_wind.nmea_wixdr,sizeof(NMEA_WIXDR)); printf("Temperature %lf\n",data->bone_wind.nmea_wixdr.temperature); printf("unit %c\n",data->bone_wind.nmea_wixdr.unit); char temp[64]; timestamp_to_timeString16(data->bone_wind.nmea_wixdr.tv,temp); printf("send time: %s\n",temp); printf("\n"); } if(input_stream[3]==LINE_ANGLE_ID){ // Send a character (to gpio of arduino) // to stop the arduino-timer /* FILE *myFile; myFile = fopen("/dev/ttyUSB0", "w"); fputs ("a", myFile); fclose (myFile); */ printf("LINE_ANGLE_ID content:"); print_mem((void *)&data->bone_arm.line_angle,sizeof(LINE_ANGLE)); printf("Azimuth %i\n",data->bone_arm.line_angle.azimuth_raw); printf("Elevation %i\n",data->bone_arm.line_angle.elevation_raw); // printf("unit %c\n",data->bone_wind.nmea_wixdr.unit); //char temp[64]; //timestamp_to_timeString16(data->bone_arm.line_angle.tv,temp); //printf("send time: %s\n",temp); printf("\n"); } }else{ printf("UNKNOW PACKAGE with id %d\n",input_stream[3]); exit(1); } } #if ANALYZE if(an_imu_accel_freq_done==1 && an_imu_accel_lat_done==1 && an_imu_gyro_freq_done==1 && an_imu_gyro_lat_done==1 && an_imu_mag_freq_done==1 && an_imu_mag_lat_done==1 && an_baro_raw_lat_done==1 && an_baro_raw_freq_done==1 && an_airspeed_ets_lat_done==1 && an_airspeed_ets_freq_done==1 && an_actuators_lat_done==1 && an_actuators_freq_done==1 && an_UART_errors_lat_done==1 && an_UART_errors_freq_done==1 && an_sys_mon_lat_done==1 && an_sys_mon_freq_done==1) { printf("ANALYZE RESULTS - IMU_ACCEL_RAW:\n"); printf("avg period:\t %0.4f ms\n",(get_avg(&an_imu_accel_raw_freq))); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_imu_accel_raw_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_imu_accel_raw_lat)); printf("\n"); dump_buffer_to_file(&an_imu_accel_raw_freq,"analyze/imu_accel_raw_per.csv"); dump_buffer_to_file(&an_imu_accel_raw_lat,"analyze/imu_accel_raw_lat.csv"); destroy_analyze(&an_imu_accel_raw_freq); destroy_analyze(&an_imu_accel_raw_lat); printf("ANALYZE RESULTS - IMU_GYRO_RAW:\n"); printf("avg period:\t %0.4f ms\n",(get_avg(&an_imu_gyro_raw_freq))); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_imu_gyro_raw_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_imu_gyro_raw_lat)); printf("\n"); dump_buffer_to_file(&an_imu_gyro_raw_freq,"analyze/imu_gyro_raw_per.csv"); dump_buffer_to_file(&an_imu_gyro_raw_lat,"analyze/imu_gyro_raw_lat.csv"); destroy_analyze(&an_imu_gyro_raw_freq); destroy_analyze(&an_imu_gyro_raw_lat); printf("ANALYZE RESULTS - IMU_MAG_RAW:\n"); printf("avg period:\t %0.4f ms\n",(get_avg(&an_imu_mag_raw_freq))); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_imu_mag_raw_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_imu_mag_raw_lat)); printf("\n"); dump_buffer_to_file(&an_imu_mag_raw_freq,"analyze/imu_mag_raw_per.csv"); dump_buffer_to_file(&an_imu_mag_raw_lat,"analyze/imu_mag_raw_lat.csv"); destroy_analyze(&an_imu_mag_raw_freq); destroy_analyze(&an_imu_mag_raw_lat); printf("ANALYZE RESULTS - BARO_RAW:\n"); printf("avg period:\t %0.4f ms\n",(get_avg(&an_baro_raw_freq))); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_baro_raw_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_baro_raw_lat)); printf("\n"); dump_buffer_to_file(&an_baro_raw_freq,"analyze/baro_raw_per.csv"); dump_buffer_to_file(&an_baro_raw_lat,"analyze/baro_raw_lat.csv"); destroy_analyze(&an_baro_raw_freq); destroy_analyze(&an_baro_raw_lat); printf("ANALYZE RESULTS - GPS_INT:\n"); printf("avg period:\t %0.4f ms\n",get_avg(&an_gps_int_freq)); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_gps_int_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_gps_int_lat)); printf("\n"); dump_buffer_to_file(&an_gps_int_freq,"analyze/gps_int_per.csv"); dump_buffer_to_file(&an_gps_int_lat,"analyze/gps_int_lat.csv"); destroy_analyze(&an_gps_int_freq); destroy_analyze(&an_gps_int_lat); printf("ANALYZE RESULTS - AIRSPEED_ETS:\n"); printf("avg period:\t %0.4f ms\n",get_avg(&an_airspeed_ets_freq)); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_airspeed_ets_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_airspeed_ets_lat)); printf("\n"); dump_buffer_to_file(&an_airspeed_ets_freq,"analyze/airspeed_ets_per.csv"); dump_buffer_to_file(&an_airspeed_ets_lat,"analyze/airspeed_ets_lat.csv"); destroy_analyze(&an_airspeed_ets_freq); destroy_analyze(&an_airspeed_ets_lat); printf("ANALYZE RESULTS - ACTUATORS:\n"); printf("avg period:\t %0.4f ms\n",get_avg(&an_actuators_freq)); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_actuators_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_actuators_lat)); printf("\n"); dump_buffer_to_file(&an_actuators_freq,"analyze/actuators_per.csv"); dump_buffer_to_file(&an_actuators_lat,"analyze/actuators_lat.csv"); destroy_analyze(&an_actuators_freq); destroy_analyze(&an_actuators_lat); printf("ANALYZE RESULTS - UART_ERRORS:\n"); printf("avg period:\t %0.4f ms\n",get_avg(&an_UART_errors_freq)); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_UART_errors_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_UART_errors_lat)); printf("\n"); dump_buffer_to_file(&an_UART_errors_freq,"analyze/UART_errors_per.csv"); dump_buffer_to_file(&an_UART_errors_lat,"analyze/UART_errors_lat.csv"); destroy_analyze(&an_UART_errors_freq); destroy_analyze(&an_UART_errors_lat); printf("ANALYZE RESULTS - SYS_MON:\n"); printf("avg period:\t %0.4f ms\n",get_avg(&an_sys_mon_freq)); printf("avg freq:\t %0.4f hz\n",1/(get_avg(&an_sys_mon_freq))*1e3); printf("avg latency\t %0.4f ms\n",get_avg(&an_sys_mon_lat)); printf("\n"); dump_buffer_to_file(&an_sys_mon_freq,"analyze/sys_mon_per.csv"); dump_buffer_to_file(&an_sys_mon_lat,"analyze/sys_mon_lat.csv"); destroy_analyze(&an_sys_mon_freq); destroy_analyze(&an_sys_mon_lat); exit(1); } #endif } UDP_err_handler(closeUDPServerSocket(&udp_server),write_error_ptr); /*------------------------END OF FIRST THREAD------------------------*/ //wait for the second thread to finish if(pthread_join(thread_server_to_planebone, NULL)) { error_write(FILENAME,"error joining thread_lisa_to_pc"); exit(EXIT_FAILURE); } return 0; }