From eb574cf1816df79905861dd4e61241c17e35556a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20M=C3=A5rtensson?=
Date: Sun, 16 Jul 2023 17:14:59 +0200
Subject: [PATCH] Add closedown function
---
Src/Open_SAE_J1939/Closedown_ECU.c | 19 +++++++++++++++++++
Src/Open_SAE_J1939/Open_SAE_J1939.h | 3 +++
2 files changed, 22 insertions(+)
create mode 100644 Src/Open_SAE_J1939/Closedown_ECU.c
diff --git a/Src/Open_SAE_J1939/Closedown_ECU.c b/Src/Open_SAE_J1939/Closedown_ECU.c
new file mode 100644
index 0000000..16660df
--- /dev/null
+++ b/Src/Open_SAE_J1939/Closedown_ECU.c
@@ -0,0 +1,19 @@
+/*
+ * Closedown_ECU.c
+ *
+ * Created on: 16 Juli. 2023
+ * Author: Daniel M�rtensson
+ */
+
+#include "Open_SAE_J1939.h"
+
+ /* Layers */
+#include "../Hardware/Hardware.h"
+
+/* Save our ECU parameters into J1939 structure. Very useful if you want your ECU remember its NAME + address + identifications at startup. */
+bool Open_SAE_J1939_Closedown_ECU(J1939* j1939) {
+ uint32_t ECU_information_length = sizeof(Information_this_ECU);
+ uint8_t ECU_information_data[sizeof(Information_this_ECU)];
+ memcpy(ECU_information_data, (uint8_t*)&j1939->information_this_ECU, ECU_information_length);
+ return Save_Struct(ECU_information_data, ECU_information_length, (char*)INFORMATION_THIS_ECU);
+}
\ No newline at end of file
diff --git a/Src/Open_SAE_J1939/Open_SAE_J1939.h b/Src/Open_SAE_J1939/Open_SAE_J1939.h
index 3e034d4..9e2acd7 100644
--- a/Src/Open_SAE_J1939/Open_SAE_J1939.h
+++ b/Src/Open_SAE_J1939/Open_SAE_J1939.h
@@ -27,6 +27,9 @@ bool Open_SAE_J1939_Listen_For_Messages(J1939 *j1939);
/* This function should ONLY be called at your ECU startup */
bool Open_SAE_J1939_Startup_ECU(J1939* j1939);
+/* This function should ONLY be called at your ECU closedown */
+bool Open_SAE_J1939_Closedown_ECU(J1939* j1939);
+
#ifdef __cplusplus
}
#endif