[Ovmsdev] Addition to OVMS Developer Guide
Stephen Casner
casner at acm.org
Sun Jan 3 13:27:40 HKT 2021
Greg,
> Regarding obdii "complexity"... I've always wondered why the obdii
> command only has 'ecu' as a second and only parameter. If obdii is
> essentially the command front-end to the obd2ecu task, that split is
> odd. What else was considered for the obdii framework?
See cmd_obdii in components/vehicle/vehicle.cpp
> A few months ago there was a discussion on adding a bus speed parameter
> to the obd2ecu task start command. In general I'm not a fan of
> positional parameters, as they're not self-documenting, and parameter
> skipping is always hard to deal with. I also note that in terms of
> strings, there's no real difference between '-s', '--speed', and
> 'speed'. They're just strings to be matched. The value associated with
> that parameter, if any, would be included after a bit of white space.
> So, the proposal for adding a speed to the can bus selection would look
> like 'obdii ecu start can3 speed 500' (with kbits/sec implied).
> Alternatively, I can't imagine what else we'd add to that command, so
> just putting the '500' in there without an option prefix would work
> too. So, the use of option prefixes would be, um, "complexity driven"?
If the only expected addition for obdii ecu is the speed parameter,
then the way that would be added within the original design of the
command parser would be just:
Usage: obdii ecu start can3 [<bus speed=500>]
This is indicating that the parameter is optional and the default
value is 500. That _is_ a postional parameter. If you wanted more
flexibility for other parameters it could be:
Usage: obdii ecu start can3 [speed <bus speed=500>]
Michael's complaint is that if you added another optional paramter,
say color, you could set one or the other but not both:
Usage: obdii ecu start can3 [speed|color]
Usage: obdii ecu start can3 speed <bus speed>
Usage: obdii ecu start can3 color red|green|blue
Michael would prefer flag options. If done as he did for a delay
value on "event raise" it would be:
Usage: obdii ecu start can3 [-s<bus speed=500>] [-c<color>]
Or maybe, since people familiar with Unix-like systems expect flag
options to come first:
Usage: obdii ecu start [-s<bus speed=500>] [-c<color>] <bus#>
Or if willing to do the extra programming with the validate() function
to allow intermediate parameters:
Usage: obdii ecu start [-s<bus speed=500>] [-c<color>] can1|can2|can3
Here I would vote for simple. The complexity is in the vehicle.cpp
code.
-- Steve
More information about the OvmsDev
mailing list