[Ovmsdev] Reading config in OvmsVehicleXXXInit

Soko ovms at soko.cc
Sun Jul 26 15:15:37 HKT 2020


Hi Michael,

OK, understood. So the "My" in "MyConfig" is not for the vehicle, its a 
global thing, correct?

I wasn't sure as no other vehicle has multiple vehicle types. But as it 
is OK i will implement two VWeUP.

thanks

Soko

On 25.07.2020 20:31, Michael Balzer wrote:
> 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



More information about the OvmsDev mailing list