a.binder 5 rokov pred
rodič
commit
202105e566

+ 21 - 6
SE/stuff/P5_Automation_can-dev-res/P5_Automation_can-dev-res.ino

@@ -86,13 +86,13 @@
 #define  _ControllerID   0x101 
 #define  _Slave1_ID   0x103 
 
-//#define Active_ControllerID _ControllerID 
-#define Active_ControllerID _Slave1_ID 
+#define Active_ControllerID _ControllerID 
+//#define Active_ControllerID _Slave1_ID 
 
 
  #if Active_ControllerID == _ControllerID 
     String lcdPattern = "s" ;
-    #define HAS_LCD1602 
+  //   #define HAS_LCD1602 
    //  #define HAS_TFT_ILI9163C 
    #define HAS_ROTTARY_SW
  #endif
@@ -144,8 +144,20 @@ MCP_CAN CAN0(CAN_CSpin);                          // Set CS to pin 10
 
 
  //REMOTE PORTS DEFINITIONS
-
+ #include "_Slave_Ports_Protocol.h"
+ #include "Slave_Ports_Status_S.h"
+ 
+_Slave_Port _Slave_Ports[] = {
+  {"CAN", 0x102, 0x07, 0x00, 0x00, 0x00, 0x00 }
+  //,
+  //{"CAN", 0x102, 0x01, 0x00, 0x01, 0xFF, 0x6d } //testowy ttl
+};
+
+    Slave_Ports_Status_T  Slave_Ports_Status_A[100];
+    Slave_Ports_Status_add_port_count_T lave_Ports_Status_add_port_count_A = 0;
+    #include "_Slave_Ports_LOCAL.h"
   #include "_Slave_Ports.h"
+ // #include "_Slave_Ports_ttl_decrement_POP.h"
   // #define _CAN_P_0x102_PWM0x00_0 { _Slave1_ID , "PWM", 0x00, 0 } 
    //#define _CAN_P_0x102_PWMServoDriver0x40
    
@@ -308,8 +320,8 @@ _Slave_Ports_queue__list(_Slave_Ports_queue_tasks_LIST);
 //  int _Slave_Ports_queue_push = _Slave_Ports_queue.push(_Slave_Ports_queue.peek() + 1) ; 
   //int _Slave_Ports_queue_peek_new = _Slave_Ports_queue.peek() ; _Slave_Ports_queue__add(  *_Slave_Ports_queue_tasks_LIST, 0x01 ,0x00 ,100, 5000 ) ;  // _Slave_Ports_queue_peek, _Slave_Ports_queue.push(_Slave_Ports_queue.peek() + 1), _Slave_Ports_queue.peek());
 //void _Slave_Ports_queue__add( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST,int _Slave_Ports_queue_task_type,int _Slave_Port_link,long time_seq_id, long time_min_run //, 
-_Slave_Ports_queue__add(     _Slave_Ports_queue_tasks_LIST,  int(0x04) ,0x00 ,100, 5000 ) ;  //        "_Slave_Ports_broadcast", //4
-_Slave_Ports_queue__add(  _Slave_Ports_queue_tasks_LIST, 0x05 ,0x00 ,100, 5000 ) ;  //"_Slave_Ports_set_I2C" //5  - to set ports associated on PW
+_Slave_Ports_queue__add(  _Slave_Ports_queue_tasks_LIST,  TASK_TYPE_T_Slave_Ports_broadcast____ ,0x00 ,100, 5000 ) ;  //        "_Slave_Ports_broadcast", //4
+_Slave_Ports_queue__add(  _Slave_Ports_queue_tasks_LIST,  TASK_TYPE_T_Slave_Ports_set_I2C______ ,0x00 ,100, 5000 ) ;  //"_Slave_Ports_set_I2C" //5  - to set ports associated on PW
 
  //  _Slave_Ports_queue_peek =  _Slave_Ports_queue.peek() ; 
    //_Slave_Ports_queue_push =  _Slave_Ports_queue.push(_Slave_Ports_queue.peek() + 1) ;  
@@ -379,6 +391,9 @@ void loop() {
 
   //_LCD_print_buffors_list(_LCD_print_buffors) ;
   //_LCD_print_screens_list(_LCD_print_screens);
+  
+  delay(5000);
+  
 }
 
 

+ 40 - 0
SE/stuff/P5_Automation_can-dev-res/Slave_Ports_Status_QUEUE.h

