Fix an issue where the FIRE could not be opened
parent
7a71a35848
commit
dcc44d99ea
|
|
@ -168,6 +168,14 @@ bool Device::open() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!afterCommunicationOpen()) {
|
||||
// Very unlikely, at the time of writing this only fails if rawWrite does.
|
||||
// If you're looking for this error, you're probably looking for if(!serial) below.
|
||||
report(APIEvent::Type::NoSerialNumber, APIEvent::Severity::Error); // Communication could not be established with the device. Perhaps it is not powered with 12 volts?
|
||||
com->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto serial = com->getSerialNumberSync();
|
||||
int i = 0;
|
||||
while(!serial) {
|
||||
|
|
|
|||
|
|
@ -166,6 +166,10 @@ protected:
|
|||
|
||||
virtual void setupExtensions() {}
|
||||
void addExtension(std::shared_ptr<DeviceExtension>&& extension);
|
||||
|
||||
// Hook for devices such as FIRE which need to inject traffic before RequestSerialNumber
|
||||
// Return false to bail
|
||||
virtual bool afterCommunicationOpen() { return true; }
|
||||
|
||||
template<typename Extension>
|
||||
std::shared_ptr<Extension> getExtension() const {
|
||||
|
|
|
|||
|
|
@ -45,18 +45,12 @@ public:
|
|||
Bootloader = 'B'
|
||||
};
|
||||
|
||||
bool open() override {
|
||||
if(!com)
|
||||
return false;
|
||||
|
||||
if(!com->open())
|
||||
bool afterCommunicationOpen() override {
|
||||
if(!Device::afterCommunicationOpen()) // Doesn't do anything right now but just in case it gets added to later
|
||||
return false;
|
||||
|
||||
// Enter mode is only needed on very old FIRE devices (white board), will be ignored by newer devices
|
||||
if(!enterMode(Mode::Application))
|
||||
return false;
|
||||
|
||||
return Device::open();
|
||||
return enterMode(Mode::Application);
|
||||
}
|
||||
|
||||
bool enterMode(Mode mode) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue