[Ovmsdev] Reading config in OvmsVehicleXXXInit

Michael Balzer dexter at expeedo.de
Sun Jul 26 02:31:14 HKT 2020


Soko,

the config store isn't available in the early boot stage when the system
classes get initialized. It's availability is signaled by the
"config.mounted" event (quite some time later, vehicles shouldn't even
depend on it during their instantiation).

So you cannot read the configuration during the vehicle factory init phase.

But you can choose to register both vehicles as separate types, which
would IMO make perfect sense. The user won't change the connection type,
and the capabilities of the OBD version will probably be extended and
different from the Komfort CAN version. If the differences are going to
be huge, the OBD2 e-Up will essentially be another vehicle in the OVMS view.

OvmsVehicleVWeUpInit::OvmsVehicleVWeUpInit()
  {
  ESP_LOGI(TAG, "Registering Vehicle: VW e-Up (9000)");
  MyVehicleFactory.RegisterVehicle<VWeUpT26a>("VWUP.T26", "VW e-Up
(Komfort CAN)");
  MyVehicleFactory.RegisterVehicle<VWeUpObd>("VWUP.OBD", "VW e-Up (OBD2)");
  }

The connection type web configuration as it's currently done only makes
sense if you handle the differences dynamically within the vehicle base
class.

Regards,
Michael


Am 25.07.20 um 18:25 schrieb Soko:
> Hey guys,
>
> I'd like to keep the sources for the T26A and OBD version for the VW
> e-up separated.
>
> With my little understanding of the OVMS framework I've created one
> (abstract) class for the vehicle with the web-interface stuff.
>
> Then two derived classes, one for OBD one for T26A.
>
> Now I try to register those two different classes depending on the
> settings:
>
> OvmsVehicleVWeUpInit::OvmsVehicleVWeUpInit()
> {
>   int how_connected = MyConfig.GetParamValueInt("vwup",
> "how_connected", CONN_OBD);
>   ESP_LOGI(TAG, "Registering Vehicle: VW e-Up (9000).
> how_connected=%d", how_connected);
>
>   if (how_connected == CONN_T26A)
>   {
> MyVehicleFactory.RegisterVehicle<VWeUpT26a>("VWUP", "VW e-Up");
>   }
>   else
>   {
> MyVehicleFactory.RegisterVehicle<VWeUpObd>("VWUP", "VW e-Up");
>   }
> }
>
> I know already that this only gets called during reboot as the
> log-message doesn't show up when I change the vehicle. But it seems
> that MyConfig isn't really the correct/same instance (?) as I'm
> getting inside my classes. Because the web-interface shows
> how_connected=CONN_T26A, but here it is always CONN_OBD (default value).
>
> How do I do this properly?
>
> Or is it even a better idea to do two separate vehicles??
>
> thx
>
> Soko
>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.openvehicles.com
> http://lists.openvehicles.com/mailman/listinfo/ovmsdev

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26




More information about the OvmsDev mailing list