[Ovmsdev] Addition to OVMS Developer Guide
Stephen Casner
casner at acm.org
Fri Jan 1 09:34:20 HKT 2021
Michael,
> Regarding command options: for my latest command addition (obdii requests) I
> checked if we can use getopt_r(). Problems are a) it's not in the newlib
> included in esp-idf, and b) we also would need to change all handler
> signatures to allow getopt to modify the argv array. I also checked if some
> clever C++ getopt class is available but found none.
Another option (pun intended) would be to stick more with the original
parser design with trailing positional optional parameters rather than
prefix option flags. Option flags are familiar to many of us
developers, but that might not be the best choice for implementation
here.
Now, I'll admit that the obdii command has complex options that may
need to be implemented as you have done. However, let me cite one
counterexample:
Usage: event raise [-d<delay_ms>] <event>
This could have been done like homelink:
Usage: homelink <homelink> [<duration=1000ms>]
The latter form would be cleaner in that you wouldn't have to type the
-d prefix. Also, the tab completion that I implemented before you
added the delay option is now broken, although it would not be hard to
fix. I've edited in \t here where I pushed TAB:
OVMS# event raise system.mo\t
system.modem.down system.modem.gotip system.modem.stop
OVMS# event raise system.modem.g\totip \tsystem.modem.gotip
With the flexibility to have intermediate parameters now, using the
validate function, it may fit reasonably to have the options handled
by a subtree.
-- Steve
More information about the OvmsDev
mailing list