Event: Better error message for USB powered devices
parent
f629125e67
commit
0ce52f064b
|
|
@ -73,7 +73,10 @@ static constexpr const char* VALUE_NOT_YET_PRESENT = "The value is not yet prese
|
||||||
|
|
||||||
// Device Errors
|
// Device Errors
|
||||||
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||||
static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered with 12 volts?";
|
static constexpr const char* NO_SERIAL_NUMBER_FW_12V = "Communication could not be established with the device. Perhaps it is not powered with 12 volts?";
|
||||||
|
static constexpr const char* NO_SERIAL_NUMBER_FW = "Communication could not be established with the device. Perhaps it is not powered?";
|
||||||
|
static constexpr const char* NO_SERIAL_NUMBER_12V = "Communication could not be established with the device. Perhaps it is not powered with 12 volts or requires a firmware update using Vehicle Spy.";
|
||||||
|
static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered or requires a firmware update using Vehicle Spy.";
|
||||||
static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
|
static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
|
||||||
static constexpr const char* SETTINGS_READ = "The device settings could not be read.";
|
static constexpr const char* SETTINGS_READ = "The device settings could not be read.";
|
||||||
static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with neoVI Explorer.";
|
static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with neoVI Explorer.";
|
||||||
|
|
@ -202,6 +205,12 @@ const char* APIEvent::DescriptionForType(Type type) {
|
||||||
return TERMINATION_NOT_SUPPORTED_NETWORK;
|
return TERMINATION_NOT_SUPPORTED_NETWORK;
|
||||||
case Type::AnotherInTerminationGroupEnabled:
|
case Type::AnotherInTerminationGroupEnabled:
|
||||||
return ANOTHER_IN_TERMINATION_GROUP_ENABLED;
|
return ANOTHER_IN_TERMINATION_GROUP_ENABLED;
|
||||||
|
case Type::NoSerialNumberFW:
|
||||||
|
return NO_SERIAL_NUMBER_FW;
|
||||||
|
case Type::NoSerialNumber12V:
|
||||||
|
return NO_SERIAL_NUMBER_12V;
|
||||||
|
case Type::NoSerialNumberFW12V:
|
||||||
|
return NO_SERIAL_NUMBER_FW_12V;
|
||||||
|
|
||||||
// Transport Errors
|
// Transport Errors
|
||||||
case Type::FailedToRead:
|
case Type::FailedToRead:
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ APIEvent::Type Device::attemptToBeginCommunication() {
|
||||||
// Very unlikely, at the time of writing this only fails if rawWrite does.
|
// 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.
|
// If you're looking for this error, you're probably looking for if(!serial) below.
|
||||||
// "Communication could not be established with the device. Perhaps it is not powered with 12 volts?"
|
// "Communication could not be established with the device. Perhaps it is not powered with 12 volts?"
|
||||||
return APIEvent::Type::NoSerialNumber;
|
return getCommunicationNotEstablishedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto serial = com->getSerialNumberSync();
|
auto serial = com->getSerialNumberSync();
|
||||||
|
|
@ -281,7 +281,7 @@ APIEvent::Type Device::attemptToBeginCommunication() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!serial) // "Communication could not be established with the device. Perhaps it is not powered with 12 volts?"
|
if(!serial) // "Communication could not be established with the device. Perhaps it is not powered with 12 volts?"
|
||||||
return APIEvent::Type::NoSerialNumber;
|
return getCommunicationNotEstablishedError();
|
||||||
|
|
||||||
std::string currentSerial = getNeoDevice().serial;
|
std::string currentSerial = getNeoDevice().serial;
|
||||||
if(currentSerial != serial->deviceSerial)
|
if(currentSerial != serial->deviceSerial)
|
||||||
|
|
@ -726,6 +726,32 @@ void Device::handleNeoVIMessage(std::shared_ptr<CANMessage> message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::firmwareUpdateSupported() {
|
||||||
|
bool ret = false;
|
||||||
|
forEachExtension([&ret](const std::shared_ptr<DeviceExtension>& ext) {
|
||||||
|
if(ext->providesFirmware()) {
|
||||||
|
ret = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true; // false breaks out early
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
APIEvent::Type Device::getCommunicationNotEstablishedError() {
|
||||||
|
if(firmwareUpdateSupported()) {
|
||||||
|
if(requiresVehiclePower())
|
||||||
|
return APIEvent::Type::NoSerialNumberFW12V;
|
||||||
|
else
|
||||||
|
return APIEvent::Type::NoSerialNumberFW;
|
||||||
|
} else {
|
||||||
|
if(requiresVehiclePower())
|
||||||
|
return APIEvent::Type::NoSerialNumber12V;
|
||||||
|
else
|
||||||
|
return APIEvent::Type::NoSerialNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Device::updateLEDState() {
|
void Device::updateLEDState() {
|
||||||
std::vector<uint8_t> args {(uint8_t) ledState};
|
std::vector<uint8_t> args {(uint8_t) ledState};
|
||||||
com->sendCommand(Command::UpdateLEDState, args);
|
com->sendCommand(Command::UpdateLEDState, args);
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ public:
|
||||||
TerminationNotSupportedDevice = 0x2024,
|
TerminationNotSupportedDevice = 0x2024,
|
||||||
TerminationNotSupportedNetwork = 0x2025,
|
TerminationNotSupportedNetwork = 0x2025,
|
||||||
AnotherInTerminationGroupEnabled = 0x2026,
|
AnotherInTerminationGroupEnabled = 0x2026,
|
||||||
|
NoSerialNumberFW = 0x2027, // A firmware update was already attempted
|
||||||
|
NoSerialNumber12V = 0x2028, // The device must be powered with 12V for communication to be established
|
||||||
|
NoSerialNumberFW12V = 0x2029, // The device must be powered with 12V for communication to be established, a firmware update was already attempted
|
||||||
|
|
||||||
// Transport Events
|
// Transport Events
|
||||||
FailedToRead = 0x3000,
|
FailedToRead = 0x3000,
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,8 @@ protected:
|
||||||
// Return false to bail
|
// Return false to bail
|
||||||
virtual bool afterCommunicationOpen() { return true; }
|
virtual bool afterCommunicationOpen() { return true; }
|
||||||
|
|
||||||
|
virtual bool requiresVehiclePower() const { return true; }
|
||||||
|
|
||||||
template<typename Extension>
|
template<typename Extension>
|
||||||
std::shared_ptr<Extension> getExtension() const {
|
std::shared_ptr<Extension> getExtension() const {
|
||||||
std::shared_ptr<Extension> ret;
|
std::shared_ptr<Extension> ret;
|
||||||
|
|
@ -292,6 +294,10 @@ private:
|
||||||
|
|
||||||
void handleNeoVIMessage(std::shared_ptr<CANMessage> message);
|
void handleNeoVIMessage(std::shared_ptr<CANMessage> message);
|
||||||
|
|
||||||
|
bool firmwareUpdateSupported();
|
||||||
|
|
||||||
|
APIEvent::Type getCommunicationNotEstablishedError();
|
||||||
|
|
||||||
enum class LEDState : uint8_t {
|
enum class LEDState : uint8_t {
|
||||||
Offline = 0x04,
|
Offline = 0x04,
|
||||||
CoreMiniRunning = 0x08, // This should override "offline" if the CoreMini is running
|
CoreMiniRunning = 0x08, // This should override "offline" if the CoreMini is running
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public:
|
||||||
virtual void onGoOffline() {}
|
virtual void onGoOffline() {}
|
||||||
virtual void onDeviceClose() {}
|
virtual void onDeviceClose() {}
|
||||||
|
|
||||||
|
virtual bool providesFirmware() const { return false; }
|
||||||
|
|
||||||
virtual void handleMessage(const std::shared_ptr<Message>&) {}
|
virtual void handleMessage(const std::shared_ptr<Message>&) {}
|
||||||
|
|
||||||
// Return true to continue transmitting, success should be written to if false is returned
|
// Return true to continue transmitting, success should be written to if false is returned
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ protected:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ private:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ private:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,8 @@ protected:
|
||||||
Device::setupDecoder(decoder);
|
Device::setupDecoder(decoder);
|
||||||
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ protected:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ protected:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ protected:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ private:
|
||||||
|
|
||||||
// The supported TX networks are the same as the supported RX networks for this device
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {}
|
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {}
|
||||||
|
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool requiresVehiclePower() const override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VividCAN(neodevice_t neodevice) : Device(neodevice) {
|
VividCAN(neodevice_t neodevice) : Device(neodevice) {
|
||||||
initialize<STM32, VividCANSettings>();
|
initialize<STM32, VividCANSettings>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue