Refs #165.
- Added protection against zero division. git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@182 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
d677bf4bfd
commit
fcb25f5dc8
|
@ -247,31 +247,32 @@ begin
|
||||||
rxCnt := 0;
|
rxCnt := 0;
|
||||||
packetLen := 0;
|
packetLen := 0;
|
||||||
|
|
||||||
// re-confgure the reception timeout now that the total packet length is known.
|
// only attempt to receive the remainder of the packet if its length is valid
|
||||||
// timeout = (MULTIPLIER) * number_of_bytes + CONSTANT
|
if resLen > 0 then
|
||||||
sciDriver.Timeouts.ReadTotalConstant := 0;
|
|
||||||
if timeOutms > 0 then
|
|
||||||
sciDriver.Timeouts.ReadTotalMultiplier := timeOutms div resLen
|
|
||||||
else
|
|
||||||
sciDriver.Timeouts.ReadTotalMultiplier := timeOutms;
|
|
||||||
|
|
||||||
// attempt to receive the bytes of the response packet one by one
|
|
||||||
while (rxCnt < resLen) and (GetTickCount < dwEnd) do
|
|
||||||
begin
|
begin
|
||||||
// receive the next byte
|
// re-confgure the reception timeout now that the total packet length is known.
|
||||||
if sciDriver.Read(packetData[rxCnt], 1) = 1 then
|
// timeout = (MULTIPLIER) * number_of_bytes + CONSTANT
|
||||||
|
sciDriver.Timeouts.ReadTotalConstant := 0;
|
||||||
|
sciDriver.Timeouts.ReadTotalMultiplier := timeOutms div resLen;
|
||||||
|
|
||||||
|
// attempt to receive the bytes of the response packet one by one
|
||||||
|
while (rxCnt < resLen) and (GetTickCount < dwEnd) do
|
||||||
begin
|
begin
|
||||||
// increment counter
|
// receive the next byte
|
||||||
rxCnt := rxCnt + 1;
|
if sciDriver.Read(packetData[rxCnt], 1) = 1 then
|
||||||
|
begin
|
||||||
|
// increment counter
|
||||||
|
rxCnt := rxCnt + 1;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
// check to see if all bytes were received. if not, then a timeout must have
|
// check to see if all bytes were received. if not, then a timeout must have
|
||||||
// happened.
|
// happened.
|
||||||
if rxCnt = resLen then
|
if rxCnt = resLen then
|
||||||
begin
|
begin
|
||||||
packetLen := resLen;
|
packetLen := resLen;
|
||||||
result := true;
|
result := true;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end; //*** end of SendPacket ***
|
end; //*** end of SendPacket ***
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue