116 @param transmittype : PDO transmit type |
116 @param transmittype : PDO transmit type |
117 @param pdomapping: list of PDO mappings |
117 @param pdomapping: list of PDO mappings |
118 @return: a tuple of value and number of parameters to add to DCF |
118 @return: a tuple of value and number of parameters to add to DCF |
119 """ |
119 """ |
120 |
120 |
|
121 dcfdata=[] |
121 # Create entry for RPDO or TPDO parameters and Disable PDO |
122 # Create entry for RPDO or TPDO parameters and Disable PDO |
122 dcfdata = LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(0x80000000 + cobid, 4) |
123 # ---- INDEX ----- --- SUBINDEX ---- ----- SIZE ------ ------ DATA ------ |
123 # Set Transmit type synchrone |
124 dcfdata += [LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(0x80000000 + cobid, 4)] |
124 dcfdata += LE_to_BE(idx, 2) + LE_to_BE(0x02, 1) + LE_to_BE(0x01, 4) + LE_to_BE(transmittype, 1) |
125 # Set Transmit type |
125 # Re-Enable PDO |
126 dcfdata += [LE_to_BE(idx, 2) + LE_to_BE(0x02, 1) + LE_to_BE(0x01, 4) + LE_to_BE(transmittype, 1)] |
126 # ---- INDEX ----- --- SUBINDEX ---- ----- SIZE ------ ------ DATA ------ |
|
127 dcfdata += LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(cobid, 4) |
|
128 nbparams = 3 |
|
129 if len(pdomapping) > 0: |
127 if len(pdomapping) > 0: |
130 dcfdata += LE_to_BE(idx + 0x200, 2) + LE_to_BE(0x00, 1) + LE_to_BE(0x01, 4) + LE_to_BE(len(pdomapping), 1) |
128 # Disable Mapping |
131 nbparams += 1 |
129 dcfdata += [LE_to_BE(idx + 0x200, 2) + LE_to_BE(0x00, 1) + LE_to_BE(0x01, 4) + LE_to_BE(0x00, 1)] |
132 # Map Variables |
130 # Map Variables |
133 for subindex, (name, loc_infos) in enumerate(pdomapping): |
131 for subindex, (name, loc_infos) in enumerate(pdomapping): |
134 value = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) + loc_infos["size"] |
132 value = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) + loc_infos["size"] |
135 dcfdata += LE_to_BE(idx + 0x200, 2) + LE_to_BE(subindex + 1, 1) + LE_to_BE(0x04, 4) + LE_to_BE(value, 4) |
133 dcfdata += [LE_to_BE(idx + 0x200, 2) + LE_to_BE(subindex + 1, 1) + LE_to_BE(0x04, 4) + LE_to_BE(value, 4)] |
136 nbparams += 1 |
134 # Re-enable Mapping |
137 return dcfdata, nbparams |
135 dcfdata += [LE_to_BE(idx + 0x200, 2) + LE_to_BE(0x00, 1) + LE_to_BE(0x01, 4) + LE_to_BE(len(pdomapping), 1)] |
|
136 # Re-Enable PDO |
|
137 dcfdata += [LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(cobid, 4)] |
|
138 return "".join(dcfdata), len(dcfdata) |
138 |
139 |
139 class ConciseDCFGenerator: |
140 class ConciseDCFGenerator: |
140 |
141 |
141 def __init__(self, nodelist, nodename): |
142 def __init__(self, nodelist, nodename): |
142 # Dictionary of location informations classed by name |
143 # Dictionary of location informations classed by name |