19,504
社区成员
发帖
与我相关
我的任务
分享
if (WriteFile(hMaster, sampleMasterData, 64, &bytesWritten, NULL))
{
if (ReadFile(hSlave, sampleSlaveData, 64, &bytesRead, NULL))
{
transferSuccess = true;
for (int i = 0; i < 64; i++)
if (sampleMasterData[i] != sampleSlaveData[i]) transferSuccess = false;
if (transferSuccess)
{
for (int i = 0; i < 64; i++)
{
sampleMasterData[i] = 0;
sampleSlaveData[i] = i;
}
if (WriteFile(hMaster, sampleMasterData, 64, &bytesWritten, NULL))
{
if (ReadFile(hSlave, sampleSlaveData, 64, &bytesRead, NULL))
{
transferSuccess = true;
for (int i = 0; i < 64; i++)
if (sampleMasterData[i] != sampleSlaveData[i]) transferSuccess = false;
if (transferSuccess)
_tprintf(_T("Test Successful!"));
else
_tprintf(_T("Error in data on Slave to Master transfer"));
}
else
_tprintf(_T("Error reading data from Master COM port"));
}
else
_tprintf(_T("Error writing data to Slave COM port"));
}
else
_tprintf(_T("Error in data on Master to Slave transfer"));
}
else
_tprintf(_T("Error reading data from Slave COM port"));
}
else
_tprintf(_T("Error writing data to Master COM port"));