dev_Check()
Check if any layer in a device is not in data transfer state.
#include "device.h" LResult dev_Check ( LDevice device );
device | device to check |
dev_Check() checks each layer in the device from the bottom up. If any layer is not in data transfer state, the protocol id of the layer is returned. dev_Check() is intended to be used in conjunction with dev_Fix() to provide incremental recovery from the loss of a connection. dev_Check() will attach the device, if necessary, and leave it in the same condition in which it found it.
If successful, dev_Check() returns a non-negative value. If the value is 0, all layers are in data transfer state. If the value is positive, it is the protocol id of the lowest layer not in data transfer state. Otherwise, it returns a negative value indicating the reason it failed. Possible unsuccessful return values are:
if (dev_IsConnected(device)) { if ((result = dev_Check(device)) < 0) { LOG("Device check failed", lgo_ProtocolMessage(result)); } else if (result != 0) { LOG("Device failure"); if (dev_Fix(device) < 0) { LOG("Cannot restore service"); } else { LOG("Service restored"); } } else { LOG("Device OK"); } }