Changeset 42bad281f223c00abe6af881022d49977ac483d4


Ignore:
Timestamp:
03/04/11 11:43:42 (2 years ago)
Author:
Matias De la Puente <mfpuente.ar@…>
Children:
47bf006ff320470525f4b3355342f2d7628cdf52
Parents:
1ccee93ef7bc44a5da992218395cbfcc0e289cc8
git-committer:
Matias De la Puente <mfpuente.ar@…> (03/04/11 11:43:42)
Message:

Programmers: Add required and optional options per action

Also fix some options name

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • data/programmers/avrdude.xml

    r9ab0cbf r42bad28  
    55                <write_flash> 
    66                        <command>avrdude %options -U flash:w:%firmware</command> 
     7                        <required_options>Device,Programmer</required_options> 
     8                        <optional_options>SerialPort,BaudRate,BitClock,ConfigFile,DisableAutoErase,ISPClockDelay,DoNotWrite,DoNotverify,ExtendedParam,VerboseOutput,QuellOutput</optional_options> 
    79                </write_flash> 
    810                <read_flash> 
    911                        <command>avrdude %options -U flash:r:%firmware:i</command> 
     12                        <required_options>Device,Programmer</required_options> 
     13                        <optional_options>SerialPort,BaudRate,BitClock,ConfigFile,ISPClockDelay,DoNotverify,ExtendedParam,VerboseOutput,QuellOutput</optional_options> 
    1014                </read_flash> 
    1115                <verify_flash> 
    1216                        <command>avrdude %options -U flash:v:%firmware</command> 
     17                        <required_options>Device,Programmer</required_options> 
     18                        <optional_options>SerialPort,BaudRate,BitClock,ConfigFile,ISPClockDelay,DoNotverify,ExtendedParam,VerboseOutput,QuellOutput</optional_options> 
    1319                </verify_flash> 
    1420        </actions> 
     
    7177                        <description lang="es">No escribir nada al dispositivo</description> 
    7278                </option> 
    73                 <option name="Don't verify" format="-V" value_type="None" optional="true" most_used="false"> 
     79                <option name="DoNotverify" format="-V" value_type="None" optional="true" most_used="false"> 
    7480                        <label lang="en">Don't verify</label> 
    7581                        <label lang="es">No verificar</label> 
  • data/programmers/lpc21isp.xml

    r9ab0cbf r42bad28  
    55                <write_flash> 
    66                        <command>lpc21isp %optional_options -wipe -verify %firmware %required_options</command> 
     7                        <required_options>FirmwareType,SerialPort,BaudRate,OscillatorFrequency</required_options> 
     8                        <optional_options>DebugMode,DoNotStartMCU,Attempts,ControlLines,ControlLinesSwapped,ControlLinesInverted,EnableLogging,UseHalfduplex</optional_options> 
    79                </write_flash> 
    810        </actions> 
     
    7880                        <description lang="es">Elegir velocidad de transmisión</description> 
    7981                </option> 
    80                 <option name="Oscillator frequency" format="%value" value_type="Entry" optional="false" most_used="true"> 
     82                <option name="OscillatorFrequency" format="%value" value_type="Entry" optional="false" most_used="true"> 
    8183                        <label lang="en">Oscillator frequency</label> 
    8284                        <label lang="es">Frecuencia del oscilador</label> 
  • data/programmers/pickit2.xml

    r9ab0cbf r42bad28  
    55                <write_flash> 
    66                        <command>pk2cmd %options -F%firmware -M</command> 
     7                        <required_options>PK2DeviceFilePath,Device</required_options> 
     8                        <optional_options>UnitID,ProgrammingSpeed,DisablePE,ExternallyPowered,VPPFirst,PreserveEEData,BlankCheck,OSCCAL,PowerDevice</optional_options> 
    79                </write_flash> 
    810                <read_flash> 
    911                        <command>pk2cmd %options -GF%firmware</command> 
     12                        <required_options>PK2DeviceFilePath,Device</required_options> 
     13                        <optional_options>UnitID,ProgrammingSpeed,DisablePE,ExternallyPowered,VPPFirst,BlankCheck,PowerDevice</optional_options> 
    1014                </read_flash> 
    1115                <verify_flash> 
    1216                        <command>pk2cmd %options -F%firmware -Y</command> 
     17                        <required_options>PK2DeviceFilePath,Device</required_options> 
     18                        <optional_options>UnitID,ProgrammingSpeed,DisablePE,ExternallyPowered,VPPFirst,BlankCheck,PowerDevice</optional_options> 
    1319                </verify_flash> 
    1420                <erase_flash> 
    1521                        <command>pk2cmd %options -E</command> 
     22                        <required_options>PK2DeviceFilePath,Device</required_options> 
     23                        <optional_options>UnitID,ProgrammingSpeed,DisablePE,ExternallyPowered,VPPFirst,PreserveEEData,BlankCheck,OSCCAL</optional_options> 
    1624                </erase_flash> 
    1725                <read_fuses> 
    1826                        <command>pk2cmd %options -GC</command> 
     27                        <required_options>PK2DeviceFilePath,Device</required_options> 
     28                        <optional_options>UnitID,ProgrammingSpeed,DisablePE,ExternallyPowered,VPPFirst,BlankCheck,PowerDevice</optional_options> 
    1929                </read_fuses> 
    2030                <get_version> 
    2131                        <command>pk2cmd %options -?V</command> 
     32                        <required_options>PK2DeviceFilePath</required_options> 
    2233                </get_version> 
    2334        </actions> 
     
    8596                        <description lang="es">Programar memoria OSCCAL</description> 
    8697                </option> 
    87                 <option name="Release MCLR" format="-R" value_type="None" optional="true" most_used="true"> 
     98                <option name="ReleaseMCLR" format="-R" value_type="None" optional="true" most_used="true"> 
    8899                        <label lang="en">Release MCLR</label> 
    89100                        <label lang="es">Liberar MCLR</label> 
  • data/programmers/picstartplus.xml

    r9ab0cbf r42bad28  
    55                <write_flash> 
    66                        <command>picp %options -bp -wp %firmware</command> 
     7                        <required_options>SerialPort,Device</required_options> 
     8                        <optional_options>CommLineDebug,ISPProtocol,QuietMode</optional_options> 
    79                </write_flash> 
    810                <read_flash> 
    911                        <command>picp %options -rp %firmware</command> 
     12                        <required_options>SerialPort,Device</required_options> 
     13                        <optional_options>CommLineDebug,ISPProtocol,QuietMode</optional_options> 
    1014                </read_flash> 
    1115                <erase_flash> 
    1216                        <command>picp %options -ef</command> 
     17                        <required_options>SerialPort,Device</required_options> 
     18                        <optional_options>CommLineDebug,ISPProtocol,QuietMode</optional_options> 
    1319                </erase_flash> 
    1420                <read_fuses> 
    1521                        <command>picp %options -rc</command> 
     22                        <required_options>SerialPort,Device</required_options> 
     23                        <optional_options>CommLineDebug,ISPProtocol,QuietMode</optional_options> 
    1624                </read_fuses> 
    1725                <get_version> 
    18                         <command>picp %options -v</command> 
     26                        <command>picp -v</command> 
    1927                </get_version> 
    2028        </actions> 
    2129        <options> 
    22                 <option name="Comm line debug" format="-c" value_type="None" optional="true" most_used="false"> 
     30                <option name="CommLineDebug" format="-c" value_type="None" optional="true" most_used="false"> 
    2331                        <label lang="en">Comm line debug</label> 
    2432                        <label lang="es">Depuración de la línea de comunicación</label> 
  • libi4uccore/optionslogic.vala

    r9ab0cbf r42bad28  
    108108        } 
    109109         
    110         public string get_options (string? format=null) throws OptionError 
    111         { 
     110        public string get_options (Gee.List<string>? required_options, Gee.List<string>? optional_options, string? format=null) throws OptionError 
     111        { 
     112                // Return empty string if there's no options added 
    112113                if (_options == null) 
    113114                        return ""; 
    114                 var required_options = ""; 
    115                 var optional_options = ""; 
    116                 foreach (var option_view in _option_views) 
    117                 { 
    118                         if (option_view.sensitive && option_view.active) 
    119                         { 
    120                                 if (option_view.value == null || option_view.value == "") 
    121                                         throw new OptionError.OPTION_VALUE_MISSING (_("Option value missing: ") + option_view.name); 
    122                                 var option = get_option (option_view.name); 
    123                                 var option_value = option_view.value; 
    124                                 if (option.value_type == "FilePath" || option.value_type == "FolderPath") 
    125                                         option_value = Shell.quote (option_value);_option_settings[option_view.name].name = option_view.name; 
    126                                 var option_str = " " + option.format.replace ("%value", option_value); 
    127                                 if (option.optional) 
    128                                         optional_options += option_str; 
    129                                 else 
    130                                         required_options += option_str; 
    131                         } 
    132                 } 
     115                 
     116                // Fill required_options_str 
     117                var required_options_str = ""; 
     118                if (required_options != null) 
     119                        foreach (var option_name in required_options) 
     120                        { 
     121                                var option_view = get_option_view (option_name); 
     122                                if (option_view == null) 
     123                                        continue; 
     124                                if (option_view.sensitive && option_view.active) 
     125                                { 
     126                                        if (option_view.value == null || option_view.value == "") 
     127                                                throw new OptionError.OPTION_VALUE_MISSING (_("Option value missing: ") + option_name); 
     128                                        var option = get_option (option_name); 
     129                                        var option_value = option_view.value; 
     130                                        if (option.value_type == "FilePath" || option.value_type == "FolderPath") 
     131                                                option_value = Shell.quote (option_value); 
     132                                        _option_settings[option_name].name = option_name; 
     133                                        required_options_str += " " + option.format.replace ("%value", option_value); 
     134                                } 
     135                        } 
     136                 
     137                // Fill optional_options_str 
     138                var optional_options_str = ""; 
     139                if (optional_options != null) 
     140                        foreach (var option_name in optional_options) 
     141                        { 
     142                                var option_view = get_option_view (option_name); 
     143                                if (option_view == null) 
     144                                        continue; 
     145                                if (option_view.sensitive && option_view.active) 
     146                                { 
     147                                        if (option_view.value == null || option_view.value == "") 
     148                                                throw new OptionError.OPTION_VALUE_MISSING (_("Option value missing: ") + option_name); 
     149                                        var option = get_option (option_name); 
     150                                        var option_value = option_view.value; 
     151                                        if (option.value_type == "FilePath" || option.value_type == "FolderPath") 
     152                                                option_value = Shell.quote (option_value); 
     153                                        _option_settings[option_name].name = option_name; 
     154                                        optional_options_str += " " + option.format.replace ("%value", option_value); 
     155                                } 
     156                        } 
     157                 
    133158                if (format == null) 
    134                         return @"$required_options $optional_options"; 
     159                        return @"$required_options_str $optional_options_str"; 
    135160                var formatted_options = format; 
    136                 formatted_options = formatted_options.replace ("%required_options", required_options); 
    137                 formatted_options = formatted_options.replace ("%optional_options", optional_options); 
    138                 formatted_options = formatted_options.replace ("%options", @"$required_options $optional_options"); 
     161                formatted_options = formatted_options.replace ("%required_options", required_options_str); 
     162                formatted_options = formatted_options.replace ("%optional_options", optional_options_str); 
     163                formatted_options = formatted_options.replace ("%options", @"$required_options_str $optional_options_str"); 
    139164                return formatted_options; 
    140165        } 
    141166         
    142         public bool valid_required_options () 
    143         { 
     167        public bool valid_required_options (Gee.List<string>? required_options) 
     168        { 
     169                // Return false if there's no options added 
    144170                if (_options == null) 
    145171                        return false; 
    146172                 
     173                // Return true if there's no required options 
     174                if (required_options == null || required_options.size == 0) 
     175                        return true; 
     176                 
    147177                // Check if the required options are valid 
    148178                var valid_options = true; 
    149                 foreach (var option in _options) 
    150                 { 
    151                         if (!option.optional) 
    152                         { 
    153                                 var option_view = get_option_view (option.name); 
    154                                 if (option_view == null) 
    155                                         return false; 
    156                                 valid_options &= option_view.value != null && option_view.value != ""; 
    157                         } 
     179                foreach (var option_name in required_options) 
     180                { 
     181                        var option_view = get_option_view (option_name); 
     182                        if (option_view == null) 
     183                                return false; 
     184                        valid_options &= option_view.value != null && option_view.value != ""; 
    158185                } 
    159186                return valid_options; 
  • libi4uccore/programmer.vala

    r9ab0cbf r42bad28  
    9090        private HashMap<string, string> _description = new HashMap<string, string> (); 
    9191        private ArrayList<Option> _options = new ArrayList<Option> (); 
     92        private HashMap<string, Gee.List<string>> _required_options = new HashMap<string, Gee.List<string>> (); 
     93        private HashMap<string, Gee.List<string>> _optional_options = new HashMap<string, Gee.List<string>> (); 
    9294        private string _lang; 
    9395         
     
    112114        public Gee.Map<string, string> description { get { return _description; } } 
    113115        public Gee.List<Option> options { get { return _options; } } 
     116        public Gee.Map<string, Gee.List<string>> required_options { get { return _required_options; } } 
     117        public Gee.Map<string, Gee.List<string>> optional_options { get { return _optional_options; } } 
    114118         
    115119        public string locale_description 
  • libi4uccore/programmerloader.vala

    rd6d5a30 r42bad28  
    221221                                break; 
    222222                         
     223                        case "required_options": 
     224                                var required_options_list = new ArrayList<string> (); 
     225                                foreach (var option_name in text.split (",")) 
     226                                        required_options_list.add (option_name); 
     227                                _programmer.required_options[_action] = required_options_list; 
     228                                break; 
     229                         
     230                        case "optional_options": 
     231                                var optional_options_list = new ArrayList<string> (); 
     232                                foreach (var option_name in text.split (",")) 
     233                                        optional_options_list.add (option_name); 
     234                                _programmer.optional_options[_action] = optional_options_list; 
     235                                break; 
     236                         
    223237                        case "label": 
    224238                                _new_option.label[_lang] = text; 
  • libi4uccore/programmerslogic.vala

    r9ab0cbf r42bad28  
    5757                _view.write_flash_clicked.connect (on_write_flash_clicked); 
    5858                _view.read_flash_clicked.connect (on_read_flash_clicked); 
    59                 _view.verify_flash_clicked.connect (() => run_command (_current_programmer.verify_flash_command)); 
     59                _view.verify_flash_clicked.connect (() => run_command ("verify_flash", _current_programmer.verify_flash_command)); 
    6060                _view.erase_flash_clicked.connect (on_erase_flash_clicked); 
    6161                _view.write_fuses_clicked.connect (on_write_fuses_clicked); 
    62                 _view.read_fuses_clicked.connect (() => run_command (_current_programmer.read_fuses_command)); 
    63                 _view.get_version_clicked.connect (() => run_command (_current_programmer.get_version_command)); 
     62                _view.read_fuses_clicked.connect (() => run_command ("read_fuses", _current_programmer.read_fuses_command)); 
     63                _view.get_version_clicked.connect (() => run_command ("get_version", _current_programmer.get_version_command)); 
    6464                _view.stop_clicked.connect (() => _command_runner.stop ()); 
    6565                _command_runner.finished.connect (on_command_finished); 
     
    7373                try 
    7474                { 
    75                         var filtered_command = _options_logic.get_options (_current_programmer.write_flash_command); 
     75                        var required_options = _current_programmer.required_options["write_flash"]; 
     76                        var optional_options = _current_programmer.optional_options["write_flash"]; 
     77                        var filtered_command = _options_logic.get_options (required_options, optional_options, _current_programmer.write_flash_command); 
    7678                         
    7779                        var firmware = File.new_for_uri (uri).get_path (); 
     
    142144        { 
    143145                if (_app.view_factory.show_yes_no_message (_("Are you sure you want to write the flash memory?")) == DialogResponse.YES) 
    144                         run_command (_current_programmer.write_flash_command); 
     146                        run_command ("write_flash", _current_programmer.write_flash_command); 
    145147        } 
    146148         
     
    154156                        _app.settings.working_folder = folder_uri; 
    155157                        _read_firmware = firmware_uri; 
    156                         run_command (_current_programmer.read_flash_command); 
     158                        run_command ("read_flash", _current_programmer.read_flash_command); 
    157159                } 
    158160        } 
     
    161163        { 
    162164                if (_app.view_factory.show_yes_no_message (_("Are you sure you want to erase the flash memory?")) == DialogResponse.YES) 
    163                         run_command (_current_programmer.erase_flash_command); 
     165                        run_command ("erase_flash", _current_programmer.erase_flash_command); 
    164166        } 
    165167         
     
    167169        { 
    168170                if (_app.view_factory.show_yes_no_message (_("Are you sure you want to write the fuses?")) == DialogResponse.YES) 
    169                         run_command (_current_programmer.write_fuses_command); 
     171                        run_command ("write_fuses", _current_programmer.write_fuses_command); 
    170172        } 
    171173         
     
    192194        } 
    193195         
    194         private void run_command (string command) 
     196        private void run_command (string command, string format) 
    195197        { 
    196198                try 
    197199                { 
    198                         var filtered_command = _options_logic.get_options (command); 
     200                        var required_options = _current_programmer.required_options[command]; 
     201                        var optional_options = _current_programmer.optional_options[command]; 
     202                        var filtered_command = _options_logic.get_options (required_options, optional_options, format); 
    199203                         
    200204                        if (_read_firmware == null) 
     
    238242                                 _current_programmer.is_valid_firmware_type (_view.pages_panel.current_page.tab_title); 
    239243                 
    240                 if (!_options_logic.valid_required_options ()) 
    241                         return; 
    242                  
    243                 this.can_write_flash = _current_programmer.can_write_flash; 
    244                 _view.write_flash_sensitive = valid_page && _current_programmer.can_write_flash; 
    245                 _view.read_flash_sensitive = _current_programmer.can_read_flash; 
    246                 _view.verify_flash_sensitive = valid_page && _current_programmer.can_verify_flash; 
    247                 _view.erase_flash_sensitive = _current_programmer.can_erase_flash; 
    248                 _view.write_fuses_sensitive = _current_programmer.can_write_fuses; 
    249                 _view.read_fuses_sensitive = _current_programmer.can_read_fuses; 
    250                 _view.get_version_sensitive = _current_programmer.can_get_version; 
     244                var write_flash_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["write_flash"]); 
     245                var read_flash_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["read_flash"]); 
     246                var verify_flash_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["verify_flash"]); 
     247                var erase_flash_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["erase_flash"]); 
     248                var write_fuses_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["write_fuses"]); 
     249                var read_fuses_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["read_fuses"]); 
     250                var get_version_valid_options = _options_logic.valid_required_options (_current_programmer.required_options["get_version"]); 
     251                 
     252                this.can_write_flash = _current_programmer.can_write_flash && write_flash_valid_options; 
     253                _view.write_flash_sensitive = valid_page && _current_programmer.can_write_flash && write_flash_valid_options; 
     254                _view.read_flash_sensitive = _current_programmer.can_read_flash && read_flash_valid_options; 
     255                _view.verify_flash_sensitive = valid_page && _current_programmer.can_verify_flash && verify_flash_valid_options; 
     256                _view.erase_flash_sensitive = _current_programmer.can_erase_flash && erase_flash_valid_options; 
     257                _view.write_fuses_sensitive = _current_programmer.can_write_fuses && write_fuses_valid_options; 
     258                _view.read_fuses_sensitive = _current_programmer.can_read_fuses && read_fuses_valid_options; 
     259                _view.get_version_sensitive = _current_programmer.can_get_version && get_version_valid_options; 
    251260                _view.stop_sensitive = _command_runner.is_running; 
    252261        } 
Note: See TracChangeset for help on using the changeset viewer.