targets/plc_debug.c
changeset 236 a32817e81f5e
parent 235 a66e150f2888
child 239 112b4bc523b3
equal deleted inserted replaced
235:a66e150f2888 236:a32817e81f5e
   134     /* atomically mark buffer as free */
   134     /* atomically mark buffer as free */
   135     long latest_state = AtomicCompareExchange(
   135     long latest_state = AtomicCompareExchange(
   136         &buffer_state,
   136         &buffer_state,
   137         BUFFER_BUSY,
   137         BUFFER_BUSY,
   138         BUFFER_FREE);
   138         BUFFER_FREE);
   139     subscription_cursor = subscription_table;
       
   140 }
   139 }
   141 
   140 
   142 void* IterDebugData(int* idx, const char **type_name)
   141 void* IterDebugData(int* idx, const char **type_name)
   143 {
   142 {
   144     if(subscription_cursor < latest_subscription){
   143     if(subscription_cursor < latest_subscription){
       
   144         char* old_cursor = buffer_cursor;
   145         *idx = *subscription_cursor;
   145         *idx = *subscription_cursor;
   146         struct_plcvar* my_var = &variable_table[*(subscription_cursor++)];
   146         struct_plcvar* my_var = &variable_table[*(subscription_cursor++)];
   147         *type_name = __get_type_enum_name(my_var->type);
   147         *type_name = __get_type_enum_name(my_var->type);
   148         return my_var->ptrvalue;
   148         /* get variable size*/
       
   149         USINT size = __get_type_enum_size(my_var->type);
       
   150         /* compute next cursor positon*/
       
   151         buffer_cursor = buffer_cursor + size;
       
   152         if(old_cursor < debug_buffer + BUFFER_SIZE)
       
   153         {
       
   154             return old_cursor;
       
   155         }else{
       
   156             return NULL;
       
   157         } 
   149     }
   158     }
       
   159     *idx = -1;
       
   160     *type_name = NULL;
   150     return NULL;
   161     return NULL;
   151 }
   162 }
   152 
   163