J2534_WIN: Fix application hang on unexpected USB removal.

master
Jessy Diamond Exum 2017-09-15 21:39:38 -07:00
parent 3944a81c84
commit de294ccbf7
2 changed files with 3 additions and 0 deletions

View File

@ -420,6 +420,8 @@ bool Panda::can_recv_async(HANDLE kill_event, std::vector<PANDA_CAN_MSG>& msg_bu
}
return TRUE;
}
} else { // ERROR_BAD_COMMAND happens when device is unplugged.
return FALSE;
}
}

View File

@ -18,6 +18,7 @@ PandaJ2534Device::~PandaJ2534Device() {
SetEvent(this->can_kill_event);
DWORD res = WaitForSingleObject(this->can_thread_handle, INFINITE);
CloseHandle(this->can_thread_handle);
CloseHandle(this->can_kill_event);
}
std::unique_ptr<PandaJ2534Device> PandaJ2534Device::openByName(std::string sn) {