@@ -0,0 +1,40 @@
+
+
+
+/*
+typedef struct
+{
+  uint8_t CNF1;
+} TASK_TYPE_T;
+
+
+*/
+
+
+
+
+#ifndef Slave_Ports_Status_QUEUE
+
+
+#define TASK_TYPE_T_NOT_USED_________________ 0x00
+#define TASK_TYPE_T_Slave_Ports_ttl_decrement 0x01
+#define TASK_TYPE_T_request_confirm_Exp_state 0x02
+#define TASK_TYPE_T_request_set_new_Exp_state 0x03
+#define TASK_TYPE_T_Slave_Ports_broadcast____ 0x04
+#define TASK_TYPE_T_Slave_Ports_set_I2C______ 0x05
+
+
+    #define Slave_Ports_Status_QUEUE
+    
+     struct Slave_Ports_Status_QUEUE_S {
+      int _queue_id ; //current queue task
+       int TASK_TYPE_A ; 
+       long time_seq_id;
+       long time_min_run;
+    } ;
+    
+    
+    typedef struct Slave_Ports_Status_QUEUE_S Slave_Ports_Status_QUEUE_T;
+
+    
+#endif

+ 129 - 0
SE/stuff/P5_Automation_can-dev-res/Slave_Ports_Status_S.h

@@ -0,0 +1,129 @@
+
+
+#ifndef Slave_Ports_Status_S_h
+#define Slave_Ports_Status_S_h
+
+
+ #define    I2C_driver_NOT_USED_  0x00
+ #define    I2C_driver_Adafruit_PWMServoDriver    0x01
+
+
+
+ #define    PortTypes_PWM  0x01
+ #define    PortTypes_I2C  0x02
+ #define    PortTypes_EXP  0x03
+ #define    PortTypes_P2M_EXP_I2C  0x07
+
+
+ #define    Exp_state_OFF  0x01
+ #define    Exp_state_ON  0x02
+
+
+
+ #define    Exp_state_ttl_TO_REFRESH  0x01
+
+ #define    Broadcast_state_TO_REFRESH  0x01 
+
+#define I2C_port_DEFAULT 0x01
+
+ struct Slave_Ports_Status_S {
+  int  Port_ID ; //global id for device //const char * const _Protocol;
+  int  _Slave_ID; //Device which orginated port   //remote id - use FF for broadcast
+  int  PortTypes;  //0xFF  =  1111 1111 s
+                                          /*
+                                          {
+                                      bit 1 - PWM port
+                                      bit 2 - on I2C managed port
+                                      bit 3 - expanded port with LocalPort address
+                                      bit 4 - not allocated
+                                      bit 2 - not allocated
+                                      bit 5 - not allocated
+                                      bit 6 - not allocated
+                                      bit 7 - not allocated
+                                      bit 8 - not allocated
+                                    } 
+                                           */
+ // byte has_Address;
+  int  Address ;
+ // byte has_Local_Port;
+  int  LocalPort;
+  int  Exp_state;                  /*0xFF  =  1111 1111
+                                    0x00  =  0000 0001  = OFF = 0V
+                                    0x01  =  0000 0002  = ON = PWM max
+                                    {
+                                      bit 1 - OFF = 0V
+                                      bit 2 - ON = PWM max
+                                      bit 3 - not allocated
+                                      bit 4 - not allocated
+                                      bit 2 - not allocated
+                                      bit 5 - not allocated
+                                      bit 6 - not allocated
+                                      bit 7 - not allocated
+                                      bit 8 - not allocated
+                                    }*/
+  int  Exp_state_ttl;  // 0x01 = odswiezyc
+  int  Broadcast_state; //0x00 - not broadcast; 0x01
+  int I2C_port ; //0x01 - default port, 0x00 - not I2C connected
+  int I2C_driver; //0x00 - not driver, 0x01 Adafruit_PWMServoDriver.h
+ // int IS_Local; // Define if port is local or remote added
+  
+} ;
+
+typedef struct Slave_Ports_Status_S Slave_Ports_Status_T;
+
+typedef int Slave_Ports_Status_add_port_count_T;
+Slave_Ports_Status_add_port_count_T Slave_Ports_Status_add_port_count_A ;
+
+ void Slave_Ports_Status_add_port(
+ Slave_Ports_Status_T* Slave_Ports_Status_A , Slave_Ports_Status_add_port_count_T* Slave_Ports_Status_add_port_count_A,
+ 
+                int  Port_ID,
+                int  _Slave_ID,
+                int  PortTypes,
+                int  Address,
+                int  LocalPort,
+                int  Exp_state,
+                int  Exp_state_ttl,
+                int  Broadcast_state,
+                int I2C_port,
+                //int I2C_driver
+                int I2C_driver
+                )
+{
+        int i = Slave_Ports_Status_add_port_count_A ;
+    if(Slave_Ports_Status_add_port_count_A == 0) {
+      Slave_Ports_Status_add_port_count_A ++;
+     Slave_Ports_Status_A[i].Port_ID=0x00;
+     Slave_Ports_Status_A[i]._Slave_ID=0x00;
+     Slave_Ports_Status_A[i].PortTypes=0x00;
+     Slave_Ports_Status_A[i].Address=0x00;
+     Slave_Ports_Status_A[i].LocalPort=0x00;
+     Slave_Ports_Status_A[i].Exp_state=0x00;
+     Slave_Ports_Status_A[i].Exp_state_ttl=0x00;
+     Slave_Ports_Status_A[i].Broadcast_state=0x00;
+     Slave_Ports_Status_A[i].I2C_port=0x00;
+     Slave_Ports_Status_A[i].I2C_driver=0x00;
+     Slave_Ports_Status_add_port_count_A ++;
+     
+   
+   
+    }
+    
+    Slave_Ports_Status_A[i + 1].Port_ID = Port_ID ;
+    Slave_Ports_Status_A[i + 1]._Slave_ID = _Slave_ID ;
+    Slave_Ports_Status_A[i + 1].PortTypes = PortTypes ;
+    Slave_Ports_Status_A[i + 1].Address = Address ;
+    Slave_Ports_Status_A[i + 1].LocalPort = LocalPort ;
+    Slave_Ports_Status_A[i + 1].Exp_state = Exp_state ;
+    Slave_Ports_Status_A[i + 1].Exp_state_ttl = Exp_state_ttl ;
+    Slave_Ports_Status_A[i + 1].Broadcast_state = Broadcast_state ;
+    Slave_Ports_Status_A[i + 1].I2C_port = I2C_port ;
+    Slave_Ports_Status_A[i + 1].I2C_driver = I2C_driver ;
+  //  Slave_Ports_Status_A[Slave_Ports_Status_add_port_count_A + 1].I2C_driver = I2C_driver_F(I2C_driver) ;
+
+    Slave_Ports_Status_add_port_count_A ++;
+  
+}
+
+#endif
+

