/********************************************** * * * HCS II Logged Data Processing Demo Program * * Version 1.00 * * March 1, 1993 * * Version 1.00 -- March 1992 * -- Release version * * ***********************************************/ #include #include #define false 0 #define true 1 FILE *fp; unsigned char *logdata; unsigned int len=0; unsigned int ReadData(char *input) { unsigned int i=0; if ((fp=fopen(input, "rb")) == NULL) { printf("\nError opening %s\n", input); fclose(fp); return 1; } logdata = malloc(32768); if (!logdata) { printf("\nError allocating memory.\n"); fclose(fp); return 1; } while (!feof(fp)) { logdata[i++] = getc(fp); len++; } fclose(fp); return 0; } void ProcessData() { unsigned int id, record, id_header; for (id=0; id<=254; id++) { id_header = false; for (record=0; record<=len; record+=8) { if (logdata[record]==id) { if (!id_header) { printf("\nID = %u\n", id); id_header = true; } printf(" % 5i %02i/%02i, %02i:%02i:%02i\n", logdata[record+1]+(logdata[record+2]*256), logdata[record+3], logdata[record+4], logdata[record+5], logdata[record+6], logdata[record+7]); } } } printf("\n"); } main(int argc, char *argv[]) { char *file, name[16]; unsigned int err=0; file = name; if (argc < 2) err = ReadData("LOGDATA.BIN"); else { if (strchr(argv[1],'.')) err = ReadData(argv[1]); else { strcpy(file, argv[1]); strcat(file,".BIN"); err = ReadData(file); } } if (!err) ProcessData(); return 0; }