193 Execute "ethercat master" command and parse the execution result |
193 Execute "ethercat master" command and parse the execution result |
194 @return MasterState |
194 @return MasterState |
195 """ |
195 """ |
196 |
196 |
197 # exectute "ethercat master" command |
197 # exectute "ethercat master" command |
198 error, return_val = self.Controler.RemoteExec(MASTER_STATE, return_val=None) |
198 _error, return_val = self.Controler.RemoteExec(MASTER_STATE, return_val=None) |
199 master_state = {} |
199 master_state = {} |
200 # parse the reslut |
200 # parse the reslut |
201 for each_line in return_val.splitlines(): |
201 for each_line in return_val.splitlines(): |
202 if len(each_line) > 0: |
202 if len(each_line) > 0: |
203 chunks = each_line.strip().split(':', 1) |
203 chunks = each_line.strip().split(':', 1) |
218 """ |
218 """ |
219 Set slave state to the specified one using "ethercat states -p %d %s" command. |
219 Set slave state to the specified one using "ethercat states -p %d %s" command. |
220 Command example : "ethercat states -p 0 PREOP" (target slave position and target state are given.) |
220 Command example : "ethercat states -p 0 PREOP" (target slave position and target state are given.) |
221 @param command : target slave state |
221 @param command : target slave state |
222 """ |
222 """ |
223 error, return_val = self.Controler.RemoteExec(SLAVE_STATE % (self.Controler.GetSlavePos(), command), return_val=None) |
223 _error, _return_val = self.Controler.RemoteExec( |
|
224 SLAVE_STATE % (self.Controler.GetSlavePos(), command), |
|
225 return_val=None) |
224 |
226 |
225 def GetSlaveStateFromSlave(self): |
227 def GetSlaveStateFromSlave(self): |
226 """ |
228 """ |
227 Get slave information using "ethercat slaves" command and store the information into internal data structure |
229 Get slave information using "ethercat slaves" command and store the information into internal data structure |
228 (self.SlaveState) for "Slave State" |
230 (self.SlaveState) for "Slave State" |
229 return_val example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100) |
231 return_val example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100) |
230 """ |
232 """ |
231 error, return_val = self.Controler.RemoteExec(GET_SLAVE, return_val=None) |
233 _error, return_val = self.Controler.RemoteExec(GET_SLAVE, return_val=None) |
232 self.SlaveState = return_val |
234 self.SlaveState = return_val |
233 return return_val |
235 return return_val |
234 |
236 |
235 # ------------------------------------------------------------------------------- |
237 # ------------------------------------------------------------------------------- |
236 # Used SDO Management |
238 # Used SDO Management |
239 """ |
241 """ |
240 Get SDO objects information of current slave using "ethercat sdos -p %d" command. |
242 Get SDO objects information of current slave using "ethercat sdos -p %d" command. |
241 Command example : "ethercat sdos -p 0" |
243 Command example : "ethercat sdos -p 0" |
242 @return return_val : execution results of "ethercat sdos" command (need to be parsed later) |
244 @return return_val : execution results of "ethercat sdos" command (need to be parsed later) |
243 """ |
245 """ |
244 error, return_val = self.Controler.RemoteExec(SLAVE_SDO % (self.Controler.GetSlavePos()), return_val=None) |
246 _error, return_val = self.Controler.RemoteExec(SLAVE_SDO % (self.Controler.GetSlavePos()), return_val=None) |
245 return return_val |
247 return return_val |
246 |
248 |
247 def SDODownload(self, data_type, idx, sub_idx, value): |
249 def SDODownload(self, data_type, idx, sub_idx, value): |
248 """ |
250 """ |
249 Set an SDO object value to user-specified value using "ethercat download" command. |
251 Set an SDO object value to user-specified value using "ethercat download" command. |
251 @param data_type : data type of SDO entry |
253 @param data_type : data type of SDO entry |
252 @param idx : index of the SDO entry |
254 @param idx : index of the SDO entry |
253 @param sub_idx : subindex of the SDO entry |
255 @param sub_idx : subindex of the SDO entry |
254 @param value : value of SDO entry |
256 @param value : value of SDO entry |
255 """ |
257 """ |
256 error, return_val = self.Controler.RemoteExec(SDO_DOWNLOAD % (data_type, self.Controler.GetSlavePos(), idx, sub_idx, value), return_val=None) |
258 _error, _return_val = self.Controler.RemoteExec( |
|
259 SDO_DOWNLOAD % (data_type, self.Controler.GetSlavePos(), idx, sub_idx, value), |
|
260 return_val=None) |
257 |
261 |
258 def BackupSDODataSet(self): |
262 def BackupSDODataSet(self): |
259 """ |
263 """ |
260 Back-up current SDO entry information to restore the SDO data |
264 Back-up current SDO entry information to restore the SDO data |
261 in case that the user cancels SDO update operation. |
265 in case that the user cancels SDO update operation. |
269 |
273 |
270 def ClearSDODataSet(self): |
274 def ClearSDODataSet(self): |
271 """ |
275 """ |
272 Clear the specified SDO entry information. |
276 Clear the specified SDO entry information. |
273 """ |
277 """ |
274 for count in range(6): |
278 for dummy in range(6): |
275 self.SaveSDOData.append([]) |
279 self.SaveSDOData.append([]) |
276 |
280 |
277 # ------------------------------------------------------------------------------- |
281 # ------------------------------------------------------------------------------- |
278 # Used PDO Monitoring |
282 # Used PDO Monitoring |
279 # ------------------------------------------------------------------------------- |
283 # ------------------------------------------------------------------------------- |
283 """ |
287 """ |
284 # Load slave information from ESI XML file (def EthercatMaster.py) |
288 # Load slave information from ESI XML file (def EthercatMaster.py) |
285 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
289 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
286 |
290 |
287 type_infos = slave.getType() |
291 type_infos = slave.getType() |
288 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
292 device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
289 # Initialize PDO data set |
293 # Initialize PDO data set |
290 self.ClearDataSet() |
294 self.ClearDataSet() |
291 |
295 |
292 # if 'device' object is valid, call SavePDOData() to parse PDO data |
296 # if 'device' object is valid, call SavePDOData() to parse PDO data |
293 if device is not None: |
297 if device is not None: |
299 Tx(Rx)PDOCategory : index, name, entry number |
303 Tx(Rx)PDOCategory : index, name, entry number |
300 Tx(Rx)Info : entry index, sub index, name, length, type |
304 Tx(Rx)Info : entry index, sub index, name, length, type |
301 @param device : Slave information extracted from ESI XML file |
305 @param device : Slave information extracted from ESI XML file |
302 """ |
306 """ |
303 # Parsing TXPDO entries |
307 # Parsing TXPDO entries |
304 for pdo, pdo_info in ([(pdo, "Inputs") for pdo in device.getTxPdo()]): |
308 for pdo, _pdo_info in ([(pdo, "Inputs") for pdo in device.getTxPdo()]): |
305 # Save pdo_index, entry, and name of each entry |
309 # Save pdo_index, entry, and name of each entry |
306 pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
310 pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
307 entries = pdo.getEntry() |
311 entries = pdo.getEntry() |
308 pdo_name = ExtractName(pdo.getName()) |
312 pdo_name = ExtractName(pdo.getName()) |
309 |
313 |
329 |
333 |
330 categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} |
334 categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} |
331 self.TxPDOCategory.append(categorys) |
335 self.TxPDOCategory.append(categorys) |
332 |
336 |
333 # Parsing RxPDO entries |
337 # Parsing RxPDO entries |
334 for pdo, pdo_info in ([(rxpdo, "Outputs") for rxpdo in device.getRxPdo()]): |
338 for pdo, _pdo_info in ([(rxpdo, "Outputs") for rxpdo in device.getRxPdo()]): |
335 # Save pdo_index, entry, and name of each entry |
339 # Save pdo_index, entry, and name of each entry |
336 pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
340 pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
337 entries = pdo.getEntry() |
341 entries = pdo.getEntry() |
338 pdo_name = ExtractName(pdo.getName()) |
342 pdo_name = ExtractName(pdo.getName()) |
339 |
343 |
460 "mailbox_standardconf_instart": '0', |
464 "mailbox_standardconf_instart": '0', |
461 "mailbox_standardconf_inlength": '0'} |
465 "mailbox_standardconf_inlength": '0'} |
462 |
466 |
463 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
467 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
464 type_infos = slave.getType() |
468 type_infos = slave.getType() |
465 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
469 device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
466 |
470 |
467 # 'device' represents current slave device selected by user |
471 # 'device' represents current slave device selected by user |
468 if device is not None: |
472 if device is not None: |
469 for eeprom_element in device.getEeprom().getcontent(): |
473 for eeprom_element in device.getEeprom().getcontent(): |
470 # get EEPROM size; <Device>-<Eeprom>-<ByteSize> |
474 # get EEPROM size; <Device>-<Eeprom>-<ByteSize> |
556 """ |
560 """ |
557 Get slave EEPROM contents maintained by master device using "ethercat sii_read -p %d" command. |
561 Get slave EEPROM contents maintained by master device using "ethercat sii_read -p %d" command. |
558 Command example : "ethercat sii_read -p 0" |
562 Command example : "ethercat sii_read -p 0" |
559 @return return_val : result of "ethercat sii_read" (binary data) |
563 @return return_val : result of "ethercat sii_read" (binary data) |
560 """ |
564 """ |
561 error, return_val = self.Controler.RemoteExec(SII_READ % (self.Controler.GetSlavePos()), return_val=None) |
565 _error, return_val = self.Controler.RemoteExec(SII_READ % (self.Controler.GetSlavePos()), return_val=None) |
562 self.SiiData = return_val |
566 self.SiiData = return_val |
563 return return_val |
567 return return_val |
564 |
568 |
565 def SiiWrite(self, binary): |
569 def SiiWrite(self, binary): |
566 """ |
570 """ |
567 Overwrite slave EEPROM contents using "ethercat sii_write -p %d" command. |
571 Overwrite slave EEPROM contents using "ethercat sii_write -p %d" command. |
568 Command example : "ethercat sii_write -p 0 - (binary contents)" |
572 Command example : "ethercat sii_write -p 0 - (binary contents)" |
569 @param binary : EEPROM contents in binary data format |
573 @param binary : EEPROM contents in binary data format |
570 @return return_val : result of "ethercat sii_write" (If it succeeds, the return value is NULL.) |
574 @return return_val : result of "ethercat sii_write" (If it succeeds, the return value is NULL.) |
571 """ |
575 """ |
572 error, return_val = self.Controler.RemoteExec(SII_WRITE % (self.Controler.GetSlavePos()), return_val=None, sii_data=binary) |
576 _error, return_val = self.Controler.RemoteExec( |
|
577 SII_WRITE % (self.Controler.GetSlavePos()), |
|
578 return_val=None, |
|
579 sii_data=binary) |
573 return return_val |
580 return return_val |
574 |
581 |
575 def LoadData(self): |
582 def LoadData(self): |
576 """ |
583 """ |
577 Loading data from EEPROM use Sii_Read Method |
584 Loading data from EEPROM use Sii_Read Method |
580 return_val = self.Controler.CommonMethod.SiiRead() |
587 return_val = self.Controler.CommonMethod.SiiRead() |
581 self.BinaryCode = return_val |
588 self.BinaryCode = return_val |
582 self.Controler.SiiData = self.BinaryCode |
589 self.Controler.SiiData = self.BinaryCode |
583 |
590 |
584 # append zero-filled padding data up to EEPROM size |
591 # append zero-filled padding data up to EEPROM size |
585 for index in range(self.SmartViewInfosFromXML["eeprom_size"] - len(self.BinaryCode)): |
592 for dummy in range(self.SmartViewInfosFromXML["eeprom_size"] - len(self.BinaryCode)): |
586 self.BinaryCode = self.BinaryCode + 'ff'.decode('hex') |
593 self.BinaryCode = self.BinaryCode + 'ff'.decode('hex') |
587 |
594 |
588 return self.BinaryCode |
595 return self.BinaryCode |
589 |
596 |
590 def HexRead(self, binary): |
597 def HexRead(self, binary): |
640 @return eeprom_list : reconstructed list data structure |
647 @return eeprom_list : reconstructed list data structure |
641 """ |
648 """ |
642 eeprom_list = [] |
649 eeprom_list = [] |
643 |
650 |
644 if direction is 0 or 1: |
651 if direction is 0 or 1: |
645 for i in range(length/2): |
652 for dummy in range(length/2): |
646 if data == "": |
653 if data == "": |
647 eeprom_list.append("00") |
654 eeprom_list.append("00") |
648 else: |
655 else: |
649 eeprom_list.append(data[direction*(length-2):direction*(length-2)+2]) |
656 eeprom_list.append(data[direction*(length-2):direction*(length-2)+2]) |
650 data = data[(1-direction)*2:length-direction*2] |
657 data = data[(1-direction)*2:length-direction*2] |
669 eeprom_binary = "" |
676 eeprom_binary = "" |
670 |
677 |
671 # 'device' is the slave device of the current EtherCAT slave plugin |
678 # 'device' is the slave device of the current EtherCAT slave plugin |
672 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
679 slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
673 type_infos = slave.getType() |
680 type_infos = slave.getType() |
674 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
681 device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
675 |
682 |
676 if device is not None: |
683 if device is not None: |
677 # get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData> |
684 # get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData> |
678 for eeprom_element in device.getEeprom().getcontent(): |
685 for eeprom_element in device.getEeprom().getcontent(): |
679 if eeprom_element["name"] == "ConfigData": |
686 if eeprom_element["name"] == "ConfigData": |
912 if data == vendor_spec_string: |
919 if data == vendor_spec_string: |
913 self.GroupIdx = vendor_spec_strings.index(data)+1 |
920 self.GroupIdx = vendor_spec_strings.index(data)+1 |
914 grouptypeflag = True |
921 grouptypeflag = True |
915 break |
922 break |
916 if grouptypeflag is False: |
923 if grouptypeflag is False: |
917 grouptype = data |
|
918 count += 1 |
924 count += 1 |
919 self.Strings.append(data) |
925 self.Strings.append(data) |
920 vendor_spec_strings.append(data) |
926 vendor_spec_strings.append(data) |
921 grouptypeflag = True |
927 grouptypeflag = True |
922 self.GroupIdx = count |
928 self.GroupIdx = count |
925 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
931 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
926 |
932 |
927 # element2-2; <EtherCATInfo>-<Groups>-<Group>-<Type> |
933 # element2-2; <EtherCATInfo>-<Groups>-<Group>-<Type> |
928 if grouptypeflag is False: |
934 if grouptypeflag is False: |
929 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
935 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
930 for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
936 for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
931 for group_type, group_etc in vendor["groups"].iteritems(): |
937 for group_type, group_etc in vendor["groups"].iteritems(): |
932 for device_item in group_etc["devices"]: |
938 for device_item in group_etc["devices"]: |
933 if device == device_item[1]: |
939 if device == device_item[1]: |
934 data = group_type |
940 data = group_type |
935 if data is not None and isinstance(data, unicode): |
941 if data is not None and isinstance(data, unicode): |
937 if data == vendor_spec_string: |
943 if data == vendor_spec_string: |
938 self.GroupIdx = vendor_spec_strings.index(data)+1 |
944 self.GroupIdx = vendor_spec_strings.index(data)+1 |
939 grouptypeflag = True |
945 grouptypeflag = True |
940 break |
946 break |
941 if grouptypeflag is False: |
947 if grouptypeflag is False: |
942 grouptype = data |
|
943 count += 1 |
948 count += 1 |
944 self.Strings.append(data) |
949 self.Strings.append(data) |
945 vendor_spec_strings.append(data) |
950 vendor_spec_strings.append(data) |
946 grouptypeflag = True |
951 grouptypeflag = True |
947 self.GroupIdx = count |
952 self.GroupIdx = count |
950 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
955 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
951 data = "" |
956 data = "" |
952 |
957 |
953 # element3; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Name(LcId is "1033")> |
958 # element3; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Name(LcId is "1033")> |
954 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
959 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
955 for vendorId, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
960 for _vendorId, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
956 for group_type, group_etc in vendor["groups"].iteritems(): |
961 for group_type, group_etc in vendor["groups"].iteritems(): |
957 for device_item in group_etc["devices"]: |
962 for device_item in group_etc["devices"]: |
958 if device == device_item[1]: |
963 if device == device_item[1]: |
959 data = group_etc["name"] |
964 data = group_etc["name"] |
960 if data is not "" and isinstance(data, unicode): |
965 if data is not "" and isinstance(data, unicode): |
1013 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
1018 vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
1014 |
1019 |
1015 # element5-2; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Image16x14> |
1020 # element5-2; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Image16x14> |
1016 if imageflag is False: |
1021 if imageflag is False: |
1017 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
1022 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
1018 for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
1023 for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
1019 for group_type, group_etc in vendor["groups"].iteritems(): |
1024 for group_type, group_etc in vendor["groups"].iteritems(): |
1020 for device_item in group_etc["devices"]: |
1025 for device_item in group_etc["devices"]: |
1021 if device == device_item[1]: |
1026 if device == device_item[1]: |
1022 data = group_etc |
1027 data = group_etc |
1023 if data is not None and isinstance(data, unicode): |
1028 if data is not None and isinstance(data, unicode): |
1134 eeprom.append("{:0>2x}".format(count)) |
1139 eeprom.append("{:0>2x}".format(count)) |
1135 for element in [vendor_specific_data, |
1140 for element in [vendor_specific_data, |
1136 dc_related_elements, |
1141 dc_related_elements, |
1137 input_elements, |
1142 input_elements, |
1138 output_elements]: |
1143 output_elements]: |
1139 for iter in range(len(element)/2): |
1144 for dummy in range(len(element)/2): |
1140 if element == "": |
1145 if element == "": |
1141 eeprom.append("00") |
1146 eeprom.append("00") |
1142 else: |
1147 else: |
1143 eeprom.append(element[0:2]) |
1148 eeprom.append(element[0:2]) |
1144 element = element[2:len(element)] |
1149 element = element[2:len(element)] |
1285 eeprom.append("{:0>4x}".format((count+1)/2)[2:4]) |
1289 eeprom.append("{:0>4x}".format((count+1)/2)[2:4]) |
1286 eeprom.append("{:0>4x}".format((count+1)/2)[0:2]) |
1290 eeprom.append("{:0>4x}".format((count+1)/2)[0:2]) |
1287 else: |
1291 else: |
1288 eeprom.append("{:0>4x}".format((count)/2)[2:4]) |
1292 eeprom.append("{:0>4x}".format((count)/2)[2:4]) |
1289 eeprom.append("{:0>4x}".format((count)/2)[0:2]) |
1293 eeprom.append("{:0>4x}".format((count)/2)[0:2]) |
1290 for i in range(count): |
1294 for dummy in range(count): |
1291 if data == "": |
1295 if data == "": |
1292 eeprom.append("00") |
1296 eeprom.append("00") |
1293 else: |
1297 else: |
1294 eeprom.append(data[0:2]) |
1298 eeprom.append(data[0:2]) |
1295 data = data[2:len(data)] |
1299 data = data[2:len(data)] |
1438 eeprom.append("00") |
1442 eeprom.append("00") |
1439 # category length |
1443 # category length |
1440 eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) |
1444 eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) |
1441 eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) |
1445 eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) |
1442 data = str(data.lower()) |
1446 data = str(data.lower()) |
1443 for i in range(len(data)/2): |
1447 for dummy in range(len(data)/2): |
1444 if data == "": |
1448 if data == "": |
1445 eeprom.append("00") |
1449 eeprom.append("00") |
1446 else: |
1450 else: |
1447 eeprom.append(data[0:2]) |
1451 eeprom.append(data[0:2]) |
1448 data = data[2:len(data)] |
1452 data = data[2:len(data)] |
1512 eeprom.append("00") |
1516 eeprom.append("00") |
1513 # category length |
1517 # category length |
1514 eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) |
1518 eeprom.append("{:0>4x}".format(len(data)/4)[2:4]) |
1515 eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) |
1519 eeprom.append("{:0>4x}".format(len(data)/4)[0:2]) |
1516 data = str(data.lower()) |
1520 data = str(data.lower()) |
1517 for i in range(len(data)/2): |
1521 for dummy in range(len(data)/2): |
1518 if data == "": |
1522 if data == "": |
1519 eeprom.append("00") |
1523 eeprom.append("00") |
1520 else: |
1524 else: |
1521 eeprom.append(data[0:2]) |
1525 eeprom.append(data[0:2]) |
1522 data = data[2:len(data)] |
1526 data = data[2:len(data)] |
1532 Command example : "ethercat reg_read -p 0 0x0c00 0x0400" |
1536 Command example : "ethercat reg_read -p 0 0x0c00 0x0400" |
1533 @param offset : register address |
1537 @param offset : register address |
1534 @param length : register length |
1538 @param length : register length |
1535 @return return_val : register data |
1539 @return return_val : register data |
1536 """ |
1540 """ |
1537 error, return_val = self.Controler.RemoteExec(REG_READ % (self.Controler.GetSlavePos(), offset, length), return_val=None) |
1541 _error, return_val = self.Controler.RemoteExec( |
|
1542 REG_READ % (self.Controler.GetSlavePos(), offset, length), |
|
1543 return_val=None) |
1538 return return_val |
1544 return return_val |
1539 |
1545 |
1540 def RegWrite(self, address, data): |
1546 def RegWrite(self, address, data): |
1541 """ |
1547 """ |
1542 Write data to slave ESC register using "ethercat reg_write -p %d %s %s" command. |
1548 Write data to slave ESC register using "ethercat reg_write -p %d %s %s" command. |
1543 Command example : "ethercat reg_write -p 0 0x0c04 0x0001" |
1549 Command example : "ethercat reg_write -p 0 0x0c04 0x0001" |
1544 @param address : register address |
1550 @param address : register address |
1545 @param data : data to write |
1551 @param data : data to write |
1546 @return return_val : the execution result of "ethercat reg_write" (for error check) |
1552 @return return_val : the execution result of "ethercat reg_write" (for error check) |
1547 """ |
1553 """ |
1548 error, return_val = self.Controler.RemoteExec(REG_WRITE % (self.Controler.GetSlavePos(), address, data), return_val=None) |
1554 _error, return_val = self.Controler.RemoteExec( |
|
1555 REG_WRITE % (self.Controler.GetSlavePos(), address, data), |
|
1556 return_val=None) |
1549 return return_val |
1557 return return_val |
1550 |
1558 |
1551 def Rescan(self): |
1559 def Rescan(self): |
1552 """ |
1560 """ |
1553 Synchronize EEPROM data in master controller with the data in slave device after EEPROM write. |
1561 Synchronize EEPROM data in master controller with the data in slave device after EEPROM write. |
1554 Command example : "ethercat rescan -p 0" |
1562 Command example : "ethercat rescan -p 0" |
1555 """ |
1563 """ |
1556 error, return_val = self.Controler.RemoteExec(RESCAN % (self.Controler.GetSlavePos()), return_val=None) |
1564 _error, _return_val = self.Controler.RemoteExec(RESCAN % (self.Controler.GetSlavePos()), return_val=None) |
1557 |
1565 |
1558 # ------------------------------------------------------------------------------- |
1566 # ------------------------------------------------------------------------------- |
1559 # Common Use Methods |
1567 # Common Use Methods |
1560 # ------------------------------------------------------------------------------- |
1568 # ------------------------------------------------------------------------------- |
1561 def CheckConnect(self, cyclic_flag): |
1569 def CheckConnect(self, cyclic_flag): |
1565 @return True or False |
1573 @return True or False |
1566 """ |
1574 """ |
1567 if self.Controler.GetCTRoot()._connector is not None: |
1575 if self.Controler.GetCTRoot()._connector is not None: |
1568 # Check connection between the master and the slave. |
1576 # Check connection between the master and the slave. |
1569 # Command example : "ethercat xml -p 0" |
1577 # Command example : "ethercat xml -p 0" |
1570 error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None) |
1578 _error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None) |
1571 number_of_lines = return_val.split("\n") |
1579 number_of_lines = return_val.split("\n") |
1572 if len(number_of_lines) <= 2: # No slave connected to the master controller |
1580 if len(number_of_lines) <= 2: # No slave connected to the master controller |
1573 if not cyclic_flag: |
1581 if not cyclic_flag: |
1574 self.CreateErrorDialog('No connected slaves') |
1582 self.CreateErrorDialog('No connected slaves') |
1575 return False |
1583 return False |