Explorar el Código

testing eeprom

a.binder hace 5 años
padre
commit
4c1a7d95f5

+ 3 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/P5_Automation_can-dev-res-working-1930.ino

@@ -138,6 +138,9 @@ etc. To deactivate the Serial printing, define the macro empty:
 
 
 
+
+#include "___CONFIG/config_Active_Controller_EEPROM.h" //there kleep id of device
+
 #include "___CONFIG/config_Active_ControllerID.h" //there kleep id of device
 
 

+ 5 - 5
SE/stuff/P5_Automation_can-dev-res-working-1930/_CAN/_Slave_Ports_Protocol_CAN_struct.h

@@ -43,7 +43,7 @@ const int _CAN_8_EMPTY = 0x07 ;
  
  struct _Slave_Ports_Protocol_CAN_message_S {
   _CAN_REMOTE_ID_T _CAN_REMOTE_ID  ;   // 1remote id - use FF for broadcast
-    const _CAN_SENDER_ID_T _CAN_SENDER_ID = Active_ControllerID_HEX ; //2 sender //Device which orginated port 
+    const _CAN_SENDER_ID_T _CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A ;// Active_ControllerID_HEX ; //2 sender //Device which orginated port 
   int  Port_ID ; //3 global id for device //const char * const _Protocol;
   PortTypes_T  PortTypes;  //4 0xFF  =  1111 1111 s
   //int  Address ; //
@@ -58,7 +58,7 @@ const int _CAN_8_EMPTY = 0x07 ;
  
  struct _Slave_Ports_Protocol_CAN_broadcast_S {
   const _CAN_REMOTE_ID_T  _CAN_REMOTE_ID = _CAN_REMOTE_ID_BROADCAST ;   // 1remote id - use FF for broadcast
-  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = Active_ControllerID_HEX ; //2 sender //Device which orginated port 
+  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A ;//Active_ControllerID_HEX ; //2 sender //Device which orginated port 
   int  Port_ID ; //3 global id for device //const char * const _Protocol;
   PortTypes_T  PortTypes;  //4 0xFF  =  1111 1111 s
   //int  Address ; //
@@ -78,7 +78,7 @@ typedef struct _Slave_Ports_Protocol_CAN_broadcast_S _Slave_Ports_Protocol_CAN_b
  
  struct Slave_Ports_Protocol_CAN_request_confirm_Exp_state_S {
   const _CAN_REMOTE_ID_T  _CAN_REMOTE_ID = _CAN_REMOTE_ID_BROADCAST ; 
-  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = Active_ControllerID_HEX ; //2 sender //Device which orginated port 
+  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A ;//Active_ControllerID_HEX ; //2 sender //Device which orginated port 
   int  Port_ID ; //3 global id for device //const char * const _Protocol;
   PortTypes_T  PortTypes;  //4 0xFF  =  1111 1111 s
   Exp_state_T  Exp_state;    //5
@@ -97,7 +97,7 @@ typedef struct Slave_Ports_Protocol_CAN_request_confirm_Exp_state_S Slave_Ports_
  
  struct _Slave_Ports_Protocol_CAN_request_set_new_Exp_state_S {
   _CAN_REMOTE_ID_T  _CAN_REMOTE_ID ;   // 1remote id - use FF for broadcast
-  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = Active_ControllerID_HEX ; //2 sender //Device which orginated port 
+  const _CAN_SENDER_ID_T  _CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A ;//Active_ControllerID_HEX ; //2 sender //Device which orginated port 
   int  Port_ID ; //3 global id for device //const char * const _Protocol;
   PortTypes_T  PortTypes;  //4 0xFF  =  1111 1111 s
   Exp_state_T  Exp_state;    //5
@@ -114,7 +114,7 @@ typedef int _CAN_SEND_1_T  ; //1 byte = 0
 typedef int _CAN_SEND_2_T  ; //2 byte = 8 
 
  struct _Slave_Ports_Protocol_CAN_SEND_S {
-     const _CAN_SENDER_ID_T _CAN_SENDER_ID = Active_ControllerID_HEX ;
+     const _CAN_SENDER_ID_T _CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A ; //Active_ControllerID_HEX ;
      const  _CAN_SEND_1_T  _CAN_SEND_1 = 0 ;
      const  _CAN_SEND_2_T  _CAN_SEND_2 = 8 ;
      _Slave_Ports_Protocol_CAN_broadcast_T _Slave_Ports_Protocol_CAN_broadcast_A ;

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/_Slave_Ports_Status_QUEUE_add_func.h

@@ -8,7 +8,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_queue__add( Slave_Ports_Status_QUEUE_T*
     ARDUINO_ARRAY_INDEX_T DISPLAY_ARDUINO_ARRAY_INDEX_A //optionally
     //int _Slave_Ports_queue_peek , int _Slave_Ports_queue_push , int _Slave_Ports_queue_peek_new
     ) {
-      Serial.println("ID[");Serial.print(Active_ControllerID_HEX);
+      Serial.println("ID[");Serial.print(EEPROM_Active_ControllerID_read_A);
           Serial.print("]#152 _Slave_Ports_queue__add  TASK_TYPE_A[");
            Serial.print(TASK_TYPE_A); Serial.print(" [");  _Slave_Ports_queue_task_type_DESC(TASK_TYPE_A); Serial.print("] ");
            

+ 6 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/_Slave_Ports_Status_func.h

@@ -34,6 +34,11 @@
         //int i = Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A.ARDUINO_ARRAY_COUNT_A ;
         int i = Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A.ARDUINO_ARRAY_INDEX_CURRENT_A ;
         //if(Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A.ARDUINO_ARRAY_COUNT_A == 0) {
+        
+        if( IS_Local_A == IS_Local_TRUE and _Slave_ID != EEPROM_Active_ControllerID_read_A ) {
+            Serial.print(" [IGN]["); Serial.print(_Slave_ID) ; Serial.print("] ");
+        }
+        
           if(i == ARDUINO_ARRAY_INDEX_CORRUPT) {
                
                 // Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A.ARDUINO_ARRAY_COUNT_A ++;
@@ -151,7 +156,7 @@
                  
                  title.concat(TAB_S);
                  title.concat("Dev:0x") ;
-                title.concat(String(Active_ControllerID_HEX , HEX));          
+                title.concat(String(EEPROM_Active_ControllerID_read_A , HEX));          
                    title.concat(TAB_S);
                              
                     int i;

+ 6 - 4
SE/stuff/P5_Automation_can-dev-res-working-1930/_Slave_Ports_action_func.h

@@ -67,7 +67,7 @@ Slave_Ports_Status_QUEUE_T* Slave_Ports_Status_QUEUE_A,
     
                                  _Slave_Ports_Protocol_CAN_request_set_new_Exp_state_T CAN_request_set_new_Exp_state_T={};
                                     CAN_request_set_new_Exp_state_T._CAN_REMOTE_ID = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX]._Slave_ID;
-                                  //  CAN_broadcast_A._CAN_SENDER_ID = Active_ControllerID_HEX ;
+                                  //  CAN_broadcast_A._CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A//Active_ControllerID_HEX ;
                                     CAN_request_set_new_Exp_state_T.Port_ID = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].Port_ID ;
                                     CAN_request_set_new_Exp_state_T.PortTypes = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].PortTypes ; 
                                     CAN_request_set_new_Exp_state_T.Exp_state = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].Exp_state ;
@@ -85,7 +85,8 @@ Slave_Ports_Status_QUEUE_T* Slave_Ports_Status_QUEUE_A,
     
     
                     String message ; 
-                    byte sndStat = CAN0.sendMsgBuf(Active_ControllerID_HEX, 0, 8, CAN_MSG8_A_Slave_Ports_Protocol_CAN_request_set_new_Exp_state_A); 
+                    byte sndStat = CAN0.sendMsgBuf(EEPROM_Active_ControllerID_read_A, //Active_ControllerID_HEX,
+                         0, 8, CAN_MSG8_A_Slave_Ports_Protocol_CAN_request_set_new_Exp_state_A); 
                     delay(200);
                      if(sndStat == CAN_OK){
                      
@@ -113,7 +114,7 @@ Slave_Ports_Status_QUEUE_T* Slave_Ports_Status_QUEUE_A,
                      
                                  Slave_Ports_Protocol_CAN_request_confirm_Exp_state_T CAN_request_confirm_Exp_state_A={};
                                     //CAN_request_confirm_Exp_state_A._CAN_REMOTE_ID = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX]._Slave_ID;
-                                  //  CAN_broadcast_A._CAN_SENDER_ID = Active_ControllerID_HEX ;
+                                  //  CAN_broadcast_A._CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A Active_ControllerID_HEX ;
                                     CAN_request_confirm_Exp_state_A.Port_ID = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].Port_ID ;
                                     CAN_request_confirm_Exp_state_A.PortTypes = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].PortTypes ; 
                                     CAN_request_confirm_Exp_state_A.Exp_state = Slave_Ports_Status_A[TASK_PORT_ASSOC_A.Slave_Ports_Status_T_INDEX].Exp_state ;
@@ -128,7 +129,8 @@ Slave_Ports_Status_QUEUE_T* Slave_Ports_Status_QUEUE_A,
     
     
                     String message ; 
-                    byte sndStat = CAN0.sendMsgBuf(Active_ControllerID_HEX, 0, 8, CAN_MSG8_A_Slave_Ports_Protocol_CAN_request_confirm_Exp_state_A); 
+                    byte sndStat = CAN0.sendMsgBuf(EEPROM_Active_ControllerID_read_A , //Active_ControllerID_HEX, 
+                        0, 8, CAN_MSG8_A_Slave_Ports_Protocol_CAN_request_confirm_Exp_state_A); 
                     delay(200);
                      if(sndStat == CAN_OK){
                      

+ 4 - 3
SE/stuff/P5_Automation_can-dev-res-working-1930/_Slave_Ports_broadcast_func.h

@@ -141,7 +141,7 @@ void TASK_TYPE_T_Broadcast_state_LOW(Slave_Ports_Status_T* Slave_Ports_Status_A,
                                //( "OUT I2C 0X40[2]" + encoderPos * 5 , 2), //message,          
                                           _Slave_Ports_Protocol_CAN_broadcast_T CAN_broadcast_A={};
                                                // CAN_broadcast_A._CAN_REMOTE_ID = _CAN_REMOTE_ID_BROADCAST ;
-                                              //  CAN_broadcast_A._CAN_SENDER_ID = Active_ControllerID_HEX ;
+                                              //  CAN_broadcast_A._CAN_SENDER_ID = EEPROM_Active_ControllerID_read_A Active_ControllerID_HEX ;
                                                 CAN_broadcast_A.Port_ID = Slave_Ports_Status_A[i].Port_ID ;
                                                 CAN_broadcast_A.PortTypes = Slave_Ports_Status_A[i].PortTypes ; 
                                                 CAN_broadcast_A.Exp_state = Slave_Ports_Status_A[i].Exp_state ;  
@@ -152,7 +152,7 @@ void TASK_TYPE_T_Broadcast_state_LOW(Slave_Ports_Status_T* Slave_Ports_Status_A,
                                      // CAN_broadcast_A._CAN_8 = _CAN_8_EMPTY ;
                                      
                           /* byte CAN_broadcast_A[8] = {_CAN_REMOTE_ID_BROADCAST, 
-                                                        Active_ControllerID_HEX, 
+                                                       EEPROM_Active_ControllerID_read_A Active_ControllerID_HEX, 
                                                         Slave_Ports_Status_A[i].Port_ID, 
                                                         Slave_Ports_Status_A[i].PortTypes, 
                                                         Slave_Ports_Status_A[i].Exp_state , 
@@ -223,7 +223,8 @@ void TASK_TYPE_T_Broadcast_state_LOW(Slave_Ports_Status_T* Slave_Ports_Status_A,
                                                 // {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
                                               //   byte CAN_broadcast_A9[8] = {0xFF, 0x101, 0x02, 0x03, 0x04, 0x05, 0x07,  0x08};
                        //  CAN_data_debug(CAN_broadcast_A9);
-                         byte sndStat = CAN0.sendMsgBuf(Active_ControllerID_HEX, 0, 8, CAN_MSG8_A);  CAN_data_debug(CAN_MSG8_A);   //CAN_MSG8_A
+                         byte sndStat = CAN0.sendMsgBuf(EEPROM_Active_ControllerID_read_A, //Active_ControllerID_HEX,
+                                 0, 8, CAN_MSG8_A);  CAN_data_debug(CAN_MSG8_A);   //CAN_MSG8_A
                          delay(200);
                       //    byte sndStat ;
                                   if(sndStat == CAN_OK){

+ 4 - 4
SE/stuff/P5_Automation_can-dev-res-working-1930/___CONFIG/0x11/config_Slave_Ports_LOCAL_0x11_init.h

@@ -25,7 +25,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 1,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x11 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C, //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 0 , //int  LocalPort,
@@ -46,7 +46,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 2,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x11 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C, //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 1 , //int  LocalPort,
@@ -66,7 +66,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 3,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x11 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C, //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 2 , //int  LocalPort,
@@ -87,7 +87,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 4,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x11 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C | PortTypes_SERVO  ,// | PortTypes_SERVO //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 3 , //int  LocalPort,

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/___CONFIG/0x14/config_Slave_Ports_LOCAL_0x14_init.h

@@ -25,7 +25,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 1,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x14 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C, // PortTypes_SERVO , //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 1 , //int  LocalPort,

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/___CONFIG/0x15/config_Slave_Ports_LOCAL_0x15_init.h

@@ -25,7 +25,7 @@ ARDUINO_FUNCT_INIT_RESULT_T _Slave_Ports_LOCAL_init(
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_INDEX_T_TO_DELETE_A,
                                     Slave_Ports_Status_T_ARDUINO_ARRAY_ASSOC_TABLE_S_Port_ID_A,
                                 1,  // int  Port_ID,
-                                Active_ControllerID_HEX ,  //int  _Slave_ID,
+                                0x15 ,  //int  _Slave_ID,
                                 PortTypes_PWM_EXP_I2C, // PortTypes_SERVO , //int  PortTypes,
                                 0x40 ,  //int  Address,
                                 1 , //int  LocalPort,

+ 30 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___CONFIG/config_Active_Controller_EEPROM.h

@@ -0,0 +1,30 @@
+#include <EEPROM.h>
+
+
+
+typedef int EEPROM_Active_ControllerID_read_T ;
+typedef boolean EEPROM_Active_ControllerID_update_T;
+
+EEPROM_Active_ControllerID_read() {
+
+    int EEPROM_Active_ControllerID_addr = 0 ;
+
+    
+
+//    EEPROM.get( EEPROM_Active_ControllerID_addr, EEPROM_Active_ControllerID_read );
+    static EEPROM_Active_ControllerID_read_T  EEPROM_Active_ControllerID_read_A = EEPROM.read( EEPROM_Active_ControllerID_addr  );
+    if(EEPROM_Active_ControllerID_read_A > 0) {
+        return EEPROM_Active_ControllerID_read_A;
+    } else return false;
+}
+
+
+
+
+EEPROM_Active_ControllerID_update_T EEPROM_Active_ControllerID_update(EEPROM_Active_ControllerID_read_T EEPROM_Active_ControllerID_read_A) {
+
+    int EEPROM_Active_ControllerID_addr = 0 ;
+    EEPROM.update(EEPROM_Active_ControllerID_addr, EEPROM_Active_ControllerID_read_A);
+
+
+}