Help converting CANoe logfile to EXCEL readable .txt file
Dear People,
I'm new to the Forum so on firsthand greetings everyone and nice to see there are more people like me who are spending time on these annoying things :)
I'm a complete noob to C programming and spending my holiday time on an assignment to convert a Vector CANoe log file to a .txt file wich can be read by EXCEL.
Maybe Vector CANoe does not ring a bell but its a small device with wich you can listen in on a CAN-bus and log the messages.
This logged data is saved to a .txt file in the following way:
date Tue May 26 03:12:51 pm 2009
base hex timestamps absolute
no internal events logged
// version 7.0.0
0.000000 EnvGearDown := 1
0.000000 EnvGearDown := 0
0.000000 EnvGearDown := 1
0.000000 EnvGearDown := 0
0.000000 EnvGearDown := 1
0.000000 EnvGearDown := 0
0.000000 EnvGearDown := 1
0.000000 EnvGearDown := 0
0.000000 EnvGearDown := 1
0.000000 EnvGearDown := 0
0.000000 EnvGwSwitchIgnition := 2
0.000000 EnvGwSwitchIgnition := 0
2.000000 EnvGwSwitchIgnition := 1
3.000000 EnvGwSwitchIgnition := 2
3.100158 1 110 Tx d 3 02 00 00
3.100158 EnvDashboardEngESPDsp_ := 1
3.100158 EnvDashboardEngABSDsp_ := 1
3.100158 EnvDashboardEngOilDsp_ := 1
3.100158 EnvDashboardEngWaterDsp_ := 1
3.100158 EnvDashboardEngBaterryDsp_ := 1
3.100158 EnvBusCommActiveDsp := 1
3.120180 1 1A0 Tx d 4 00 00 00 00
3.120300 1 1F0 Tx d 1 00
3.120416 1 1F1 Tx d 1 00
3.140180 1 1A0 Tx d 4 00 00 00 00
3.150120 1 1F0 Tx d 1 00
3.150236 1 1F1 Tx d 1 00
3.160180 1 1A0 Tx d 4 00 00 00 00
3.180180 1 1A0 Tx d 4 00 00 00 00
3.180300 1 1F0 Tx d 1 00
3.180416 1 1F1 Tx d 1 00
3.200158 1 110 Tx d 3 02 00 00
3.200338 1 1A0 Tx d 4 00 00 00 00
3.205529 1 41A Tx d 4 1A 01 01 FF
3.205529 EnvNMReceiver26 := 1a
3.205529 EnvNMStatusDsp26 := 1
3.210120 1 1F0 Tx d 1 00
3.210236 1 1F1 Tx d 1 00
Now it is my task to convert this file to a .txt file in wich the correct rows and collums are ordered in the following way:
time id dlc byte0 byte1 byte2 byte3 byte4 byte5 byte6 byte7
3.100158 110 3 02 00 00
3.120180 1A0 4 00 00 00 00
3.120300 1F0 1 00
3.120416 1F1 1 00
3.140180 1A0 4 00 00 00 00
3.150120 1F0 1 00
3.150236 1F1 1 00
3.160180 1A0 4 00 00 00 00
3.180180 1A0 4 00 00 00 00
3.180300 1F0 1 00
3.180416 1F1 1 00
3.200158 110 3 02 00 00
3.200338 1A0 4 00 00 00 00
3.205529 41A 4 1A 01 01 FF
3.210120 1F0 1 00
3.210236 1F1 1 00
Like u can see i should "select" the rows in wich Tx is included and write these to the appropriate collums in the new .txt file.
Opening and reading the file is goeing ok and writing the data to the new file is also opperative. But i can't seem to get the right data in the correct order.
This is the code i've come to now:
Code:
#include <stdio.h>
/* #include <conio.h> */
int main(void)
{
FILE *fpin, *fpout;
char flin[256],flout[256];
char rel,x; /* relavant data and new line variables */
signed char meetdata[13]; /* array for logdata */
/* clrscr; */ /* clear screen */
printf("This program converts standard Vector CANoe log files to Ecxel readable files\n\nPlease specify source filename:"); /* print programheader with programfunction and ask for input filename */
scanf("%s",flin); /* read input filename */
/* does inputfile exist ? */
if ((fpin = fopen(flin, "r"))== NULL)
{
printf("Cannot open source file!\n"); /* if not, show cannot open input */
return 1;
}
/* if inputfile does exist */
else
{
printf("Please specify destination filename:"); /* ask to specify destination filename */
scanf("%s",flout); /* read output filename */
fpout = fopen(flout, "w"); /* open outputfile */
x=0; /* select first line of logdata */
}
while((rel=fgetc(fpin))!=EOF) /* while relavant databyte = byte from inputfile and not end of file */
{
if (meetdata[3]=='Tx') /* if logdata colum 2 is 1 (synch) */
{
meetdata[x]=rel; /* logdata[x] is relavant databyte */
x++; /* select new line of logdata */
}
/* write in outputfile */
fprintf(fpout,"%f\t%X\t%d\t%X\t%X\t%X\t%X\t%X\t%X\t%X\t%X\n",meetdata[0],meetdata[2],meetdata[5],meetdata[6],meetdata[7],meetdata[8],meetdata[9],meetdata[10],meetdata[11],meetdata[12],meetdata[13]);
}
/* time\tid\tdlc\tbyte0\tbyte1\tbyte2\tbyte3\tbyte4\tbyte5\tbyte6\tbyte7\n */
fclose(fpin); /* close inputfile */
fclose(fpout); /* close outputfile */
return 0;
}
/*end of main*/
I have to finish this assignment verry soon and don't know what to do!!!!
My professor has been unreachable for about a month an wil be for quite the same conciderring it's a holiday periode now.
So he won't be of any help unfortunately.
Please can somebody help me out its really important to me?
Thanks upfront.