better readbility
This commit is contained in:
@@ -290,11 +290,9 @@ result_t Device::recv(unsigned int timeout, symbol_t* value, ArbitrationState* a
|
|||||||
cancelRunningArbitration(arbitrationState);
|
cancelRunningArbitration(arbitrationState);
|
||||||
return RESULT_ERR_DEVICE;
|
return RESULT_ERR_DEVICE;
|
||||||
}
|
}
|
||||||
bool repeat = false;
|
|
||||||
bool repeated = false;
|
bool repeated = false;
|
||||||
timeout += m_latency;
|
timeout += m_latency;
|
||||||
do {
|
do {
|
||||||
repeat = false;
|
|
||||||
bool isAvailable = available();
|
bool isAvailable = available();
|
||||||
if (!isAvailable && timeout > 0) {
|
if (!isAvailable && timeout > 0) {
|
||||||
int ret;
|
int ret;
|
||||||
@@ -347,17 +345,17 @@ result_t Device::recv(unsigned int timeout, symbol_t* value, ArbitrationState* a
|
|||||||
|
|
||||||
// directly read byte from device
|
// directly read byte from device
|
||||||
bool incomplete = false;
|
bool incomplete = false;
|
||||||
if (!read(value, isAvailable, arbitrationState, &incomplete)) {
|
if (read(value, isAvailable, arbitrationState, &incomplete)) {
|
||||||
|
break; // don't repeat on successful read
|
||||||
|
}
|
||||||
if (!isAvailable && incomplete && !repeated) {
|
if (!isAvailable && incomplete && !repeated) {
|
||||||
// for a two-byte transfer another poll is needed
|
// for a two-byte transfer another poll is needed
|
||||||
repeat = true;
|
|
||||||
repeated = true;
|
repeated = true;
|
||||||
timeout = m_latency+ENHANCED_COMPLETE_WAIT_DURATION;
|
timeout = m_latency+ENHANCED_COMPLETE_WAIT_DURATION;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return RESULT_ERR_TIMEOUT;
|
return RESULT_ERR_TIMEOUT;
|
||||||
}
|
} while (true);
|
||||||
} while (repeat);
|
|
||||||
if (m_enhancedProto || *value != SYN || m_arbitrationMaster == SYN) {
|
if (m_enhancedProto || *value != SYN || m_arbitrationMaster == SYN) {
|
||||||
if (m_listener != nullptr) {
|
if (m_listener != nullptr) {
|
||||||
m_listener->notifyDeviceData(*value, true);
|
m_listener->notifyDeviceData(*value, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user