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
Qt Code:
  1. file->setFileName("LogReport.txt");
  2. file->open(QIODevice::WriteOnly | QIODevice::Text);
  3. QTextStream stream(file);
  4. int index = 0;
  5.  
  6. stream << "ECU->USS\n";
  7. stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
  8. for(int i = 0;i<12;i++)
  9. {
  10. stream << "USS"<<i+1<<" ";
  11.  
  12. stream<<time_log_ecu2uss[i];
  13. if(i<9)
  14. {
  15. stream<<" ";
  16. }
  17. else
  18. {
  19. stream<<" ";
  20. }
  21.  
  22. for(int j = 0;j<4;j++)
  23. {
  24.  
  25. stream<<("0x"+QString::number(Data_ecu2uss[index],16));
  26. if(j<3)
  27. {
  28. stream<<",";
  29. }
  30. index++;
  31. }
  32.  
  33. stream<<endl;
  34. }
  35.  
  36. index = 0 ;
  37. stream << "USS->ECU\n";
  38. stream <<"Sensor"<<" "<<"Time"<<" "<<"Data"<<endl;
  39. for(int i = 0;i<12;i++)
  40. {
  41. stream << "USS"<<i+1<<" ";
  42. stream<<time_log_uss2ecu[i];
  43. if(i<9)
  44. {
  45. stream<<" ";
  46. }
  47. else
  48. {
  49. stream<<" ";
  50. }
  51. for(int j = 0;j<4;j++)
  52. {
  53. stream<<("0x"+QString::number(Data_uss2ecu[index],16));
  54. if(j<3)
  55. {
  56. stream<<",";
  57. }
  58. index++;
  59. }
  60. stream<<endl;
  61. }
  62.  
  63. stream<<"******************************************************************"<<endl;
  64.  
  65. }
To copy to clipboard, switch view to plain text mode