# HG changeset patch # User Laurent Bessard # Date 1365113394 -7200 # Node ID c317b1aaf92086e75be7df26edb98dc75d36b5c0 # Parent fc1bc441cf71d5007bcc62100203961ff01713dc Fixed bug when using real axis and simulated axis at the same time (got the same index) diff -r fc1bc441cf71 -r c317b1aaf920 etherlab/EthercatCIA402Slave.py --- a/etherlab/EthercatCIA402Slave.py Thu Apr 04 17:50:43 2013 +0900 +++ b/etherlab/EthercatCIA402Slave.py Fri Apr 05 00:09:54 2013 +0200 @@ -51,8 +51,7 @@ } """ -BLOCK_FUNTION_DEFINITION_TEMPLATE = """ if (!__CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s) -__CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location)s;""" +BLOCK_FUNTION_DEFINITION_TEMPLATE = " __CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location)s;" GLOBAL_INSTANCES = [ {"blocktype": "GetTorqueLimit", diff -r fc1bc441cf71 -r c317b1aaf920 etherlab/plc_cia402node.c --- a/etherlab/plc_cia402node.c Thu Apr 04 17:50:43 2013 +0900 +++ b/etherlab/plc_cia402node.c Fri Apr 05 00:09:54 2013 +0200 @@ -55,10 +55,8 @@ int __init_%(location)s() { + __FirstTick = 1; %(init_entry_variables)s - *__IW%(location)s_0 = __MK_Alloc_AXIS_REF(); - __CIA402Node_%(location)s.axis = __MK_GetPublic_AXIS_REF(*__IW%(location)s_0); - __CIA402Node_%(location)s.axis->NetworkPosition = %(slave_pos)d; *(__CIA402Node_%(location)s.ModesOfOperation) = 0x08; return 0; } @@ -69,13 +67,15 @@ void __retrieve_%(location)s() { -%(fieldbus_interface_definition)s - IEC_UINT statusword_inactive = *(__CIA402Node_%(location)s.StatusWord) & __InactiveMask; IEC_UINT statusword_active = *(__CIA402Node_%(location)s.StatusWord) & __ActiveMask; if (__FirstTick) { + *__IW%(location)s_0 = __MK_Alloc_AXIS_REF(); + __CIA402Node_%(location)s.axis = __MK_GetPublic_AXIS_REF(*__IW%(location)s_0); + __CIA402Node_%(location)s.axis->NetworkPosition = %(slave_pos)d; %(init_axis_params)s +%(fieldbus_interface_definition)s __FirstTick = 0; }