From 34d681a00a7fc3c8d82a5ba3082dd5524f2a8389 Mon Sep 17 00:00:00 2001
From: Chernov Dmitriy <cd_work@mail.ru>
Date: 周二, 01 3月 2016 21:26:22 +0800
Subject: [PATCH] The basic implementation completed. Tests are needed. (issue #73)

---
 libscpi/src/parser.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c
index fd85e47..00cba78 100644
--- a/libscpi/src/parser.c
+++ b/libscpi/src/parser.c
@@ -219,10 +219,11 @@
                 result &= processCommand(context);
                 cmd_prev = state->programHeader;
             } else {
-                //SCPI_ErrorPush(context, SCPI_ERROR_UNDEFINED_HEADER);
 				/* test */
-				data[r-1]=0;
+				/* place undefined header with error */
+				data[r?(r-1):r]=0;
 				SCPI_ErrorPushEx(context, SCPI_ERROR_UNDEFINED_HEADER, data);
+                //SCPI_ErrorPush(context, SCPI_ERROR_UNDEFINED_HEADER);				
                 result = FALSE;
             }
         }
@@ -511,15 +512,19 @@
 
 
 /**
- * Write string withn " to the result
+ * SCPI-99:21.8 Device-dependent error information.
+ * Write error information with the following syntax:
+ * <Error/event_number>,"<Error/event_description>[;<Device-dependent_info>]"
+ * The maximum string length of <Error/event_description> plus <Device-dependent_info>
+ * is SCPI_STD_ERROR_DESC_MAX_STRING_LENGTH (255) characters.
+ *
  * @param context
- * @param data
+ * @param error
  * @return
  */
-static size_t outputlimit_0=0;
 size_t SCPI_ResultError(scpi_t * context, scpi_error_t * error) {
  	size_t result = 0;
-	size_t outputlimit = outputlimit_0++; //SCPI_STD_ERROR_DESC_CHARS_LIMIT;
+	size_t outputlimit = SCPI_STD_ERROR_DESC_MAX_STRING_LENGTH;
 	size_t step = 0;
 	const char * quote;
 
@@ -531,11 +536,11 @@
 	
 #if USE_DEVICE_DEPENDENT_ERROR_INFORMATION
 	data[1] = error->device_dependent_info;
-	#if USE_MEMORY_ALLOCATION_FREE
-		len[1] = error->device_dependent_info ? strlen(data[1]) : 0;
-	#else
-		SCPIDEFINE_get_parts(&context->error_info_heap, data[1], &len[1], &data[2], &len[2]);
-	#endif
+#if USE_MEMORY_ALLOCATION_FREE
+	len[1] = error->device_dependent_info ? strlen(data[1]) : 0;
+#else
+	SCPIDEFINE_get_parts(&context->error_info_heap, data[1], &len[1], &data[2], &len[2]);
+#endif
 #endif
 
 	result += SCPI_ResultInt32(context, error->error_code);

--
Gitblit v1.9.1