VividCAN: Better "Online Not Supported" Error

pull/32/head
Paul Hollinsky 2020-09-08 17:39:47 -04:00
parent 3f8ed840ba
commit de0c16a461
3 changed files with 14 additions and 1 deletions

View File

@ -94,6 +94,7 @@ static constexpr const char* MESSAGE_FORMATTING = "The message was not properly
static constexpr const char* CANFD_NOT_SUPPORTED = "This device does not support CANFD."; static constexpr const char* CANFD_NOT_SUPPORTED = "This device does not support CANFD.";
static constexpr const char* RTR_NOT_SUPPORTED = "RTR is not supported with CANFD."; static constexpr const char* RTR_NOT_SUPPORTED = "RTR is not supported with CANFD.";
static constexpr const char* DEVICE_DISCONNECTED = "The device was disconnected."; static constexpr const char* DEVICE_DISCONNECTED = "The device was disconnected.";
static constexpr const char* ONLINE_NOT_SUPPORTED = "This device does not support going online.";
// Transport Errors // Transport Errors
static constexpr const char* FAILED_TO_READ = "A read operation failed."; static constexpr const char* FAILED_TO_READ = "A read operation failed.";
@ -187,6 +188,8 @@ const char* APIEvent::DescriptionForType(Type type) {
return RTR_NOT_SUPPORTED; return RTR_NOT_SUPPORTED;
case Type::DeviceDisconnected: case Type::DeviceDisconnected:
return DEVICE_DISCONNECTED; return DEVICE_DISCONNECTED;
case Type::OnlineNotSupported:
return ONLINE_NOT_SUPPORTED;
// Transport Errors // Transport Errors
case Type::FailedToRead: case Type::FailedToRead:

View File

@ -71,6 +71,7 @@ public:
CANFDNotSupported = 0x2020, CANFDNotSupported = 0x2020,
RTRNotSupported = 0x2021, RTRNotSupported = 0x2021,
DeviceDisconnected = 0x2022, DeviceDisconnected = 0x2022,
OnlineNotSupported = 0x2023,
// Transport Events // Transport Events
FailedToRead = 0x3000, FailedToRead = 0x3000,

View File

@ -23,7 +23,16 @@ public:
return found; return found;
} }
bool goOnline() override { return false; } // VividCAN does not go online, you can only set settings
bool goOnline() override {
report(APIEvent::Type::OnlineNotSupported, APIEvent::Severity::Error);
return false;
}
bool goOffline() override {
report(APIEvent::Type::OnlineNotSupported, APIEvent::Severity::Error);
return false;
}
private: private:
VividCAN(neodevice_t neodevice) : Device(neodevice) { VividCAN(neodevice_t neodevice) : Device(neodevice) {