reset the connection completely if adapter was reset

This commit is contained in:
John
2022-08-31 20:24:01 +02:00
parent 31241ebec3
commit b1893abe7d
2 changed files with 15 additions and 1 deletions
+13 -1
View File
@@ -80,7 +80,8 @@ Device::Device(const char* name, bool checkDevice, unsigned int latency, bool re
bool enhancedProto)
: m_name(name), m_checkDevice(checkDevice),
m_latency(HOST_LATENCY_MS+(enhancedProto?ENHANCED_LATENCY_MS:0)+latency), m_readOnly(readOnly),
m_initialSend(initialSend), m_enhancedProto(enhancedProto), m_fd(-1), m_listener(nullptr), m_arbitrationMaster(SYN),
m_initialSend(initialSend), m_enhancedProto(enhancedProto), m_fd(-1), m_resetRequested(false),
m_listener(nullptr), m_arbitrationMaster(SYN),
m_arbitrationCheck(0), m_bufSize(((MAX_LEN+1+3)/4)*4), m_bufLen(0), m_bufPos(0),
m_extraFatures(0), m_infoId(0xff), m_infoLen(0), m_infoPos(0) {
m_buffer = reinterpret_cast<symbol_t*>(malloc(m_bufSize));
@@ -158,6 +159,7 @@ result_t Device::afterOpen() {
if (m_listener != nullptr) {
m_listener->notifyStatus(false, "resetting");
}
m_resetRequested = true;
} else if (m_initialSend && !write(ESC)) {
return RESULT_ERR_SEND;
}
@@ -612,6 +614,16 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
m_arbitrationMaster = SYN;
m_arbitrationCheck = 0;
}
m_enhInfoTemperature = "";
m_enhInfoSupplyVoltage = "";
m_enhInfoBusVoltage = "";
m_infoId = 0xff;
if (m_resetRequested) {
m_resetRequested = false;
} else {
close(); // on self-reset of device close and reopen it to have a clean startup
cancelRunningArbitration(arbitrationState);
}
m_extraFatures = data;
if (m_listener != nullptr) {
m_listener->notifyStatus(false, (m_extraFatures&0x01) ? "reset, supports info" : "reset");
+2
View File
@@ -283,6 +283,8 @@ class Device {
/** the opened file descriptor, or -1. */
int m_fd;
/** whether the reset of an enhanced device was already requested. */
bool m_resetRequested;
private:
/** the @a DeviceListener, or nullptr. */