Adding communication error detect function

Error detect and recovery