418 # Compiling lists of indexes defined |
418 # Compiling lists of indexes defined |
419 entries = [idx for name, idx in Manager.GetCurrentValidIndexes(0, 0xFFFF)] |
419 entries = [idx for name, idx in Manager.GetCurrentValidIndexes(0, 0xFFFF)] |
420 |
420 |
421 # Generate FileInfo section |
421 # Generate FileInfo section |
422 fileContent = "[FileInfo]\n" |
422 fileContent = "[FileInfo]\n" |
423 fileContent += "CreatedBy=CANFestival\n" |
423 fileContent += "FileName=%s\n"%os.path.split(filepath)[-1] |
|
424 fileContent += "FileVersion=1\n" |
|
425 fileContent += "FileRevision=1\n" |
|
426 fileContent += "EDSVersion=4.0\n" |
424 fileContent += "Description=%s\n"%description |
427 fileContent += "Description=%s\n"%description |
425 fileContent += "CreationTime=%s"%strftime("%I:%M", current_time) |
428 fileContent += "CreationTime=%s"%strftime("%I:%M", current_time) |
426 # %p option of strftime seems not working, then generate AM/PM by hands |
429 # %p option of strftime seems not working, then generate AM/PM by hands |
427 if strftime("%I", current_time) == strftime("%H", current_time): |
430 if strftime("%I", current_time) == strftime("%H", current_time): |
428 fileContent += "AM\n" |
431 fileContent += "AM\n" |
429 else: |
432 else: |
430 fileContent += "PM\n" |
433 fileContent += "PM\n" |
431 fileContent += "CreationDate=%s\n"%strftime("%m-%d-%Y", current_time) |
434 fileContent += "CreationDate=%s\n"%strftime("%m-%d-%Y", current_time) |
432 fileContent += "FileName=%s\n"%os.path.split(filepath)[-1] |
435 fileContent += "CreatedBy=CANFestival\n" |
433 fileContent += "FileVersion=1\n" |
436 fileContent += "ModificationTime=%s"%strftime("%I:%M", current_time) |
434 fileContent += "FileRevision=1\n" |
437 # %p option of strftime seems not working, then generate AM/PM by hands |
435 fileContent += "EDSVersion=3.0\n" |
438 if strftime("%I", current_time) == strftime("%H", current_time): |
|
439 fileContent += "AM\n" |
|
440 else: |
|
441 fileContent += "PM\n" |
|
442 fileContent += "ModificationDate=%s\n"%strftime("%m-%d-%Y", current_time) |
|
443 fileContent += "ModifiedBy=CANFestival\n" |
436 |
444 |
437 # Generate DeviceInfo section |
445 # Generate DeviceInfo section |
438 fileContent += "\n[DeviceInfo]\n" |
446 fileContent += "\n[DeviceInfo]\n" |
439 fileContent += "VendorName=CANFestival\n" |
447 fileContent += "VendorName=CANFestival\n" |
440 # Use information typed by user in Identity entry |
448 # Use information typed by user in Identity entry |
554 |
562 |
555 # Generate Definition of mandatory objects |
563 # Generate Definition of mandatory objects |
556 fileContent += "\n[MandatoryObjects]\n" |
564 fileContent += "\n[MandatoryObjects]\n" |
557 fileContent += "SupportedObjects=%d\n"%len(mandatories) |
565 fileContent += "SupportedObjects=%d\n"%len(mandatories) |
558 for idx, entry in enumerate(mandatories): |
566 for idx, entry in enumerate(mandatories): |
559 fileContent += "%d=0x%4.4X\n"%(idx, entry) |
567 fileContent += "%d=0x%4.4X\n"%(idx + 1, entry) |
560 # Write mandatory entries |
568 # Write mandatory entries |
561 for entry in mandatories: |
569 for entry in mandatories: |
562 fileContent += indexContents[entry] |
570 fileContent += indexContents[entry] |
563 |
571 |
564 # Generate Definition of optional objects |
572 # Generate Definition of optional objects |
565 fileContent += "\n[OptionalObjects]\n" |
573 fileContent += "\n[OptionalObjects]\n" |
566 fileContent += "SupportedObjects=%d\n"%len(optionals) |
574 fileContent += "SupportedObjects=%d\n"%len(optionals) |
567 for idx, entry in enumerate(optionals): |
575 for idx, entry in enumerate(optionals): |
568 fileContent += "%d=0x%4.4X\n"%(idx, entry) |
576 fileContent += "%d=0x%4.4X\n"%(idx + 1, entry) |
569 # Write optional entries |
577 # Write optional entries |
570 for entry in optionals: |
578 for entry in optionals: |
571 fileContent += indexContents[entry] |
579 fileContent += indexContents[entry] |
572 |
580 |
573 # Generate Definition of manufacturer objects |
581 # Generate Definition of manufacturer objects |
574 fileContent += "\n[ManufacturerObjects]\n" |
582 fileContent += "\n[ManufacturerObjects]\n" |
575 fileContent += "SupportedObjects=%d\n"%len(manufacturers) |
583 fileContent += "SupportedObjects=%d\n"%len(manufacturers) |
576 for idx, entry in enumerate(manufacturers): |
584 for idx, entry in enumerate(manufacturers): |
577 fileContent += "%d=0x%4.4X\n"%(idx, entry) |
585 fileContent += "%d=0x%4.4X\n"%(idx + 1, entry) |
578 # Write manufacturer entries |
586 # Write manufacturer entries |
579 for entry in manufacturers: |
587 for entry in manufacturers: |
580 fileContent += indexContents[entry] |
588 fileContent += indexContents[entry] |
581 |
589 |
582 # Return File Content |
590 # Return File Content |
625 ProfileNb = eds_dict[0x1000]["DEFAULTVALUE"] & 0x0000ffff |
633 ProfileNb = eds_dict[0x1000]["DEFAULTVALUE"] & 0x0000ffff |
626 # If profile is not DS-301 or DS-302 |
634 # If profile is not DS-301 or DS-302 |
627 if ProfileNb not in [301, 302]: |
635 if ProfileNb not in [301, 302]: |
628 # Compile Profile name and path to .prf file |
636 # Compile Profile name and path to .prf file |
629 ProfileName = "DS-%d"%ProfileNb |
637 ProfileName = "DS-%d"%ProfileNb |
630 ProfilePath = os.path.join(cwd, "config/%s.prf"%ProfileName) |
638 ProfilePath = os.path.join(os.path.split(__file__)[0], "config/%s.prf"%ProfileName) |
631 # Verify that profile is available |
639 # Verify that profile is available |
632 if os.path.isfile(ProfilePath): |
640 if os.path.isfile(ProfilePath): |
633 try: |
641 try: |
634 # Load Profile |
642 # Load Profile |
635 execfile(ProfilePath) |
643 execfile(ProfilePath) |