How to recover from ReadFromPipeOut error

Hello,

I am using ReadFromPipeOut() to transfer data from a XEM6310-LX45 to the PC continuously. The system generally works well. Sometime ReadFromPipeOut( ) returns -2 when SetWireInValue() is used. My question is how to recover from ReadFromPipeOut returning error. Thanks!