# My Digital Signal Controller Library # The objective of MyDSC library is to implement controllers with help digital signal processors, digital signal controllers or mixed signals processors.

Dependents:   mydsc_sampling_example mydsc_sampling_example mydsc-serial-example mydsc-nonblocking-example

Files at this revision

API Documentation at this revision

Comitter:
ghsalazar
Date:
Sat Mar 28 16:09:15 2020 +0000
Parent:
3:b780db800303
Commit message:
Add error handling

Changed in this revision

include/mydsc_error.h Show annotated file Show diff for this revision Revisions of this file
include/mydsc_kvp.h Show annotated file Show diff for this revision Revisions of this file
src/mydsc_error.c Show annotated file Show diff for this revision Revisions of this file
src/mydsc_kvp.c Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/mydsc_error.h	Sat Mar 28 16:09:15 2020 +0000
@@ -0,0 +1,34 @@
+/** @file: mydsc_error.h
+    @author Gastón H. Salazar-Silva <gaston_salazar@yahoo.com>
+    
+    @brief A very basic error reporting system.
+**/
+
+#ifndef MYDSC_ERROR_H
+#define MYDSC_ERROR_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/// Error conditions on looking-up a key, or trying to setting the value.
+
+typedef enum {
+    MYDSC_SUCCESS,
+    MYDSC_KVP_NO_SET,
+    MYDSC_KVP_NO_KEY,
+    MYDSC_KVP_WRONG_VALUE
+} mydsc_errno_t;
+
+extern mydsc_errno_t mydsc_errno;
+
+extern char *mydsc_error[];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MYDSC_ERROR_H
--- a/include/mydsc_kvp.h	Mon Mar 09 15:56:21 2020 +0000
+++ b/include/mydsc_kvp.h	Sat Mar 28 16:09:15 2020 +0000
@@ -4,8 +4,10 @@
     @brief A very basic key-value pair system is implemented. 
 **/
 
-#ifndef MYDSC_kvp_H
-#define MYDSC_kvp_H
+#ifndef MYDSC_KVP_H
+#define MYDSC_KVP_H
+
+#include "mydsc_error.h"
 
 #include <stdint.h>
 
@@ -13,14 +15,6 @@
 extern "C" {
 #endif
 
-/// Error conditions on looking-up a key, or trying to setting the value.
-enum mydsc_kvp_errno_t {
-    MYDSC_KVP_SUCCESS       = 0,
-    MYDSC_KVP_NO_SET        = -1,
-    MYDSC_KVP_NO_KEY        = -2,
-    MYDSC_KVP_WRONG_VALUE   = -3                
-};
-
 /// The structure sets a linked list up.
 typedef struct mydsc_kvp_struct {
     char *key;
@@ -60,4 +54,4 @@
 }
 #endif
 
-#endif // MYDSC_RING_BUFFER_H
+#endif // MYDSC_KVP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mydsc_error.c	Sat Mar 28 16:09:15 2020 +0000
@@ -0,0 +1,11 @@
+#include "mydsc_error.h"
+
+mydsc_errno_t mydsc_errno = MYDSC_SUCCESS;
+
+char *mydsc_error[] ={
+    "Ok",
+    "key-value: Value can't be changed",
+    "key-value: There isn't such key",
+    "The value is wrong",
+    
+};
--- a/src/mydsc_kvp.c	Mon Mar 09 15:56:21 2020 +0000
+++ b/src/mydsc_kvp.c	Sat Mar 28 16:09:15 2020 +0000
@@ -1,4 +1,5 @@
 #include "mydsc_kvp.h"
+#include "mydsc_error.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -77,7 +78,7 @@
         node->set_function = set_function;
         node->next_kvp = NULL;
     }
-    return MYDSC_KVP_SUCCESS;
+    return MYDSC_SUCCESS;
 }
 
 static char* get_version(void)