/* SELENE MAP PACE PBF Format Data Sample read program Created by Yoshifumi Saito on 2007/06/30 Ver. 0.0 */ #include #include #include #include #include "paceql_outputdata_090805.h" /* DATA HEADER */ H_P_t s_pace_header; size_t size_H_P_t=(sizeof(s_pace_header)); /* ESA DATA TYPE */ D_ESAS1_TYPE00_t s_esas1_type00; size_t size_s_esas1_type00_t=(sizeof(s_esas1_type00)); D_ESAS2_TYPE00_t s_esas2_type00; size_t size_s_esas2_type00_t=(sizeof(s_esas2_type00)); D_ESAS1_TYPE01_t s_esas1_type01; size_t size_s_esas1_type01_t=(sizeof(s_esas1_type01)); D_ESAS2_TYPE01_t s_esas2_type01; size_t size_s_esas2_type01_t=(sizeof(s_esas2_type01)); D_ESAS1_TYPE02_t s_esas1_type02; size_t size_s_esas1_type02_t=(sizeof(s_esas1_type02)); D_ESAS2_TYPE02_t s_esas2_type02; size_t size_s_esas2_type02_t=(sizeof(s_esas2_type02)); D_ESAS1_TYPE03_t s_esas1_type03; size_t size_s_esas1_type03_t=(sizeof(s_esas1_type03)); D_ESAS2_TYPE03_t s_esas2_type03; size_t size_s_esas2_type03_t=(sizeof(s_esas2_type03)); /* IMA DATA TYPE */ D_IMA_TYPE40_t s_ima_type40; size_t size_s_ima_type40_t=(sizeof(s_ima_type40)); D_IMA_TYPE41_t s_ima_type41; size_t size_s_ima_type41_t=(sizeof(s_ima_type41)); D_IMA_TYPE42_t s_ima_type42; size_t size_s_ima_type42_t=(sizeof(s_ima_type42)); D_IMA_TYPE43_t s_ima_type43; size_t size_s_ima_type43_t=(sizeof(s_ima_type43)); D_IMA_TYPE44_t s_ima_type44; size_t size_s_ima_type44_t=(sizeof(s_ima_type44)); D_IMA_TYPE45_t s_ima_type45; size_t size_s_ima_type45_t=(sizeof(s_ima_type45)); /* IEA DATA TYPE */ D_IEA_TYPE80_t s_iea_type80; size_t size_s_iea_type80_t=(sizeof(s_iea_type80)); D_IEA_TYPE81_t s_iea_type81; size_t size_s_iea_type81_t=(sizeof(s_iea_type81)); D_IEA_TYPE82_t s_iea_type82; size_t size_s_iea_type82_t=(sizeof(s_iea_type82)); FILE *fp_in; unsigned char c_in_head[1024]; int main(int argc, char **argv) { int i,j; char fil_nme[500]; if(argc != 2){ fprintf(stderr, "\n Usage: read_pbf input_file \n"); fputs("\n", stderr); exit(1); } strcpy(fil_nme,argv[1]); /* INPUT DATA FILE OPEN */ if (NULL == (fp_in=fopen(fil_nme,"rb"))) { exit(-1); } /* READ FILE HEADER DESCRIPTION */ fread(c_in_head, 1024 , 1,fp_in); /* FILE BINARY TYPE CHECK */ #ifdef PC if (c_in_head[1023] != 0xEE){ printf("FILE_TYPE ERROR \n"); exit(1);} #else if (c_in_head[1023] != 0xDD){ printf("FILE_TYPE ERROR \n"); exit(1);} #endif /* PRINT FILE HEADER INFORMATION */ printf("%s", c_in_head); while(1){ /* READ DATA HEADER */ if (0 == fread(&s_pace_header, size_H_P_t, 1,fp_in)) break; /* DATA MODE */ switch (s_pace_header.type){ case 0x00: if(s_pace_header.sensor == 0){ if (0 == fread(&s_esas1_type00, size_s_esas1_type00_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S1 DATA MODE %lX DATA TYPE 00 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas1_type00.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } else if(s_pace_header.sensor == 1){ if (0 == fread(&s_esas2_type00, size_s_esas2_type00_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S2 DATA MODE %lX DATA TYPE 00 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas2_type00.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } break; case 0x01: if(s_pace_header.sensor == 0){ if (0 == fread(&s_esas1_type01, size_s_esas1_type01_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S1 DATA MODE %lX DATA TYPE 01 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas1_type01.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } else if(s_pace_header.sensor == 1){ if (0 == fread(&s_esas2_type01, size_s_esas2_type01_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S2 DATA MODE %lX DATA TYPE 01 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas2_type01.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } break; case 0x02: if(s_pace_header.sensor == 0){ if (0 == fread(&s_esas1_type02, size_s_esas1_type02_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S1 DATA MODE %lX DATA TYPE 02 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas1_type02.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } else if(s_pace_header.sensor == 1){ if (0 == fread(&s_esas2_type02, size_s_esas2_type02_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S2 DATA MODE %lX DATA TYPE 02 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas2_type02.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } break; case 0x03: if(s_pace_header.sensor == 0){ if (0 == fread(&s_esas1_type03, size_s_esas1_type03_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S1 DATA MODE %lX DATA TYPE 03 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas1_type03.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } else if(s_pace_header.sensor == 1){ if (0 == fread(&s_esas2_type03, size_s_esas2_type03_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("ESA-S2 DATA MODE %lX DATA TYPE 03 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_esas2_type03.event[0],s_pace_header.t_date,s_pace_header.time_ms);} } break; case 0x40: if (0 == fread(&s_ima_type40, size_s_ima_type40_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 40 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type40.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x41: if (0 == fread(&s_ima_type41, size_s_ima_type41_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 41 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type41.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x42: if (0 == fread(&s_ima_type42, size_s_ima_type42_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 42 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type42.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x43: if (0 == fread(&s_ima_type43, size_s_ima_type43_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 43 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type43.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x44: if (0 == fread(&s_ima_type44, size_s_ima_type44_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 44 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type44.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x45: if (0 == fread(&s_ima_type45, size_s_ima_type45_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IMA DATA MODE %lX DATA TYPE 45 time=%04lX%04lX%04lX event[0][0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_ima_type45.event[0][0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x80: if (0 == fread(&s_iea_type80, size_s_iea_type80_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IEA DATA MODE %lX DATA TYPE 80 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_iea_type80.event[0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x81: if (0 == fread(&s_iea_type81, size_s_iea_type81_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IEA DATA MODE %lX DATA TYPE 81 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_iea_type81.event[0],s_pace_header.t_date,s_pace_header.time_ms);} break; case 0x82: if (0 == fread(&s_iea_type82, size_s_iea_type82_t, 1,fp_in)){ printf ("FILE ERROR: No Data \n"); break;} else{ printf ("IEA DATA MODE %lX DATA TYPE 82 time=%04lX%04lX%04lX event[0]=%lX total_day=%lX msec_day=%lX \n",s_pace_header.mode,s_pace_header.timeH,s_pace_header.timeM,s_pace_header.timeL,s_iea_type82.event[0],s_pace_header.t_date,s_pace_header.time_ms);} break; default: break; } /* switch type */ } /* while(1) */ fclose(fp_in); exit(0); }