I have to write logfile to trace init sequence from my simulator application

Viewed 10

So, I dont have much idea about logfile and i need to write a logfile using fprintf between BlueModPlusS50::Send and BlueModPlusS50::Receive as you can check in the code, so that it can trace init, scan and print sequences from the simulator application that i use. So please help me to understand what it actually means and how to do that. Even if there are different versions of your understanding, you may let me know. I am using Visual Studio 2019.

void BlueModPlusS50::Send(std::shared_ptr< Message > msg, const ms timeout) {
#ifdef SIMULATION
DWORD BytesWritten = 0;
printf(">>>>>>%s<<<<<<", msg->GetPayload());
bool Status = WriteFile(com_handle_,             // Handle to the Serialport
                        msg->GetPayload(),     // Data to be written to the port
                        msg->GetSize(),        // No of bytes to write into the port
                        &BytesWritten,         // No of bytes written to the port
                        NULL);
if (Status == FALSE) {
  printf_s("\nFail to Written");
}
#endif  // SIMULATION
}

void BlueModPlusS50::Receive(std::shared_ptr<Message> msg) {
#ifdef SIMULATION
DWORD NoBytesRead;  // Bytes read by ReadFile()
char ReadData;      // temporary Character
unsigned char received = 0;
auto payload = msg->GetPayload();
do {
  bool Status = ReadFile(com_handle_, &ReadData, sizeof(ReadData), &NoBytesRead, NULL);
  if (NoBytesRead > 0) {
    payload[received] = ReadData;
    printf("%c", ReadData);
    ++received;
  }
} while (received < msg->GetSize());
msg->SetSize(received);
0 Answers
Related