Hello
In my Project I am creating a LogReport.txt. Which maintain a Report like below
ECU->USS
Sensor Time Data
USS1 17:45:51 0x0,0xff,0x0,0x0
USS2 17:45:52 0x0,0x0,0xff,0x0
USS3 17:45:53 0x0,0x0,0x0,0x0
USS4 17:45:54 0x0,0xff,0x0,0x0
USS->ECU
Sensor Time Data
USS1 17:45:51 0x0,0x0,0x0,0x0
USS2 17:45:52 0x0,0xff,0x0,0x0
USS3 17:45:53 0x0,0xff,0x0,0x0
USS4 17:45:54 0x0,0x0,0xff,0x0
------
------
And so on until the code run.
Now once I stop my code I have to read back same data on button click.
Suppose on first click I have to read 17:45:51 0x0 0xff 0x0 0x0 and second click 17:45:52 0x0 0x0 0xff 0x0 and so on.
Can any one let me know how can I read each line with five different column.
Writefile
file->setFileName("LogReport.txt");
int index = 0;
stream << "ECU->USS\n";
stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
for(int i = 0;i<12;i++)
{
stream << "USS"<<i+1<<" ";
stream<<time_log_ecu2uss[i];
if(i<9)
{
stream<<" ";
}
else
{
stream<<" ";
}
for(int j = 0;j<4;j++)
{
stream<<
("0x"+QString::number(Data_ecu2uss
[index
],
16));
if(j<3)
{
stream<<",";
}
index++;
}
stream<<endl;
}
index = 0 ;
stream << "USS->ECU\n";
stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
for(int i = 0;i<12;i++)
{
stream << "USS"<<i+1<<" ";
stream<<time_log_uss2ecu[i];
if(i<9)
{
stream<<" ";
}
else
{
stream<<" ";
}
for(int j = 0;j<4;j++)
{
stream<<
("0x"+QString::number(Data_uss2ecu
[index
],
16));
if(j<3)
{
stream<<",";
}
index++;
}
stream<<endl;
}
stream<<"******************************************************************"<<endl;
}
file->setFileName("LogReport.txt");
file->open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream stream(file);
int index = 0;
stream << "ECU->USS\n";
stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
for(int i = 0;i<12;i++)
{
stream << "USS"<<i+1<<" ";
stream<<time_log_ecu2uss[i];
if(i<9)
{
stream<<" ";
}
else
{
stream<<" ";
}
for(int j = 0;j<4;j++)
{
stream<<("0x"+QString::number(Data_ecu2uss[index],16));
if(j<3)
{
stream<<",";
}
index++;
}
stream<<endl;
}
index = 0 ;
stream << "USS->ECU\n";
stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
for(int i = 0;i<12;i++)
{
stream << "USS"<<i+1<<" ";
stream<<time_log_uss2ecu[i];
if(i<9)
{
stream<<" ";
}
else
{
stream<<" ";
}
for(int j = 0;j<4;j++)
{
stream<<("0x"+QString::number(Data_uss2ecu[index],16));
if(j<3)
{
stream<<",";
}
index++;
}
stream<<endl;
}
stream<<"******************************************************************"<<endl;
}
To copy to clipboard, switch view to plain text mode
Bookmarks