viganabd / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

When Read a unexist SalveID will into endless loop #55

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I think this code has some problem:
When Read a Holding Reg ,but the Slave doesn't exist ,so there is no response 
,so this function will enter to a endless loop state

public virtual byte[] Read(int count)
        {
            byte[] frameBytes = new byte[count];
            int numBytesRead = 0;

            while (numBytesRead != count)
                numBytesRead += StreamResource.Read(frameBytes, numBytesRead, count - numBytesRead);

            return frameBytes;
        }

Original issue reported on code.google.com by AlexKing...@gmail.com on 3 Aug 2010 at 3:32

GoogleCodeExporter commented 8 years ago
I think StreamResource will throw if nothing is read, there's no reason to 
worry.

Original comment by pascal.b...@gmail.com on 16 Sep 2010 at 7:26