From 3a0d40729383c42af1cef194abc56182955fb9c9 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 24 4月 2016 16:57:16 +0800 Subject: [PATCH] Fix test and examples to work with extended errors --- libscpi/src/error.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libscpi/src/error.c b/libscpi/src/error.c index fedf795..8913ab8 100644 --- a/libscpi/src/error.c +++ b/libscpi/src/error.c @@ -123,9 +123,15 @@ } static scpi_bool_t SCPI_ErrorAddInternal(scpi_t * context, int16_t err, char * info) { - if (!fifo_add(&context->error_queue, err, info)) { - fifo_remove_last(&context->error_queue, NULL); - fifo_add(&context->error_queue, SCPI_ERROR_QUEUE_OVERFLOW, NULL); + scpi_error_t error_value; + error_value.error_code = err; + error_value.device_dependent_info = info; + if (!fifo_add(&context->error_queue, &error_value)) { + fifo_remove_last(&context->error_queue, &error_value); + // TODO free device_dependent_info + error_value.error_code = SCPI_ERROR_QUEUE_OVERFLOW; + error_value.device_dependent_info = NULL; + fifo_add(&context->error_queue, &error_value); return FALSE; } return TRUE; @@ -211,14 +217,14 @@ #else #define XE(def, val, str) #endif - LIST_OF_ERRORS + LIST_OF_ERRORS #if USE_USER_ERROR_LIST - LIST_OF_USER_ERRORS + LIST_OF_USER_ERRORS #endif #undef X #undef XE - default: return "Unknown error"; + default: return "Unknown error"; } } -- Gitblit v1.9.1