fix Read() return value check in LMS64CProtocol::TransferPacket
also improve error messages
@@ -441,29 +441,26 @@ int LMS64CProtocol::TransferPacket(GenericPacket& pkt)
{
for(int i=0; i<outLen; i+=packetLen)
{
- int bytesToSend = packetLen;
if (callback_logData)
- callback_logData(true, &outBuffer[outBufPos], bytesToSend);
- if( Write(&outBuffer[outBufPos], bytesToSend) )
+ callback_logData(true, &outBuffer[outBufPos], packetLen);
+ int written = Write(&outBuffer[outBufPos], packetLen);
+ if(written != packetLen)
{
+ status = lime::error("TransferPacket: Write failed (ret=%d)", written);
+ break;
+ }
outBufPos += packetLen;
long readLen = packetLen;
int bread = Read(&inBuffer[inDataPos], readLen);
- if(bread != readLen && protocol != LMS_PROTOCOL_NOVENA)
+ if(bread != readLen)
{
- status = ReportError(EIO, "Read(%d bytes) failed", (int)readLen);
+ status = lime::error("TransferPacket: Read failed (ret=%d)", bread);
break;
}
if (callback_logData)
callback_logData(false, &inBuffer[inDataPos], bread);
inDataPos += bread;
}
- else
- {
- status = ReportError(EIO, "Write(%d bytes) failed", (int)bytesToSend);
- break;
- }
- }
ParsePacket(pkt, inBuffer, inDataPos, protocol);
}
delete[] outBuffer;