+ 20 - 76
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports.h

@@ -1,7 +1,7 @@
 #include "_Slave_Ports_ttl_decrement.h"
-
-
-
+//#include "_Slave_Ports_Protocol.h"
+#include "Slave_Ports_Status_QUEUE.h"
+//#include "Slave_Ports_Status_S.h"
 
 typedef struct  {
   const char * const _Protocol;
@@ -52,8 +52,9 @@ _Slave_Port _Slave_Ports[] = {
   //{"CAN", 0x102, 0x01, 0x00, 0x01, 0xFF, 0x6d } //testowy ttl
 };
 */
-#include "_Slave_Ports_LOCAL.h"
-#include "_Slave_Ports_queue_task_type_LIST.h"
+//#include "_Slave_Ports_LOCAL.h"
+//#include "_Slave_Ports_queue_task_type_LIST.h"
+#include "Slave_Ports_Status_QUEUE.h"
 
 
  struct _Slave_Ports_queue_tasksS {
@@ -95,29 +96,16 @@ void _Slave_Ports_queue__INIT( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tas
 }
 
 
-String _Slave_Ports_queue_task_type_DESC( int _Slave_Ports_queue_task_type ) {//, int* res
- /* if(_Slave_Ports_queue_task_type == 0x01) res=0x99; //res="_Slave_Ports_ttl_decrement";
-  else if(_Slave_Ports_queue_task_type == 0x02) res=0x99; //res="request_confirm_Exp_state";
-  else if(_Slave_Ports_queue_task_type == 0x03) res=0x99; //res="request_set_new_Exp_state";
-  else {
-    res=0x99; // res="_UNKNOIWN";
-    Serial.print("#82 Get [");  Serial.print(_Slave_Ports_queue_task_type); Serial.println("] #82 [U] ");
-  }
-  *//*
- // char return_i;
-  Serial.print("=["); Serial.print(_Slave_Ports_queue_task_type); Serial.print("] ");
- if(_Slave_Ports_queue_task_type == 0x01)   Serial.print("_Slave_Ports_ttl_decrement"); // return "_Slave_Ports_ttl_decrement";
-  else if(_Slave_Ports_queue_task_type == 0x02)  Serial.print("request_confirm_Exp_state"); //return "request_confirm_Exp_state";
-  else if(_Slave_Ports_queue_task_type == 0x03)   Serial.print("request_set_new_Exp_state"); //return "request_set__new_Exp_state";
-  else //return_i = "_UNKNOIWN"; //return "_UNKNOIWN";
-   Serial.print("_UNKNOIWN");
-// Serial.print((String)return_i);
-//  return return_i ;
-*/
- //Serial.print(_Slave_Ports_queue_task_type[_Slave_Ports_queue_task_type]); 
-  return _Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_task_type]; 
- //  String ret = "aaaaxxx";
-   //return ret;
+void _Slave_Ports_queue_task_type_DESC( int _Slave_Ports_queue_task_type ) {//, int* res
+        if(_Slave_Ports_queue_task_type == TASK_TYPE_T_NOT_USED_________________) { 
+            Serial.println("TASK_TYPE_T_NOT_USED_________________"); 
+        } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_ttl_decrement) { Serial.println("TASK_TYPE_T_Slave_Ports_ttl_decrement");
+        } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_request_confirm_Exp_state) { Serial.println("TASK_TYPE_T_request_confirm_Exp_state");
+        } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_request_set_new_Exp_state) { Serial.println("TASK_TYPE_T_request_set_new_Exp_state");
+        } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_broadcast____) { Serial.println("TASK_TYPE_T_Slave_Ports_broadcast____");
+        } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_set_I2C______) { Serial.println("TASK_TYPE_T_Slave_Ports_set_I2C______");
+        } else  { Serial.println("106 unknown _Slave_Ports_queue_task_type");
+        }
 }
 
 
