Added more error logging
parent
dc4f96affb
commit
255e1e2b90
|
|
@ -49,6 +49,11 @@ static constexpr const char* ERROR_OUTPUT_TRUNCATED = "The output was too large
|
|||
static constexpr const char* ERROR_PARAMETER_OUT_OF_RANGE = "A parameter was out of range.";
|
||||
static constexpr const char* ERROR_DEVICE_CURRENTLY_OPEN = "The device is currently open. Perhaps a different device state was required.";
|
||||
static constexpr const char* ERROR_DEVICE_CURRENTLY_CLOSED = "The device is currently closed. Perhaps a different device state was required.";
|
||||
static constexpr const char* ERROR_DEVICE_CURRENTLY_ONLINE = "The device is currently online. Perhaps a different device state was required.";
|
||||
static constexpr const char* ERROR_DEVICE_CURRENTLY_OFFLINE = "The device is currently offline. Perhaps a different device state was required.";
|
||||
static constexpr const char* ERROR_DEVICE_NOT_POLLING = "The device is not currently polling for messages.";
|
||||
static constexpr const char* ERROR_UNSUPPORTED_TX_NETWORK = "Message network is not a supported TX network.";
|
||||
static constexpr const char* ERROR_MESSAGE_MAX_LENGTH_EXCEEDED = "The message was too long.";
|
||||
|
||||
// Device Errors
|
||||
static constexpr const char* ERROR_POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||
|
|
@ -71,7 +76,6 @@ static constexpr const char* ERROR_SETTINGS_STRUCTURE_MISMATCH = "Unexpected set
|
|||
static constexpr const char* ERROR_SETTINGS_STRUCTURE_TRUNCATED = "Settings structure is longer than the device supports and will be truncated.";
|
||||
static constexpr const char* ERROR_NO_DEVICE_RESPONSE = "Expected a response from the device but none were found.";
|
||||
static constexpr const char* ERROR_MESSAGE_FORMATTING = "The message was not properly formed.";
|
||||
static constexpr const char* ERROR_MESSAGE_DATA_OVER_CAPACITY = "The message has too much data for the protocol.";
|
||||
static constexpr const char* ERROR_CANFD_NOT_SUPPORTED = "This device does not support CANFD.";
|
||||
static constexpr const char* ERROR_RTR_NOT_SUPPORTED = "RTR is not supported with CANFD.";
|
||||
|
||||
|
|
@ -105,7 +109,17 @@ const char* APIError::DescriptionForType(ErrorType type) {
|
|||
return ERROR_DEVICE_CURRENTLY_OPEN;
|
||||
case DeviceCurrentlyClosed:
|
||||
return ERROR_DEVICE_CURRENTLY_CLOSED;
|
||||
|
||||
case DeviceCurrentlyOnline:
|
||||
return ERROR_DEVICE_CURRENTLY_ONLINE;
|
||||
case DeviceCurrentlyOffline:
|
||||
return ERROR_DEVICE_CURRENTLY_OFFLINE;
|
||||
case DeviceNotPolling:
|
||||
return ERROR_DEVICE_NOT_POLLING;
|
||||
case UnsupportedTXNetwork:
|
||||
return ERROR_UNSUPPORTED_TX_NETWORK;
|
||||
case MessageMaxLengthExceeded:
|
||||
return ERROR_MESSAGE_MAX_LENGTH_EXCEEDED;
|
||||
|
||||
// Device Errors
|
||||
case PollingMessageOverflow:
|
||||
return ERROR_POLLING_MESSAGE_OVERFLOW;
|
||||
|
|
@ -147,8 +161,6 @@ const char* APIError::DescriptionForType(ErrorType type) {
|
|||
return ERROR_NO_DEVICE_RESPONSE;
|
||||
case MessageFormattingError:
|
||||
return ERROR_MESSAGE_FORMATTING;
|
||||
case MessageDataOverCapacity:
|
||||
return ERROR_MESSAGE_DATA_OVER_CAPACITY;
|
||||
case CANFDNotSupported:
|
||||
return ERROR_CANFD_NOT_SUPPORTED;
|
||||
case RTRNotSupported:
|
||||
|
|
@ -188,6 +200,9 @@ APIError::Severity APIError::SeverityForType(ErrorType type) {
|
|||
case OutputTruncated:
|
||||
case DeviceCurrentlyOpen:
|
||||
case DeviceCurrentlyClosed:
|
||||
case DeviceCurrentlyOnline:
|
||||
case DeviceCurrentlyOffline:
|
||||
case DeviceNotPolling:
|
||||
// Device Warnings
|
||||
case PollingMessageOverflow:
|
||||
case DeviceFirmwareOutOfDate:
|
||||
|
|
@ -202,7 +217,9 @@ APIError::Severity APIError::SeverityForType(ErrorType type) {
|
|||
case RequiredParameterNull:
|
||||
case BufferInsufficient:
|
||||
case ParameterOutOfRange:
|
||||
|
||||
case UnsupportedTXNetwork:
|
||||
case MessageMaxLengthExceeded:
|
||||
|
||||
// Device Errors
|
||||
case NoSerialNumber:
|
||||
case IncorrectSerialNumber:
|
||||
|
|
@ -221,7 +238,6 @@ APIError::Severity APIError::SeverityForType(ErrorType type) {
|
|||
case SettingsStructureMismatch:
|
||||
case NoDeviceResponse:
|
||||
case MessageFormattingError:
|
||||
case MessageDataOverCapacity:
|
||||
case CANFDNotSupported:
|
||||
case RTRNotSupported:
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector
|
|||
|
||||
const size_t dataSize = message.data.size();
|
||||
if(dataSize > 64 || (dataSize > 8 && !message.isCANFD)) {
|
||||
err(APIError::MessageDataOverCapacity);
|
||||
err(APIError::MessageMaxLengthExceeded);
|
||||
return false; // Too much data for the protocol
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector
|
|||
lengthNibble = 0xF;
|
||||
break;
|
||||
default:
|
||||
err(APIError::Unknown);
|
||||
err(APIError::MessageMaxLengthExceeded);
|
||||
return false; // CAN FD frame may have had an incorrect byte count
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,12 @@ public:
|
|||
ParameterOutOfRange = 0x1004,
|
||||
DeviceCurrentlyOpen = 0x1005,
|
||||
DeviceCurrentlyClosed = 0x1006,
|
||||
|
||||
DeviceCurrentlyOnline = 0x1007,
|
||||
DeviceCurrentlyOffline = 0x1008,
|
||||
DeviceNotPolling = 0x1009,
|
||||
UnsupportedTXNetwork = 0x1010,
|
||||
MessageMaxLengthExceeded = 0x1011,
|
||||
|
||||
// Device Errors
|
||||
PollingMessageOverflow = 0x2000,
|
||||
NoSerialNumber = 0x2001,
|
||||
|
|
@ -62,9 +67,8 @@ public:
|
|||
SettingsStructureTruncated = 0x2017,
|
||||
NoDeviceResponse = 0x2018,
|
||||
MessageFormattingError = 0x2019,
|
||||
MessageDataOverCapacity = 0x2020,
|
||||
CANFDNotSupported = 0x2021,
|
||||
RTRNotSupported = 0x2022,
|
||||
CANFDNotSupported = 0x2020,
|
||||
RTRNotSupported = 0x2021,
|
||||
|
||||
// Transport Errors
|
||||
FailedToRead = 0x3000,
|
||||
|
|
|
|||
Loading…
Reference in New Issue