automate ProcessMessageCan string
Posted: Sat 11. Nov 2023, 03:59
I have modified the manualread and manualwrite functions to read and write text strings sent and received from a product I am testing.
I need help reading in the PCAN string dynamically so I can look for data and determine pass/fail criteria. you can see where I hard coded
if(msg.DATA[2]== 77 && msg.DATA[3] == 67 && msg.DATA[4] == 66) //if return string = MCB then enter test mode to determine if the string contained MCB. I want to be able to pass this function variables so I dont have to hard code my msg.DATA
Thanks, Ross
I need help reading in the PCAN string dynamically so I can look for data and determine pass/fail criteria. you can see where I hard coded
if(msg.DATA[2]== 77 && msg.DATA[3] == 67 && msg.DATA[4] == 66) //if return string = MCB then enter test mode to determine if the string contained MCB. I want to be able to pass this function variables so I dont have to hard code my msg.DATA
Thanks, Ross
Code: Select all
void ManualRead::ProcessMessageCan(TPCANMsg msg, TPCANTimestamp itsTimeStamp)
{
UINT64 microsTimestamp = itsTimeStamp.micros + (1000ULL * itsTimeStamp.millis) + (0x100'000'000ULL * 1000ULL * itsTimeStamp.millis_overflow);
char result[MAX_PATH] = { 0 };
sprintf_s(result, sizeof(result), "%i", msg.LEN);
std::cout << "Data: " << GetDataString(msg.DATA, msg.MSGTYPE, msg.LEN) << "\n";
if(msg.DATA[2]== 77 && msg.DATA[3] == 67 && msg.DATA[4] == 66) //if return string = MCB then enter test mode
}
std::string ManualRead::GetDataString(BYTE data[], TPCANMessageType msgType, int dataLength)
{
if ((msgType & PCAN_MESSAGE_RTR) == PCAN_MESSAGE_RTR)
return "Remote Request";
else
{
char strTemp[MAX_PATH] = { 0 };
std::string result = "";
for (int i = 0; i < dataLength; i++)
{
sprintf_s(strTemp, sizeof(strTemp), "%02X ", data[i]);
result.append(strTemp);
}
return result;
}
}