@@ -145,9 +133,9 @@ void _Slave_Ports_queue__list( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tas
                  //Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type);
                  //char res;
                  // res = _Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type);  Serial.print(res);
-                  Serial.print(_Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type));
-                  Serial.print(" - map[");  Serial.print(_Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type]);  Serial.print("]"); 
-               // Serial.print(_Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type)) ; //(res); //_Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type
+                  
+                //  Serial.print(" - map[");  Serial.print(_Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type]);  Serial.print("]"); 
+               _Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type) ; //(res); //_Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type
 
   
                  Serial.print("] _Slave_Port_link: ");
@@ -236,51 +224,7 @@ int _Slave_Ports_queue_task_type, int _Slave_Port_link, long time_seq_id, long t
 */
 
 
-
-
-
- void _Slave_Ports_ttl_decrement_POP(_Slave_Ports_queue_tasksT*  _Slave_Ports_queue_tasks_LIST,int _Slave_Ports_queue_pop ,  _Slave_Port* _Slave_Ports) {
-     Serial.print("#213 _Slave_Ports_ttl_decrement_POP.   sizeof _Slave_Ports[");     Serial.print(sizeof(_Slave_Ports));
-    int i;
-    for(i=0;i<=100;i++) {
-      if(_Slave_Ports[i]._Protocol == "CAN") {
-            if(_Slave_Ports[i].Exp_state_ttl > 0x00 ) {
-               Serial.print("#217 ttl min for: Prot[");  Serial.print(_Slave_Ports[i]._Protocol);   Serial.print("] ttl[");  Serial.print(_Slave_Ports[i].Exp_state_ttl);  Serial.print(" id[");  Serial.print(i);   Serial.println("]  "); 
-            }
-
-      }
-    }
-
-
- /*
-   const char * const _Protocol;
-  int _Slave_ID;
-  int PortTypes;  //0xFF  =  1111 1111 {  PWM,  .....} = 0x80
- // byte has_Address;
-  int Address ;
- // byte has_Local_Port;
-  int LocalPort;
-  int Exp_state;                  /*0xFF  =  1111 1111
-                                    0x00  =  0000 0000  = OFF = 0V
-                                    0x01  =  0000 0001  = ON = PWM max
-                                    {
-                                      bit 1 - OFF = 0V
-                                      bit 2 - ON = PWM max
-                                      bit 3 - not allocated
-                                      bit 4 - not allocated
-                                      bit 2 - not allocated
-                                      bit 5 - not allocated
-                                      bit 6 - not allocated
-                                      bit 7 - not allocated
-                                      bit 8 - not allocated
-                                   
-  int Exp_state_ttl;  // 0x00 = odswiezyc
-
-  */
- 
- } 
-
-
+#include "_Slave_Ports_ttl_decrement_POP.h"
 
  void _Slave_Ports_broadcast_POP(_Slave_Ports_queue_tasksT*  _Slave_Ports_queue_tasks_LIST, int _Slave_Ports_queue_pop ,  _Slave_Port*  _Slave_Ports, int LCDtim ) {
         Serial.println("#251 _Slave_Ports_broadcast_POP");

+ 25 - 5
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports_LOCAL.h

@@ -1,9 +1,29 @@
 
-_Slave_Port _Slave_Ports[] = {
-  {"CAN", 0x102, 0x07, 0x00, 0x00, 0x00, 0x00 }
-  //,
-  //{"CAN", 0x102, 0x01, 0x00, 0x01, 0xFF, 0x6d } //testowy ttl
-};
+#include "Slave_Ports_Status_S.h"
+
+
+void _Slave_Ports_LOCAL_init(Slave_Ports_Status_T* Slave_Ports_Status_A ,
+                Slave_Ports_Status_add_port_count_T* Slave_Ports_Status_add_port_count_A) {
+
+
+
+  Slave_Ports_Status_add_port(
+                Slave_Ports_Status_T* Slave_Ports_Status_A ,
+                Slave_Ports_Status_add_port_count_T* Slave_Ports_Status_add_port_count_A,
+                1,  // int  Port_ID,
+                Active_ControllerID ,  //int  _Slave_ID,
+                PortTypes_P2M_EXP_I2C , //int  PortTypes,
+                0x00 ,  //int  Address,
+                1 , //int  LocalPort,
+                Exp_state_OFF, //int  Exp_state,
+                Exp_state_ttl_TO_REFRESH, //int  Exp_state_ttl,
+                Broadcast_state_TO_REFRESH, //int  Broadcast_state,
+                I2C_port_DEFAULT, //int I2C_port,
+                I2C_driver_Adafruit_PWMServoDriver //int I2C_driver
+                );
+
+}
+
 
 /*
 typedef struct  {

+ 102 - 0
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports_Protocol.h

@@ -0,0 +1,102 @@
+
+typedef int _Slave_ID_BROADCAST_T  ;
+typedef int _SENDER_T  ;
+
+
+//#define _Slave_ID_BROADCAST_T  _Slave_ID_BROADCAST  0xFF ; 
+
+ #if ! defined(Active_ControllerID)
+    #error "#9 not defined Active_ControllerID"
+ 
+ #endif 
+
+ struct _Slave_Ports_Protocol_CAN_broadcast_S {
+  const   _Slave_ID_BROADCAST_T  _Slave_ID_BROADCAST = 0xFF ;   // 1remote id - use FF for broadcast
+  const _SENDER_T _SENDER = Active_ControllerID ; //2 sender //Device which orginated port 
+  int  Port_ID ; //3 global id for device //const char * const _Protocol;
+  int  PortTypes;  //4 0xFF  =  1111 1111 s
+  //int  Address ; //
+  //int  LocalPort; //
+  int  Exp_state;    //5
+  int  Exp_state_ttl;  //6
+  int  Broadcast_state;  //7
+  const int _CAN_8 = 0x07 ; //8 - nbot used
+} ;
+
+typedef struct _Slave_Ports_Protocol_CAN_broadcast_S _Slave_Ports_Protocol_CAN_broadcast_T;
+
+
+
+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 _SENDER_T _SENDER = Active_ControllerID ;
+     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 ;
+} ;
+
+//typedef  byte _Slave_Ports_Protocol_CAN_broadcast_AS[8] ;
+
+/*
+
+ struct _Slave_Ports_Protocol_CAN_broadcast_AS {
+  const byte  _Slave_ID_BROADCAST = 0xFF ;   // 1remote id - use FF for broadcast
+  const byte _SENDER = Active_ControllerID ; //2 sender //Device which orginated port 
+  byte  Port_ID ; //3 global id for device //const char * const _Protocol;
+  byte  PortTypes;  //4 0xFF  =  1111 1111 s
+  //int  Address ; //
+  //int  LocalPort; //
+  byte  Exp_state;    //5
+  byte  Exp_state_ttl;  //6
+  byte  Broadcast_state;  //7
+  const byte _CAN_8 = 0x07 ; //8 - nbot used
+} ;
+*/
+typedef  byte _Slave_Ports_Protocol_CAN_broadcast_AS[8]  ;
+
+void _Slave_Ports_Protocol_CAN_broadcast_AF(_Slave_Ports_Protocol_CAN_broadcast_T _Slave_Ports_Protocol_CAN_broadcast_A, byte* _Slave_Ports_Protocol_CAN_broadcast_B ) {
+   //byte dataa = {10, 12, 13, 4, 5, 6, 7, 8}; 
+    //   return dataa;
+     _Slave_Ports_Protocol_CAN_broadcast_B[1] = _Slave_Ports_Protocol_CAN_broadcast_A._Slave_ID_BROADCAST ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[2] = _Slave_Ports_Protocol_CAN_broadcast_A._SENDER ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[3] = _Slave_Ports_Protocol_CAN_broadcast_A.Port_ID ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[4] = _Slave_Ports_Protocol_CAN_broadcast_A.PortTypes ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[5] =  _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[6] =  _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state_ttl ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[7] = _Slave_Ports_Protocol_CAN_broadcast_A.Broadcast_state ;
+     _Slave_Ports_Protocol_CAN_broadcast_B[8] = _Slave_Ports_Protocol_CAN_broadcast_A._CAN_8 ;
+        
+        
+}
+
+
+/*
+ _Slave_Ports_Protocol_CAN_broadcast_AS  _Slave_Ports_Protocol_CAN_broadcast_F( _Slave_Ports_Protocol_CAN_broadcast_T _Slave_Ports_Protocol_CAN_broadcast_A ) {
+       byte data[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; 
+       return data;
+}
+*/
+/*byte data[8] = {
+                int  _Slave_ID --1 sender addr
+                 int 0x04, -2 task type
+                 int  Port_ID ; -3 //global id for device //const char * const _Protocol;
+                 _Slave_Ports[i].PortTypes, -4
+                   _Slave_Ports[i].Exp_state, -5
+                    _Slave_Ports[i].Exp_state_ttl, -6 
+                     Broadcast_state}; -7
+                     0x07 -8 not used
+
+byte data[8] = {_Slave_Ports[i].Address,  1
+            0x04, 2
+            _Slave_Ports[i].LocalPort, 3
+            _Slave_Ports[i].PortTypes,4
+             _Slave_Ports[i].LocalPort, 5
+             _Slave_Ports[i].Exp_state,6
+              _Slave_Ports[i].Exp_state_ttl,7
+               0x07};8
+
+                     
+byte sndStat = CAN0.sendMsgBuf(_Slave_Ports[i]._Slave_ID, 0, 8, data);
+*/

+ 0 - 19
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports_queue_task_type_LIST.h

@@ -1,19 +0,0 @@
-
-const byte _Slave_Ports_queue_task_type_COUNT = 32;
-const char _Slave_Ports_queue_task_type_LIST[][_Slave_Ports_queue_task_type_COUNT] = {
-        "_NOT_USED", //0
-        "_Slave_Ports_ttl_decrement", //1
-        "request_confirm_Exp_state",  //2
-        "request_set_new_Exp_state",  //3
-        "_Slave_Ports_broadcast", //4
-         "_Slave_Ports_set_I2C" //5  - to set ports associated on PW
-        }; 
-        
-//void  _Slave_Ports_message_queue_to_CAN() ;//
-//void  _Slave_Ports_message_queue_to_PWM() ;//
-
-//char _Slave_Ports_queue_task_type[10] = {};
-// _Slave_Ports_queue_task_type = { "_Slave_Ports_ttl_decrement" , "request_confirm_Exp_state" , "request_set_new_Exp_state"} ;
-// { HEX  0x02, "request_confirm_Exp_state" }, 
-// { HEX  0x03, "request_set_new_Exp_state" }
-//};

+ 47 - 0
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports_ttl_decrement_POP.h

@@ -0,0 +1,47 @@
+
+
+#ifndef _Slave_Ports_ttl_decrement_POP_F
+
+#define _Slave_Ports_ttl_decrement_POP_F
+
+ void _Slave_Ports_ttl_decrement_POP(_Slave_Ports_queue_tasksT*  _Slave_Ports_queue_tasks_LIST,int _Slave_Ports_queue_pop ,  _Slave_Port* _Slave_Ports) {
+     Serial.print("#213 _Slave_Ports_ttl_decrement_POP.   sizeof _Slave_Ports[");     Serial.print(sizeof(_Slave_Ports));
+    int i;
+    for(i=0;i<=100;i++) {
+      if(_Slave_Ports[i]._Protocol == "CAN") {
+            if(_Slave_Ports[i].Exp_state_ttl > 0x00 ) {
+               Serial.print("#217 ttl min for: Prot[");  Serial.print(_Slave_Ports[i]._Protocol);   Serial.print("] ttl[");  Serial.print(_Slave_Ports[i].Exp_state_ttl);  Serial.print(" id[");  Serial.print(i);   Serial.println("]  "); 
+            }
+
+      }
+    }
+
+
+ /*
+   const char * const _Protocol;
+  int _Slave_ID;
+  int PortTypes;  //0xFF  =  1111 1111 {  PWM,  .....} = 0x80
+ // byte has_Address;
+  int Address ;
+ // byte has_Local_Port;
+  int LocalPort;
+  int Exp_state;                  /*0xFF  =  1111 1111
+                                    0x00  =  0000 0000  = OFF = 0V
+                                    0x01  =  0000 0001  = ON = PWM max
+                                    {
+                                      bit 1 - OFF = 0V
+                                      bit 2 - ON = PWM max
+                                      bit 3 - not allocated
+                                      bit 4 - not allocated
+                                      bit 2 - not allocated
+                                      bit 5 - not allocated
+                                      bit 6 - not allocated
+                                      bit 7 - not allocated
+                                      bit 8 - not allocated
+                                   
+  int Exp_state_ttl;  // 0x00 = odswiezyc
+
+  */
+ 
+ } 
+#endif

+ 36 - 25
SE/stuff/P5_Automation_can-dev/P5_Automation_can-dev.ino

@@ -8,6 +8,7 @@
 //#define Active_ControllerID _Slave1_ID 
  
 #include "Slave_Ports_Status.h"
+Slave_Ports_Status  Slave_Ports_Status_C;
 //#include "Slave_Ports_QUEUE.h"  
     
 //#include "_Slave_Ports_queue_task_type_LIST.h"
@@ -16,7 +17,7 @@
 
 
 //BEGIN CAN
-
+/*
 
 #include <mcp_can.h>
 #include <SPI.h>
@@ -29,36 +30,39 @@ MCP_CAN CAN0(CAN_CSpin);                          // Set CS to pin 10
 //EOF CAN
 
 
-
+*/
 
 
  //REMOTE PORTS DEFINITIONS
 
  // #include "_Slave_Ports.h"
+  /*
   
 
 #if defined(HAS_ROTTARY_SW)
  #include "_ROTTARY_SW.h"
 #endif
 // include the library code
-/**********************************************************/
+
 //EOF BEGIN 1602
 
 
 #include "_PCINT.h"
-   
+#include "_PCINT_loop.h"
+*/
+
  int Slave_Ports_Status_C_ports_defined = 0;
-  Slave_Ports_Status  Slave_Ports_Status_C;
+  
 
 void setup() {
 
- Serial.begin(115200);
+ Serial.begin(57600);
  
  
    
  //  Slave_Ports_QUEUE Slave_Ports_QUEUE_C;
  
- #include "_Slave_Ports_LOCAL_LIST.h"
+ //#include "_Slave_Ports_LOCAL_LIST.h"
   /*AAA
   #if defined(HAS_LCD1602)
     lcd.begin(16, 2);
@@ -67,18 +71,19 @@ void setup() {
  //Slave_Ports_Status_T _add[] = { 1, Active_ControllerID, 0x01, 0x00, 1, 0x01, 0x01, 0x01 };
  
 
-     Serial.println("#200 adding ports");
+     Serial.println("UUWWW adding ports");
  
 //todo PCINT service
-#include "_PCINT_setup.h"
-
+//#include "_PCINT_setup.h"
 
+/*
 
 #if defined(HAS_ROTTARY_SW)
  #include "_ROTTARY_SW_setup.h"
 #endif
- Serial.println("#231");
-
+*/
+ Serial.println("CCCAA");
+/*
 
   if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) {
  
@@ -96,9 +101,9 @@ void setup() {
   }
        
   //EOF CAN
-  
+  */
  
- Serial.println("#298 _Slave_Ports_queue__list");
+ Serial.println("WWWF _Slave_Ports_queue__list");
  
   
 
@@ -111,27 +116,33 @@ void setup() {
   //String LCDarray1 ;
   //String LCDarray2 ;
 
-
-  unsigned long time;
-  
- #include "_PCINT_loop.h"
+  //unsigned long time;
+  int loop_id = 0;
 
 void loop() {
- Serial.println("#120 :loop " );
+ Serial.println("BBCC :loop " );
  delay(1000);
-
+ loop_id ++;
+  // time = millis();
+ 
   
   if( Slave_Ports_Status_C_ports_defined == 0) {
-   Serial.println("#431 : Slave_Ports_Status_C_ports_defined = 0" );
+   Serial.println("AAXX Slave_Ports_Status_C_ports_defined = 0" );
    Slave_Ports_Status_C_ports_defined = 1;
         Slave_Ports_Status_C.add_port( 1, 0x102, 0x01, 0x00, 1, 0x01, 0x01, 0x01, 0x01, 0x00); // Slave_Ports_Status_C.I2C_driver_F(Adafruit_PWMServoDriver)
-        Slave_Ports_Status_C.add_port( 2, 0x102, 0x01, 0x00, 1, 0x01, 0x01, 0x01, 0x01, 0x00); // Slave_Ports_Status_C.I2C_driver_F(Adafruit_PWMServoDriver)
-    //    Slave_Ports_Status_C.add_port( 3, 0x102, 0x01, 0x00, 1, 0x01, 0x01, 0x01, 0x01, 0x00); // Slave_Ports_Status_C.I2C_driver_F(Adafruit_PWMServoDriver)
+       int _count_get = Slave_Ports_Status_C._count_get();
+         Serial.print("AVVV S_count_get: " ); Serial.println(_count_get );
+      // Slave_Ports_Status_C.add_port( 2, 0x102, 0x01, 0x00, 1, 0x01, 0x01, 0x01, 0x01, 0x00); // Slave_Ports_Status_C.I2C_driver_F(Adafruit_PWMServoDriver)
+     //_count_get = Slave_Ports_Status_C._count_get();
+     //_count_get = Slave_Ports_Status_C._count_get();
+    //   Slave_Ports_Status_C.add_port( 3, 0x102, 0x01, 0x00, 1, 0x01, 0x01, 0x01, 0x01, 0x00); // Slave_Ports_Status_C.I2C_driver_F(Adafruit_PWMServoDriver)
+     //  _count_get = Slave_Ports_Status_C._count_get();
 } else {
-    Serial.println("#438 : Slave_Ports_Status_C_ports_defined =1" );
+    Serial.println("GGHH : Slave_Ports_Status_C_ports_defined =1" );
 }
 
-
+ Serial.write("Loop " );
+  Serial.println(loop_id );
   
  delay(5000);
   //_LCD_print_buffors_list(_LCD_print_buffors) ;

+ 2 - 0
SE/stuff/P5_Automation_can-dev/P5_Automation_can-dev.xpr

@@ -10,6 +10,8 @@
         </folder>
         <folder path="../P5_Automation_can-dev-2/"/>
         <folder path="../P5_Automation_can-dev-3/"/>
+        <folder path="../P5_Automation_can-dev-res/"/>
         <folder path="."/>
+        <folder path="../P5_Automation_can-single/"/>
     </projectTree>
 </project>

+ 3 - 4
SE/stuff/P5_Automation_can-dev/Slave_Ports_QUEUE.h

@@ -17,8 +17,7 @@
 
 
 
-class Slave_Ports_QUEUE 
-{
+class Slave_Ports_QUEUE {
 
     
 public:
@@ -29,13 +28,13 @@ public:
          Slave_Ports_Status_QUEUE_T *Slave_Ports_Status_QUEUE_A ;
        
           Slave_Ports_QUEUE(); 
-          ~Slave_Ports_QUEUE();    
+          ~Slave_Ports_Status_QUEUE();    
           int queue__add_A(Slave_Ports_Status_QUEUE_T QUEUE_A);
           int queue__add(int TASK_TYPE_A, long time_seq_id, long time_min_run);
 
 
 
-};
+}
 
 
 #endif