From 2806c935f1c3c48195f13589c5404153140f1988 Mon Sep 17 00:00:00 2001 From: EricLiu2000 Date: Mon, 10 Jun 2019 16:27:45 -0400 Subject: [PATCH] Added errors for DeviceCurrentlyOpen and DeviceCurrentlyClosed --- api/icsneocpp/error.cpp | 13 +++++++++++++ include/icsneo/api/error.h | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/icsneocpp/error.cpp b/api/icsneocpp/error.cpp index 7833f82..3812458 100644 --- a/api/icsneocpp/error.cpp +++ b/api/icsneocpp/error.cpp @@ -47,6 +47,8 @@ static constexpr const char* ERROR_REQUIRED_PARAMETER_NULL = "A required paramet static constexpr const char* ERROR_BUFFER_INSUFFICIENT = "The provided buffer was insufficient. No data was written."; static constexpr const char* ERROR_OUTPUT_TRUNCATED = "The output was too large for the provided buffer and has been truncated."; 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."; // 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!"; @@ -62,6 +64,7 @@ static constexpr const char* ERROR_SETTINGS_NOT_AVAILABLE = "Settings are not av static constexpr const char* ERROR_FAILED_TO_READ = "A read operation failed."; static constexpr const char* ERROR_FAILED_TO_WRITE = "A write operation failed."; static constexpr const char* ERROR_DRIVER_FAILED_TO_OPEN = "The device driver encountered a low-level error while opening the device."; +static constexpr const char* ERROR_DRIVER_FAILED_TO_CLOSE = "The device driver encountered a low-level error while closing the device."; static constexpr const char* ERROR_PACKET_CHECKSUM_ERROR = "There was a checksum error while decoding a packet. The packet was dropped."; static constexpr const char* ERROR_TRANSMIT_BUFFER_FULL = "The transmit buffer is full and the device is set to non-blocking."; static constexpr const char* ERROR_PCAP_COULD_NOT_START = "The PCAP driver could not be started. Ethernet devices will not be found."; @@ -83,6 +86,10 @@ const char* APIError::DescriptionForType(ErrorType type) { return ERROR_OUTPUT_TRUNCATED; case ParameterOutOfRange: return ERROR_PARAMETER_OUT_OF_RANGE; + case DeviceCurrentlyOpen: + return ERROR_DEVICE_CURRENTLY_OPEN; + case DeviceCurrentlyClosed: + return ERROR_DEVICE_CURRENTLY_CLOSED; // Device Errors case PollingMessageOverflow: @@ -109,6 +116,8 @@ const char* APIError::DescriptionForType(ErrorType type) { return ERROR_FAILED_TO_WRITE; case DriverFailedToOpen: return ERROR_DRIVER_FAILED_TO_OPEN; + case DriverFailedToClose: + return ERROR_DRIVER_FAILED_TO_CLOSE; case PacketChecksumError: return ERROR_PACKET_CHECKSUM_ERROR; case TransmitBufferFull: @@ -132,6 +141,8 @@ APIError::Severity APIError::SeverityForType(ErrorType type) { switch(type) { // API Warnings case OutputTruncated: + case DeviceCurrentlyOpen: + case DeviceCurrentlyClosed: // Device Warnings case PollingMessageOverflow: // Transport Warnings @@ -144,6 +155,7 @@ APIError::Severity APIError::SeverityForType(ErrorType type) { case RequiredParameterNull: case BufferInsufficient: case ParameterOutOfRange: + // Device Errors case NoSerialNumber: case IncorrectSerialNumber: @@ -156,6 +168,7 @@ APIError::Severity APIError::SeverityForType(ErrorType type) { case FailedToRead: case FailedToWrite: case DriverFailedToOpen: + case DriverFailedToClose: case PacketChecksumError: case TransmitBufferFull: // Other Errors diff --git a/include/icsneo/api/error.h b/include/icsneo/api/error.h index 6aed07b..713be79 100644 --- a/include/icsneo/api/error.h +++ b/include/icsneo/api/error.h @@ -38,6 +38,8 @@ public: BufferInsufficient = 0x1002, OutputTruncated = 0x1003, ParameterOutOfRange = 0x1004, + DeviceCurrentlyOpen = 0x1005, + DeviceCurrentlyClosed = 0x1006, // Device Errors PollingMessageOverflow = 0x2000, @@ -53,8 +55,9 @@ public: FailedToRead = 0x3000, FailedToWrite = 0x3001, DriverFailedToOpen = 0x3002, - PacketChecksumError = 0x3003, - TransmitBufferFull = 0x3004, + DriverFailedToClose = 0x3003, + PacketChecksumError = 0x3004, + TransmitBufferFull = 0x3005, PCAPCouldNotStart = 0x3102, PCAPCouldNotFindDevices = 0x3103,