[dfu-util] TI Stellaris prefix support for dfu-suffix
coronasensei at gmail.com
Fri Jul 6 02:13:32 CEST 2012
On 6/07/12 7:02 AM, Tormod Volden wrote:
> On Thu, Jul 5, 2012 at 7:40 AM, Tommi Keisala wrote:
>> Yes you are correct. There is optional_argument option for getopt_long but
>> that does not seem to work as I want it. And there seems to be a reason why
>> it is implemented as it is. Anyhow I do not want to use it. So I added
>> another option -t that requires no argument and is meant to use with
>> deleting prefix (with -D). And option -s is for adding (-a).
>> Suggestions are very welcome how to handle this better.
> I see some alternatives, not necessarily better:
> 1. Always require an address argument. Explain in the usage text that
> a dummy address is needed when deleting or checking. This allows us to
> do all Stellaris stuff without introducing more than one new option.
> 2. Replace "-D -t" with e.g. -T. So use -D for "normal" devices and -T
> for Stellaris. Then we would need a third option for "-t -c" unless we
> go back to always probing for this prefix. So we will still have to
> (or three) new options, so I am not sure this is better than your
> 3. Let -D delete the suffix as before. Let -T only delete prefix. So
> the most usual usage will practically be the same (-D -T vs -D -t),
> but it is more clear what each option does, and it is more flexible.
> Same issue for -c checking as in (2).
Another option would be to replace getopt for something else to parse
the arguments that can handle optional arguments. Ideally something
that's more posix/portable...?
I bring this up as getopt was one of the stumbling blocks I encountered
when compiling dfu-util with visual-c when I was having problems with
mingw and libusb. I had to find a port of getopt to include in the
project manually, as it's not covered by any standard windows libs.
To be honest though I don't know what would be a better args lib to use,
have to browse some other cross platform apps so see what they use.
More information about the devel