equal
deleted
inserted
replaced
252 |
252 |
253 # Extract data and number of params in current DCF |
253 # Extract data and number of params in current DCF |
254 if nodeDCF != None and nodeDCF != '': |
254 if nodeDCF != None and nodeDCF != '': |
255 tmpnbparams = [i for i in nodeDCF[:4]] |
255 tmpnbparams = [i for i in nodeDCF[:4]] |
256 tmpnbparams.reverse() |
256 tmpnbparams.reverse() |
257 nbparams += int(''.join(["%2.2x"%ord(i) for i in tmpnbparams]), 16) |
257 nbparams += int(''.join(["%2.2x" % ord(i) for i in tmpnbparams]), 16) |
258 data = nodeDCF[4:] + data |
258 data = nodeDCF[4:] + data |
259 |
259 |
260 # Build new DCF |
260 # Build new DCF |
261 dcf = LE_to_BE(nbparams, 0x04) + data |
261 dcf = LE_to_BE(nbparams, 0x04) + data |
262 # Set new DCF for slave |
262 # Set new DCF for slave |
544 mapvariableidx = VariableStartIndex[variable_infos["pdotype"]] + \ |
544 mapvariableidx = VariableStartIndex[variable_infos["pdotype"]] + \ |
545 VariableTypeOffset[variable_infos["sizelocation"]] * VariableIncrement + \ |
545 VariableTypeOffset[variable_infos["sizelocation"]] * VariableIncrement + \ |
546 variable_infos["nodeid"] |
546 variable_infos["nodeid"] |
547 |
547 |
548 # Generate entry name |
548 # Generate entry name |
549 indexname = "%s%s%s_%d"%(VariableDirText[variable_infos["pdotype"]], |
549 indexname = "%s%s%s_%d" % (VariableDirText[variable_infos["pdotype"]], |
550 variable_infos["sizelocation"], |
550 variable_infos["sizelocation"], |
551 '_'.join(map(str,current_location)), |
551 '_'.join(map(str,current_location)), |
552 variable_infos["nodeid"]) |
552 variable_infos["nodeid"]) |
553 |
553 |
554 # Search for an entry that has an empty subindex |
554 # Search for an entry that has an empty subindex |
570 |
570 |
571 # Verify that a not full entry has been found |
571 # Verify that a not full entry has been found |
572 if mapvariableidx < VariableStartIndex[variable_infos["pdotype"]] + 0x2000: |
572 if mapvariableidx < VariableStartIndex[variable_infos["pdotype"]] + 0x2000: |
573 # Generate subentry name |
573 # Generate subentry name |
574 if variable_infos["bit"] != None: |
574 if variable_infos["bit"] != None: |
575 subindexname = "%(index)d_%(subindex)d_%(bit)d"%variable_infos |
575 subindexname = "%(index)d_%(subindex)d_%(bit)d" % variable_infos |
576 else: |
576 else: |
577 subindexname = "%(index)d_%(subindex)d"%variable_infos |
577 subindexname = "%(index)d_%(subindex)d" % variable_infos |
578 # If entry have just been created, no subentry have to be added |
578 # If entry have just been created, no subentry have to be added |
579 if not new_index: |
579 if not new_index: |
580 self.Manager.AddSubentriesToCurrent(mapvariableidx, 1, self.MasterNode) |
580 self.Manager.AddSubentriesToCurrent(mapvariableidx, 1, self.MasterNode) |
581 nbsubentries += 1 |
581 nbsubentries += 1 |
582 # Add informations to the new subentry created |
582 # Add informations to the new subentry created |
588 if typeinfos != None: |
588 if typeinfos != None: |
589 value = (mapvariableidx << 16) + ((nbsubentries) << 8) + typeinfos["size"] |
589 value = (mapvariableidx << 16) + ((nbsubentries) << 8) + typeinfos["size"] |
590 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
590 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
591 |
591 |
592 # Add variable to pointed variables |
592 # Add variable to pointed variables |
593 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s"%(indexname, subindexname) |
593 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s" % (indexname, subindexname) |
594 |
594 |
595 def GenerateConciseDCF(locations, current_location, nodelist, sync_TPDOs, nodename): |
595 def GenerateConciseDCF(locations, current_location, nodelist, sync_TPDOs, nodename): |
596 """ |
596 """ |
597 Fills a CanFestival network editor model, with DCF with requested PDO mappings. |
597 Fills a CanFestival network editor model, with DCF with requested PDO mappings. |
598 @param locations: List of complete variables locations \ |
598 @param locations: List of complete variables locations \ |
666 |
666 |
667 --reset (-r) |
667 --reset (-r) |
668 Reset the reference result of config_utils test. |
668 Reset the reference result of config_utils test. |
669 Use with caution. Be sure that config_utils |
669 Use with caution. Be sure that config_utils |
670 is currently working properly. |
670 is currently working properly. |
671 """%sys.argv[0] |
671 """ % sys.argv[0] |
672 |
672 |
673 # Boolean that indicate if reference result must be redefined |
673 # Boolean that indicate if reference result must be redefined |
674 reset = False |
674 reset = False |
675 |
675 |
676 # Extract command options |
676 # Extract command options |
718 |
718 |
719 # Generate MasterNode configuration |
719 # Generate MasterNode configuration |
720 try: |
720 try: |
721 masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
721 masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
722 except ValueError, message: |
722 except ValueError, message: |
723 print "%s\nTest Failed!"%message |
723 print "%s\nTest Failed!" % message |
724 sys.exit() |
724 sys.exit() |
725 |
725 |
726 import pprint |
726 import pprint |
727 # Get Text corresponding to MasterNode |
727 # Get Text corresponding to MasterNode |
728 result_node = masternode.PrintString() |
728 result_node = masternode.PrintString() |